Skip to content

Commit 46d4f4a

Browse files
committed
chore(fill): fix transition fork state test node ids.
1 parent e04edbe commit 46d4f4a

File tree

5 files changed

+40
-2
lines changed

5 files changed

+40
-2
lines changed

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Test fixtures for use by clients are available for each release on the [Github r
1515
- ✨ Add support for Nethermind's `nethtest` command to `consume direct` ([#1250](https://github.com/ethereum/execution-spec-tests/pull/1250)).
1616
- ✨ Allow filtering of test cases by fork via pytest marks (via, e.g., `-m "Cancun or Prague"`) ([#1304](https://github.com/ethereum/execution-spec-tests/pull/1304)).
1717
- 🐞 Improve index generation of ethereum/tests fixtures: Allow generation at any directory level and include `generatedTestHash` in the index file for the `fixture_hash` ([#1303](https://github.com/ethereum/execution-spec-tests/pull/1303)).
18+
- 🐞 Fix the node id for state tests marked by transition forks ([#1313](https://github.com/ethereum/execution-spec-tests/pull/1313)).
1819

1920
### 📋 Misc
2021

src/ethereum_test_forks/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
get_closest_fork_with_solc_support,
3434
get_deployed_forks,
3535
get_development_forks,
36+
get_fork_from_transition_fork,
37+
get_fork_to_transition_fork,
3638
get_forks,
3739
get_forks_with_no_descendants,
3840
get_forks_with_no_parents,
@@ -76,6 +78,8 @@
7678
"get_closest_fork_with_solc_support",
7779
"get_deployed_forks",
7880
"get_development_forks",
81+
"get_fork_from_transition_fork",
82+
"get_fork_to_transition_fork",
7983
"get_forks_with_no_descendants",
8084
"get_forks_with_no_parents",
8185
"get_forks_with_solc_support",

src/ethereum_test_forks/helpers.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,20 @@ def get_transition_forks() -> Set[Fork]:
9898
return transition_forks
9999

100100

101+
def get_fork_from_transition_fork(transition_fork: Fork) -> Fork:
102+
"""Return the fork from which the transition fork transitions."""
103+
if not issubclass(transition_fork, TransitionBaseClass):
104+
raise Exception(f"{transition_fork} is not a transition fork.")
105+
return transition_fork.transitions_from()
106+
107+
108+
def get_fork_to_transition_fork(transition_fork: Fork) -> Fork:
109+
"""Return the fork to which the transition fork transitions."""
110+
if not issubclass(transition_fork, TransitionBaseClass):
111+
raise Exception(f"{transition_fork} is not a transition fork.")
112+
return transition_fork.transitions_to()
113+
114+
101115
def get_from_until_fork_set(
102116
forks: Set[Fork], forks_from: Set[Fork], forks_until: Set[Fork]
103117
) -> Set[Fork]:

src/ethereum_test_forks/transition_base_fork.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ class NewTransitionClass(
4949
def transitions_to(cls) -> Fork:
5050
return to_fork
5151

52+
@classmethod
53+
def transitions_from(cls) -> Fork:
54+
return from_fork
55+
5256
NewTransitionClass.name = lambda: transition_name # type: ignore
5357

5458
def make_transition_method(

src/pytest_plugins/filler/filler.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from ethereum_clis.clis.geth import FixtureConsumerTool
2626
from ethereum_test_base_types import Alloc, ReferenceSpec
2727
from ethereum_test_fixtures import BaseFixture, FixtureCollector, FixtureConsumer, TestInfo
28-
from ethereum_test_forks import Fork
28+
from ethereum_test_forks import Fork, get_fork_from_transition_fork, get_transition_forks
2929
from ethereum_test_specs import SPEC_TYPES, BaseTest
3030
from ethereum_test_tools.utility.versioning import (
3131
generate_github_url,
@@ -753,7 +753,9 @@ def pytest_collection_modifyitems(config: pytest.Config, items: List[pytest.Item
753753
Remove pre-Paris tests parametrized to generate hive type fixtures; these
754754
can't be used in the Hive Pyspec Simulator.
755755
756-
This can't be handled in this plugins pytest_generate_tests() as the fork
756+
Replaces the test ID for state tests that use a transition fork with the base fork.
757+
758+
These can't be handled in this plugins pytest_generate_tests() as the fork
757759
parametrization occurs in the forks plugin.
758760
"""
759761
for item in items[:]: # use a copy of the list, as we'll be modifying it
@@ -780,6 +782,19 @@ def pytest_collection_modifyitems(config: pytest.Config, items: List[pytest.Item
780782
if "yul" in item.fixturenames: # type: ignore
781783
item.add_marker(pytest.mark.yul_test)
782784

785+
# Update test ID for state tests that use a transition fork
786+
if fork in get_transition_forks():
787+
has_state_test = any(marker.name == "state_test" for marker in markers)
788+
has_valid_transition = any(
789+
marker.name == "valid_at_transition_to" for marker in markers
790+
)
791+
if has_state_test and has_valid_transition:
792+
base_fork = get_fork_from_transition_fork(fork)
793+
item._nodeid = item._nodeid.replace(
794+
f"fork_{fork.name()}",
795+
f"fork_{base_fork.name()}",
796+
)
797+
783798

784799
def pytest_sessionfinish(session: pytest.Session, exitstatus: int):
785800
"""

0 commit comments

Comments
 (0)