Skip to content

Commit b16de8d

Browse files
authored
feat(t8n,filler): Append EELS resolution information to _info for generate test jsons (#1123)
- Look for ``info_metadata`` in the transition tool POST request response and use this field to extend the ``_info`` field in the generated test json.
1 parent 83228e6 commit b16de8d

File tree

6 files changed

+15
-4
lines changed

6 files changed

+15
-4
lines changed

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ Release tarball changes:
105105
- ✨ Use self-hosted runners for fixture building in CI ([#1051](https://github.com/ethereum/execution-spec-tests/pull/1051)).
106106
- ✨ Release tarballs now contain fixtures filled for all forks, not only the fork under active development and the fork currently deployed on mainnet ([#1053](https://github.com/ethereum/execution-spec-tests/pull/1053)).
107107
-`StateTest` fixture format now contains `state` field in each network post result, containing the decoded post allocation that results from the transaction execution ([#1064](https://github.com/ethereum/execution-spec-tests/pull/1064)).
108+
- ✨ Include EELS fork resolution information in filled json test fixtures ([#1123](https://github.com/ethereum/execution-spec-tests/pull/1123)).
108109

109110
### 💥 Breaking Change
110111

src/ethereum_clis/transition_tool.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def __init__(
7272
self.exception_mapper = exception_mapper
7373
super().__init__(binary=binary)
7474
self.trace = trace
75+
self._info_metadata: Optional[Dict[str, Any]] = {}
7576

7677
def __init_subclass__(cls):
7778
"""Register all subclasses of TransitionTool as possible tools."""
@@ -342,7 +343,12 @@ def _evaluate_server(
342343
response = self._server_post(
343344
data=request_data_json, url_args=self._generate_post_args(t8n_data), timeout=timeout
344345
)
345-
output: TransitionToolOutput = TransitionToolOutput.model_validate(response.json())
346+
response_json = response.json()
347+
348+
# pop optional test ``_info`` metadata from response, if present
349+
self._info_metadata = response_json.pop("_info_metadata", {})
350+
351+
output: TransitionToolOutput = TransitionToolOutput.model_validate(response_json)
346352

347353
if debug_output_path:
348354
response_info = (

src/ethereum_test_base_types/reference_spec/git_reference_spec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def has_known_version(self) -> bool:
9696
"""
9797
return self.SpecVersion != ""
9898

99-
def write_info(self, info: Dict[str, str]):
99+
def write_info(self, info: Dict[str, Dict[str, Any] | str]):
100100
"""
101101
Write info about the reference specification used into the output
102102
fixture.

src/ethereum_test_base_types/reference_spec/reference_spec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def is_outdated(self) -> bool:
6363
pass
6464

6565
@abstractmethod
66-
def write_info(self, info: Dict[str, str]):
66+
def write_info(self, info: Dict[str, Dict[str, Any] | str]):
6767
"""Write info about the reference specification used into the output fixture."""
6868
pass
6969

src/ethereum_test_fixtures/base.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class BaseFixture(CamelModel):
1515
"""Represents a base Ethereum test fixture of any type."""
1616

17-
info: Dict[str, str] = Field(default_factory=dict, alias="_info")
17+
info: Dict[str, Dict[str, Any] | str] = Field(default_factory=dict, alias="_info")
1818

1919
# Fixture format properties
2020
fixture_format_name: ClassVar[str] = "unset"
@@ -52,6 +52,7 @@ def fill_info(
5252
test_case_description: str,
5353
fixture_source_url: str,
5454
ref_spec: ReferenceSpec | None,
55+
_info_metadata: Dict[str, Any],
5556
):
5657
"""Fill the info field for this fixture."""
5758
if "comment" not in self.info:
@@ -62,6 +63,8 @@ def fill_info(
6263
self.info["fixture_format"] = self.fixture_format_name
6364
if ref_spec is not None:
6465
ref_spec.write_info(self.info)
66+
if _info_metadata:
67+
self.info.update(_info_metadata)
6568

6669
def get_fork(self) -> str | None:
6770
"""Return fork of the fixture as a string."""

src/pytest_plugins/filler/filler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,7 @@ def __init__(self, *args, **kwargs):
679679
test_case_description,
680680
fixture_source_url=fixture_source_url,
681681
ref_spec=reference_spec,
682+
_info_metadata=t8n._info_metadata,
682683
)
683684

684685
fixture_path = fixture_collector.add_fixture(

0 commit comments

Comments
 (0)