diff --git a/src/ethereum_test_forks/base_fork.py b/src/ethereum_test_forks/base_fork.py index 645f9490b2..c5cb903d6b 100644 --- a/src/ethereum_test_forks/base_fork.py +++ b/src/ethereum_test_forks/base_fork.py @@ -73,6 +73,7 @@ class BaseFork(ABC, metaclass=BaseForkMeta): _transition_tool_name: ClassVar[Optional[str]] = None _blockchain_test_network_name: ClassVar[Optional[str]] = None _solc_name: ClassVar[Optional[str]] = None + _ignore: ClassVar[bool] = False def __init_subclass__( cls, @@ -80,6 +81,7 @@ def __init_subclass__( transition_tool_name: Optional[str] = None, blockchain_test_network_name: Optional[str] = None, solc_name: Optional[str] = None, + ignore: bool = False, ) -> None: """ Initializes the new fork with values that don't carry over to subclass forks. @@ -87,6 +89,7 @@ def __init_subclass__( cls._transition_tool_name = transition_tool_name cls._blockchain_test_network_name = blockchain_test_network_name cls._solc_name = solc_name + cls._ignore = ignore # Header information abstract methods @classmethod @@ -287,6 +290,13 @@ def is_deployed(cls) -> bool: """ return True + @classmethod + def ignore(cls) -> bool: + """ + Returns whether the fork should be ignored during test generation. + """ + return cls._ignore + # Fork Type Fork = Type[BaseFork] diff --git a/src/ethereum_test_forks/forks/forks.py b/src/ethereum_test_forks/forks/forks.py index 51094de37e..223abbe224 100644 --- a/src/ethereum_test_forks/forks/forks.py +++ b/src/ethereum_test_forks/forks/forks.py @@ -231,7 +231,7 @@ def precompiles(cls, block_number: int = 0, timestamp: int = 0) -> List[int]: # Glacier forks skipped, unless explicitly specified -class MuirGlacier(Istanbul, solc_name="istanbul"): +class MuirGlacier(Istanbul, solc_name="istanbul", ignore=True): """ Muir Glacier fork """ @@ -273,7 +273,7 @@ def tx_types(cls, block_number: int = 0, timestamp: int = 0) -> List[int]: # Glacier forks skipped, unless explicitly specified -class ArrowGlacier(London, solc_name="london"): +class ArrowGlacier(London, solc_name="london", ignore=True): """ Arrow Glacier fork """ @@ -281,7 +281,7 @@ class ArrowGlacier(London, solc_name="london"): pass -class GrayGlacier(ArrowGlacier, solc_name="london"): +class GrayGlacier(ArrowGlacier, solc_name="london", ignore=True): """ Gray Glacier fork """ diff --git a/src/ethereum_test_forks/transition_base_fork.py b/src/ethereum_test_forks/transition_base_fork.py index 2e4fcf400f..e067d89f6e 100644 --- a/src/ethereum_test_forks/transition_base_fork.py +++ b/src/ethereum_test_forks/transition_base_fork.py @@ -1,6 +1,7 @@ """ Base objects used to define transition forks. """ + from inspect import signature from typing import Callable, List, Type @@ -54,6 +55,7 @@ class NewTransitionClass( transition_tool_name=cls._transition_tool_name, blockchain_test_network_name=cls._blockchain_test_network_name, solc_name=cls._solc_name, + ignore=cls._ignore, ): pass diff --git a/src/ethereum_test_tools/tests/test_code.py b/src/ethereum_test_tools/tests/test_code.py index ceceefb52b..03d815bc9b 100644 --- a/src/ethereum_test_tools/tests/test_code.py +++ b/src/ethereum_test_tools/tests/test_code.py @@ -53,10 +53,6 @@ def test_code_operations(code: Code, expected_bytes: bytes): def fork(request: pytest.FixtureRequest): """ Return the target evm-version (fork) for solc compilation. - - Note: - - Homestead. - - forks_from_until: Used to remove the Glacier forks """ return request.param diff --git a/src/pytest_plugins/forks/forks.py b/src/pytest_plugins/forks/forks.py index 8bf23e4f3e..18cbad1560 100644 --- a/src/pytest_plugins/forks/forks.py +++ b/src/pytest_plugins/forks/forks.py @@ -1,6 +1,7 @@ """ Pytest plugin to enable fork range configuration for the test session. """ + import itertools import sys import textwrap @@ -13,7 +14,6 @@ from ethereum_test_forks import ( Fork, ForkAttribute, - forks_from_until, get_deployed_forks, get_forks, get_transition_forks, @@ -186,9 +186,7 @@ def get_fork_option(config, option_name): forks_until = get_fork_option(config, "forks_until") show_fork_help = config.getoption("show_fork_help") - all_forks = get_forks() - # TODO: Tricky, this removes the *Glacier forks. - config.all_forks = forks_from_until(all_forks[0], all_forks[-1]) + config.all_forks = [fork for fork in get_forks() if not fork.ignore()] config.fork_map = {fork.name(): fork for fork in config.all_forks} config.fork_names = list(config.fork_map.keys()) @@ -433,17 +431,19 @@ def pytest_generate_tests(metafunc): ) else: pytest_params = [ - ForkParametrizer( - fork=fork, - mark=pytest.mark.skip( - reason=( - f"Fork '{fork}' unsupported by " - f"'{metafunc.config.getoption('evm_bin')}'." - ) - ), + ( + ForkParametrizer( + fork=fork, + mark=pytest.mark.skip( + reason=( + f"Fork '{fork}' unsupported by " + f"'{metafunc.config.getoption('evm_bin')}'." + ) + ), + ) + if fork.name() in metafunc.config.unsupported_forks + else ForkParametrizer(fork=fork) ) - if fork.name() in metafunc.config.unsupported_forks - else ForkParametrizer(fork=fork) for fork in intersection_range ] add_fork_covariant_parameters(metafunc, pytest_params)