Skip to content

Commit a6d9e4e

Browse files
authored
Merge branch 'main' into refactor/ethereum/safe-proxy-heuristic
2 parents f2c8981 + 0f1a967 commit a6d9e4e

4 files changed

Lines changed: 46 additions & 20 deletions

File tree

tests/conftest.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,14 @@ def custom_network_chain_id_1():
599599

600600
@pytest.fixture
601601
def custom_network(ethereum, project, custom_networks_config_dict):
602-
with project.temp_config(**custom_networks_config_dict):
602+
config = {
603+
**custom_networks_config_dict,
604+
ethereum.name: {
605+
CUSTOM_NETWORK_0: {"required_confirmations": 0},
606+
CUSTOM_NETWORK_1: {"required_confirmations": 0},
607+
},
608+
}
609+
with project.temp_config(**config):
603610
yield ethereum.apenet
604611

605612

@@ -646,4 +653,4 @@ def empty_project():
646653

647654
@pytest.fixture
648655
def geth_contract(geth_account, project, geth_provider):
649-
return geth_account.deploy(project.SolidityContract, 0)
656+
return geth_account.deploy(project.SolidityContract, 0, required_confirmations=0)

tests/functional/conftest.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,15 @@ def use_debug(logger):
406406

407407

408408
@pytest.fixture
409-
def dummy_live_network(chain):
410-
original_network = chain.provider.network.name
411-
chain.provider.network.name = "sepolia"
412-
yield chain.provider.network
413-
chain.provider.network.name = original_network
409+
def dummy_live_network(chain, project):
410+
network = chain.provider.network
411+
original_network = network.name
412+
network.name = "sepolia"
413+
try:
414+
with project.temp_config(ethereum={"sepolia": {"required_confirmations": 0}}):
415+
yield network
416+
finally:
417+
network.name = original_network
414418

415419

416420
@pytest.fixture
@@ -620,15 +624,19 @@ def mock_sepolia(create_mock_sepolia):
620624

621625

622626
@pytest.fixture
623-
def create_mock_sepolia(ethereum, eth_tester_provider, minimal_proxy):
627+
def create_mock_sepolia(ethereum, eth_tester_provider, minimal_proxy, project):
624628
@contextmanager
625629
def fn():
626630
# Ensuring contract exists before hack.
627631
# This allows the network to be past genesis which is more realistic.
628632
_ = minimal_proxy
629-
eth_tester_provider.network.name = "sepolia"
630-
yield eth_tester_provider.network
631-
eth_tester_provider.network.name = LOCAL_NETWORK_NAME
633+
network = eth_tester_provider.network
634+
network.name = "sepolia"
635+
try:
636+
with project.temp_config(ethereum={"sepolia": {"required_confirmations": 0}}):
637+
yield network
638+
finally:
639+
network.name = LOCAL_NETWORK_NAME
632640

633641
return fn
634642

tests/functional/geth/conftest.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,31 @@ def contract_with_call_depth_geth(
2121
and is used for any testing that requires nested calls, such as
2222
call trees or event-name clashes.
2323
"""
24-
return owner.deploy(project.ContractA, middle_contract_geth, leaf_contract_geth)
24+
return owner.deploy(
25+
project.ContractA, middle_contract_geth, leaf_contract_geth, required_confirmations=0
26+
)
2527

2628

2729
@pytest.fixture
2830
def error_contract_geth(owner, project, geth_provider):
2931
_ = geth_provider # Ensure uses geth
30-
return owner.deploy(project.HasError, 1)
32+
return owner.deploy(project.HasError, 1, required_confirmations=0)
3133

3234

3335
@pytest.fixture
3436
def leaf_contract_geth(project, geth_provider, owner):
3537
"""
3638
The last contract called by `contract_with_call_depth`.
3739
"""
38-
return owner.deploy(project.ContractC)
40+
return owner.deploy(project.ContractC, required_confirmations=0)
3941

4042

4143
@pytest.fixture
4244
def middle_contract_geth(project, geth_provider, owner, leaf_contract_geth):
4345
"""
4446
The middle contract called by `contract_with_call_depth`.
4547
"""
46-
return owner.deploy(project.ContractB, leaf_contract_geth)
48+
return owner.deploy(project.ContractB, leaf_contract_geth, required_confirmations=0)
4749

4850

4951
@pytest.fixture
@@ -83,7 +85,12 @@ def custom_network_connection(
8385
data["networks"]["custom"][0]["chain_id"] = geth_provider.chain_id
8486

8587
config = {
86-
ethereum.name: {custom_network_name_0: {"default_transaction_type": 0}},
88+
ethereum.name: {
89+
custom_network_name_0: {
90+
"default_transaction_type": 0,
91+
"required_confirmations": 0,
92+
}
93+
},
8794
geth_provider.name: {ethereum.name: {custom_network_name_0: {"uri": geth_provider.uri}}},
8895
**data,
8996
}

tests/functional/geth/test_network_manager.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
@pytest.fixture
8-
def mock_geth_sepolia(ethereum, geth_provider, geth_contract):
8+
def mock_geth_sepolia(ethereum, geth_provider, geth_contract, project):
99
"""
1010
Temporarily tricks Ape into thinking the local network
1111
is Sepolia so we can test features that require a live
@@ -14,9 +14,13 @@ def mock_geth_sepolia(ethereum, geth_provider, geth_contract):
1414
# Ensuring contract exists before hack.
1515
# This allows the network to be past genesis which is more realistic.
1616
_ = geth_contract
17-
geth_provider.network.name = "sepolia"
18-
yield geth_provider.network
19-
geth_provider.network.name = LOCAL_NETWORK_NAME
17+
network = geth_provider.network
18+
network.name = "sepolia"
19+
try:
20+
with project.temp_config(ethereum={"sepolia": {"required_confirmations": 0}}):
21+
yield network
22+
finally:
23+
network.name = LOCAL_NETWORK_NAME
2024

2125

2226
@geth_process_test

0 commit comments

Comments
 (0)