Skip to content

Commit

Permalink
feat(t8n,filler): Append EELS resolution information to _info for gen…
Browse files Browse the repository at this point in the history
…erate 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.
  • Loading branch information
fselmo authored Jan 28, 2025
1 parent 83228e6 commit b16de8d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 7 additions & 1 deletion src/ethereum_clis/transition_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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 = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion src/ethereum_test_fixtures/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand All @@ -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."""
Expand Down
1 change: 1 addition & 0 deletions src/pytest_plugins/filler/filler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit b16de8d

Please sign in to comment.