diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 6e41e12dfce..50a4af056b3 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -105,6 +105,7 @@ Release tarball changes: - ✨ Use self-hosted runners for fixture building in CI ([#1051](https://github.com/ethereum/execution-spec-tests/pull/1051)). - ✨ 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)). - ✨ `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)). +- ✨ Include EELS fork resolution information in filled json test fixtures ([#1123](https://github.com/ethereum/execution-spec-tests/pull/1123)). ### 💥 Breaking Change diff --git a/src/ethereum_clis/transition_tool.py b/src/ethereum_clis/transition_tool.py index 6614b1928e2..89bb85fdbcb 100644 --- a/src/ethereum_clis/transition_tool.py +++ b/src/ethereum_clis/transition_tool.py @@ -72,6 +72,7 @@ def __init__( self.exception_mapper = exception_mapper super().__init__(binary=binary) self.trace = trace + self._info_metadata: Optional[Dict[str, Any]] = {} def __init_subclass__(cls): """Register all subclasses of TransitionTool as possible tools.""" @@ -342,7 +343,12 @@ def _evaluate_server( response = self._server_post( data=request_data_json, url_args=self._generate_post_args(t8n_data), timeout=timeout ) - output: TransitionToolOutput = TransitionToolOutput.model_validate(response.json()) + response_json = response.json() + + # pop optional test ``_info`` metadata from response, if present + self._info_metadata = response_json.pop("_info_metadata", {}) + + output: TransitionToolOutput = TransitionToolOutput.model_validate(response_json) if debug_output_path: response_info = ( diff --git a/src/ethereum_test_base_types/reference_spec/git_reference_spec.py b/src/ethereum_test_base_types/reference_spec/git_reference_spec.py index 45ec4eb6e0a..a74fd9fc91e 100644 --- a/src/ethereum_test_base_types/reference_spec/git_reference_spec.py +++ b/src/ethereum_test_base_types/reference_spec/git_reference_spec.py @@ -96,7 +96,7 @@ def has_known_version(self) -> bool: """ return self.SpecVersion != "" - def write_info(self, info: Dict[str, str]): + def write_info(self, info: Dict[str, Dict[str, Any] | str]): """ Write info about the reference specification used into the output fixture. diff --git a/src/ethereum_test_base_types/reference_spec/reference_spec.py b/src/ethereum_test_base_types/reference_spec/reference_spec.py index 10e86a4ce1b..1da8820cec8 100644 --- a/src/ethereum_test_base_types/reference_spec/reference_spec.py +++ b/src/ethereum_test_base_types/reference_spec/reference_spec.py @@ -63,7 +63,7 @@ def is_outdated(self) -> bool: pass @abstractmethod - def write_info(self, info: Dict[str, str]): + def write_info(self, info: Dict[str, Dict[str, Any] | str]): """Write info about the reference specification used into the output fixture.""" pass diff --git a/src/ethereum_test_fixtures/base.py b/src/ethereum_test_fixtures/base.py index 922d12760e5..cbc971d84a9 100644 --- a/src/ethereum_test_fixtures/base.py +++ b/src/ethereum_test_fixtures/base.py @@ -14,7 +14,7 @@ class BaseFixture(CamelModel): """Represents a base Ethereum test fixture of any type.""" - info: Dict[str, str] = Field(default_factory=dict, alias="_info") + info: Dict[str, Dict[str, Any] | str] = Field(default_factory=dict, alias="_info") # Fixture format properties fixture_format_name: ClassVar[str] = "unset" @@ -52,6 +52,7 @@ def fill_info( test_case_description: str, fixture_source_url: str, ref_spec: ReferenceSpec | None, + _info_metadata: Dict[str, Any], ): """Fill the info field for this fixture.""" if "comment" not in self.info: @@ -62,6 +63,8 @@ def fill_info( self.info["fixture_format"] = self.fixture_format_name if ref_spec is not None: ref_spec.write_info(self.info) + if _info_metadata: + self.info.update(_info_metadata) def get_fork(self) -> str | None: """Return fork of the fixture as a string.""" diff --git a/src/pytest_plugins/filler/filler.py b/src/pytest_plugins/filler/filler.py index 3e945ed0a68..a3c4dac5c8b 100644 --- a/src/pytest_plugins/filler/filler.py +++ b/src/pytest_plugins/filler/filler.py @@ -679,6 +679,7 @@ def __init__(self, *args, **kwargs): test_case_description, fixture_source_url=fixture_source_url, ref_spec=reference_spec, + _info_metadata=t8n._info_metadata, ) fixture_path = fixture_collector.add_fixture(