Skip to content

Commit

Permalink
refactor!: change default test chain ID to match foundry's (#2460)
Browse files Browse the repository at this point in the history
Co-authored-by: antazoey <[email protected]>
  • Loading branch information
antazoey and antazoey authored Jan 7, 2025
1 parent 287a86c commit 0547d74
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/ape/utils/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
DEFAULT_NUMBER_OF_TEST_ACCOUNTS = 10
DEFAULT_TEST_MNEMONIC = "test test test test test test test test test test test junk"
DEFAULT_TEST_HD_PATH = "m/44'/60'/0'/0"
DEFAULT_TEST_CHAIN_ID = 1337
DEFAULT_TEST_CHAIN_ID = 31337
DEFAULT_TEST_ACCOUNT_BALANCE = int(10e21) # 10,000 Ether (in Wei)
GeneratedDevAccount = namedtuple("GeneratedDevAccount", ("address", "private_key"))
"""
Expand Down
11 changes: 6 additions & 5 deletions tests/functional/geth/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
VirtualMachineError,
)
from ape.utils import to_int
from ape.utils.testing import DEFAULT_TEST_CHAIN_ID
from ape_ethereum.ecosystem import Block
from ape_ethereum.provider import DEFAULT_SETTINGS, EthereumNodeProvider
from ape_ethereum.trace import TraceApproach
Expand Down Expand Up @@ -53,7 +54,7 @@ def process_factory_patch(mocker):
def tx_for_call(geth_contract):
return DynamicFeeTransaction.model_validate(
{
"chainId": 1337,
"chainId": DEFAULT_TEST_CHAIN_ID,
"to": geth_contract.address,
"gas": 4716984,
"value": 0,
Expand Down Expand Up @@ -146,7 +147,7 @@ def test_uri_invalid(geth_provider, project, ethereum):
@geth_process_test
def test_repr_connected(geth_provider):
actual = repr(geth_provider)
expected = f"<Node ({geth_provider.client_version}) chain_id=1337>"
expected = f"<Node ({geth_provider.client_version}) chain_id={DEFAULT_TEST_CHAIN_ID}>"
assert actual == expected


Expand All @@ -158,7 +159,7 @@ def test_repr_on_local_network_and_disconnected(networks):
node._web3 = None

actual = repr(node)
expected = "<Node chain_id=1337>"
expected = f"<Node chain_id={DEFAULT_TEST_CHAIN_ID}>"
assert actual == expected

if w3:
Expand All @@ -184,7 +185,7 @@ def test_get_logs(geth_contract, geth_account):

@geth_process_test
def test_chain_id_when_connected(geth_provider):
assert geth_provider.chain_id == 1337
assert geth_provider.chain_id == DEFAULT_TEST_CHAIN_ID


@geth_process_test
Expand All @@ -207,7 +208,7 @@ def test_chain_id_live_network_connected_uses_web3_chain_id(mocker, geth_provide
geth_provider.network = orig_network

# Still use the connected chain ID instead network's
assert actual == 1337
assert actual == DEFAULT_TEST_CHAIN_ID


@geth_process_test
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/geth/test_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def test_printing_debug_logs_compat(geth_provider, geth_account, vyper_printing)
@geth_process_test
def test_call_trace_supports_debug_trace_call(geth_contract, geth_account):
tx = {
"chainId": "0x539",
"chainId": "0x7a69",
"to": "0x77c7E3905c21177Be97956c6620567596492C497",
"value": "0x0",
"data": "0x23fd0e40",
Expand Down
3 changes: 2 additions & 1 deletion tests/functional/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
)
from ape.types.trace import SourceTraceback
from ape.utils.misc import ZERO_ADDRESS
from ape.utils.testing import DEFAULT_TEST_CHAIN_ID
from ape_ethereum.transactions import DynamicFeeTransaction, Receipt


@pytest.fixture(scope="module")
def failing_call():
# A call (tx without sender)
data = {
"chainId": 1337,
"chainId": DEFAULT_TEST_CHAIN_ID,
"to": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
"from": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"gas": 30029122,
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/cli/test_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest

from ape import __all__
from ape.utils.testing import DEFAULT_TEST_CHAIN_ID
from tests.conftest import ApeSubprocessRunner
from tests.integration.cli.utils import skip_projects, skip_projects_except

Expand Down Expand Up @@ -320,5 +321,5 @@ def test_console_code(integ_project, mocker, console_runner):
result = console_runner.invoke(
"--project", f"{integ_project.path}", "--code", "chain\nx = 3\nx + 1"
)
expected = "Out[1]: <ChainManager (id=1337)>\nOut[3]: 4\n"
expected = f"Out[1]: <ChainManager (id={DEFAULT_TEST_CHAIN_ID})>\nOut[3]: 4\n"
assert result.output == expected

0 comments on commit 0547d74

Please sign in to comment.