Skip to content

Commit

Permalink
feat: geth shanghai local (#1644)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Sep 1, 2023
1 parent 4a83d9b commit c48fe64
Show file tree
Hide file tree
Showing 31 changed files with 740 additions and 740 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '^1.20.1'
go-version: '^1.20.7'

- name: Install Geth
uses: gacts/install-geth-tools@v1
Expand All @@ -95,7 +95,7 @@ jobs:
pip install .[test]
- name: Run Tests
run: pytest -m "not fuzzing" -s --cov=src -n auto --dist loadscope
run: pytest -m "not fuzzing" -s --cov=src -n auto --dist loadgroup

fuzzing:
runs-on: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions src/ape/managers/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1211,9 +1211,9 @@ def instance_at(
if not txn_hash:
# Check for txn_hash in deployments.
deployments = self._deployments.get(contract_type.name) or []
for deployment in deployments:
if deployment["address"] == contract_address:
txn_hash = deployment.get("transaction_hash")
for deployment in deployments[::-1]:
if deployment["address"] == contract_address and "transaction_hash" in deployment:
txn_hash = deployment["transaction_hash"]
break

return ContractInstance(contract_address, contract_type, txn_hash=txn_hash)
Expand Down
1 change: 1 addition & 0 deletions src/ape_geth/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def __init__(
"berlinBlock": 0,
"londonBlock": 0,
"parisBlock": 0,
"shanghaiTime": 0,
"clique": {"period": 0, "epoch": 30000},
},
"alloc": alloc,
Expand Down
44 changes: 40 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@

# Needed to test tracing support in core `ape test` command.
pytest_plugins = ["pytester"]
geth_process_test = pytest.mark.xdist_group(name="geth-tests")
GETH_URI = "http://127.0.0.1:5550"
ALIAS = "__FUNCTIONAL_TESTS_ALIAS__"
geth_process_test = pytest.mark.xdist_group(name="geth-tests")
explorer_test = pytest.mark.xdist_group(name="explorer-tests")


@pytest.fixture(autouse=True)
Expand Down Expand Up @@ -91,10 +92,45 @@ def test_accounts(accounts):


@pytest.fixture(scope="session")
def sender(test_accounts):
def owner(test_accounts):
return test_accounts[0]


@pytest.fixture(scope="session")
def sender(test_accounts):
return test_accounts[1]


@pytest.fixture(scope="session")
def receiver(test_accounts):
return test_accounts[2]


@pytest.fixture(scope="session")
def not_owner(test_accounts):
return test_accounts[3]


@pytest.fixture(scope="session")
def helper(test_accounts):
return test_accounts[4]


@pytest.fixture
def signer(test_accounts):
return test_accounts[5]


@pytest.fixture
def geth_account(test_accounts):
return test_accounts[6]


@pytest.fixture
def geth_second_account(test_accounts):
return test_accounts[7]


@pytest.fixture
def project(config, project_folder):
project_folder.mkdir(parents=True, exist_ok=True)
Expand Down Expand Up @@ -266,8 +302,8 @@ def empty_data_folder():


@pytest.fixture
def keyfile_account(sender, keyparams, temp_accounts_path, temp_keyfile_account_ctx):
with temp_keyfile_account_ctx(temp_accounts_path, ALIAS, keyparams, sender) as account:
def keyfile_account(owner, keyparams, temp_accounts_path, temp_keyfile_account_ctx):
with temp_keyfile_account_ctx(temp_accounts_path, ALIAS, keyparams, owner) as account:
yield account


Expand Down
69 changes: 6 additions & 63 deletions tests/functional/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,6 @@ def contracts_folder():
return CONTRACTS_FOLDER


@pytest.fixture(scope="session")
def receiver(test_accounts):
return test_accounts[1]


@pytest.fixture(scope="session")
def owner(test_accounts):
return test_accounts[2]


@pytest.fixture(scope="session")
def not_owner(test_accounts):
return test_accounts[7]


@pytest.fixture(scope="session")
def address():
return TEST_ADDRESS
Expand Down Expand Up @@ -188,18 +173,13 @@ def sub_reverts_contract_container(sub_reverts_contract_type) -> ContractContain

@pytest.fixture
def reverts_contract_instance(
owner, reverts_contract_container, sub_reverts_contract_instance, geth_provider
owner, reverts_contract_container, sub_reverts_contract_instance, eth_tester_provider
) -> ContractInstance:
return owner.deploy(
reverts_contract_container, sub_reverts_contract_instance, required_confirmations=0
)


@pytest.fixture
def sub_reverts_contract_instance(owner, sub_reverts_contract_container, geth_provider):
return owner.deploy(sub_reverts_contract_container, required_confirmations=0)


@pytest.fixture(params=("solidity", "vyper"))
def contract_container(
request, solidity_contract_container, vyper_contract_container, networks_connected_to_tester
Expand Down Expand Up @@ -477,49 +457,18 @@ def unique_calldata():
) # functionWithUniqueArguments(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)


@pytest.fixture
def leaf_contract_geth(geth_provider, owner, get_contract_type):
"""
The last contract called by `contract_with_call_depth`.
"""
ct = get_contract_type("contract_c")
return owner.deploy(ContractContainer(ct))


@pytest.fixture
def leaf_contract(eth_tester_provider, owner, get_contract_type):
ct = get_contract_type("contract_c")
return owner.deploy(ContractContainer(ct))


@pytest.fixture
def middle_contract_geth(geth_provider, owner, leaf_contract_geth, get_contract_type):
"""
The middle contract called by `contract_with_call_depth`.
"""
ct = get_contract_type("contract_b")
return owner.deploy(ContractContainer(ct), leaf_contract_geth)


@pytest.fixture
def middle_contract(eth_tester_provider, owner, get_contract_type, leaf_contract):
ct = get_contract_type("contract_b")
return owner.deploy(ContractContainer(ct), leaf_contract)


@pytest.fixture
def contract_with_call_depth_geth(
owner, geth_provider, get_contract_type, leaf_contract_geth, middle_contract_geth
):
"""
This contract has methods that make calls to other local contracts
and is used for any testing that requires nested calls, such as
call trees or event-name clashes.
"""
contract = ContractContainer(get_contract_type("contract_a"))
return owner.deploy(contract, middle_contract_geth, leaf_contract_geth)


@pytest.fixture
def contract_with_call_depth(
owner, eth_tester_provider, get_contract_type, leaf_contract, middle_contract
Expand All @@ -528,6 +477,11 @@ def contract_with_call_depth(
return owner.deploy(contract, middle_contract, leaf_contract)


@pytest.fixture
def sub_reverts_contract_instance(owner, sub_reverts_contract_container, eth_tester_provider):
return owner.deploy(sub_reverts_contract_container, required_confirmations=0)


@pytest.fixture(scope="session")
def error_contract_container(get_contract_type):
ct = get_contract_type("has_error")
Expand All @@ -540,12 +494,6 @@ def error_contract(owner, error_contract_container, eth_tester_provider):
return owner.deploy(error_contract_container, 1)


@pytest.fixture
def error_contract_geth(owner, error_contract_container, geth_provider):
_ = geth_provider # Ensure uses geth
return owner.deploy(error_contract_container, 1)


@pytest.fixture
def vyper_factory(owner, get_contract_type):
return owner.deploy(ContractContainer(get_contract_type("vyper_factory")))
Expand All @@ -555,8 +503,3 @@ def vyper_factory(owner, get_contract_type):
def vyper_blueprint(owner, vyper_contract_container):
receipt = owner.declare(vyper_contract_container)
return receipt.contract_address


@pytest.fixture
def geth_vyper_contract(owner, vyper_contract_container, geth_provider):
return owner.deploy(vyper_contract_container, 0)

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading

0 comments on commit c48fe64

Please sign in to comment.