diff --git a/src/ethereum_spec_tools/evm_tools/fixture_loader.py b/src/ethereum_spec_tools/evm_tools/fixture_loader.py index 8e78871dfc..7b4ce75c9c 100644 --- a/src/ethereum_spec_tools/evm_tools/fixture_loader.py +++ b/src/ethereum_spec_tools/evm_tools/fixture_loader.py @@ -32,6 +32,13 @@ def __init__(self, encoded_params: bytes, error_message: str) -> None: self.error_message = error_message +class EmptyAccountOnPostMergeFork(Exception): + """ + Exception for tests that are invalid due to empty accounts on post + merge forks + """ + + class BaseLoad(ABC): """Base class for loading json fixtures""" @@ -236,10 +243,15 @@ def _module(self, name: str) -> Any: """Imports a module from the fork""" return importlib.import_module(f"ethereum.{self._fork_module}.{name}") + def _is_post_merge_fork(self) -> bool: + return not hasattr(self._module("fork"), "validate_proof_of_work") + def json_to_state(self, raw: Any) -> Any: """Converts json state data to a state object""" state = self.State() set_storage = self._module("state").set_storage + is_post_merge_fork = self._is_post_merge_fork() + EMPTY_ACCOUNT = self._module("fork_types").EMPTY_ACCOUNT for address_hex, account_state in raw.items(): address = self.hex_to_address(address_hex) @@ -248,6 +260,8 @@ def json_to_state(self, raw: Any) -> Any: balance=U256(hex_to_uint(account_state.get("balance", "0x0"))), code=hex_to_bytes(account_state.get("code", "")), ) + if is_post_merge_fork and account == EMPTY_ACCOUNT: + raise EmptyAccountOnPostMergeFork self.set_account(state, address, account) for k, v in account_state.get("storage", {}).items(): diff --git a/tests/conftest.py b/tests/conftest.py index c44c9bc940..051b0748a3 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -112,5 +112,5 @@ def pytest_sessionstart(session: Session) -> None: git_clone_fixtures( props["url"], props["commit_hash"], fixture_path ) - else: + elif "url" in props: download_fixtures(props["url"], fixture_path) diff --git a/tests/helpers/__init__.py b/tests/helpers/__init__.py index f11894405c..c4ae723b50 100644 --- a/tests/helpers/__init__.py +++ b/tests/helpers/__init__.py @@ -12,7 +12,7 @@ }, "ethereum_tests": { "url": "https://github.com/ethereum/tests.git", - "commit_hash": "0ec53d0", + "commit_hash": "9e8719a", "fixture_path": "tests/fixtures/ethereum_tests", }, }