Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(fixtures,consume): Make BaseFixture able to parse any format #1210

Merged
merged 5 commits into from
Feb 14, 2025

Conversation

marioevz
Copy link
Member

@marioevz marioevz commented Feb 12, 2025

🗒️ Description

BaseFixture Refactor

Refactors BaseFixture to make it able to parse (validate) any defined fixture format.

The class now automatically collects all fixture formats and generates a type adapter that is able to discriminate based on the _info.fixture_format field.

This allows the creation of a single Fixtures class that is a pydantic root model, and is able to parse any fixtures file, without the need to create a new class for each fixture type, and the following classes have been removed:

  • BlockchainFixtures
  • BlockchainEngineFixtures
  • StateFixtures
  • TransactionFixtures
  • EOFFixtures

The constants FIXTURE_FORMATS and EXECUTE_FORMATS have also been removed since they are now automatically generated for current and any future fixture formats without any extra code.

One caveat is that ethereum/tests cannot be parsed automatically since they lack the _info.fixture_format field.

Due to this, a single definition of BlockchainFixtures is added to src/cli/eofwrap.py, since this script loads legacy tests.

Consume Fixture Loading Refactor

All hive consume simulators new use a single generic fixture to load any type of fixture, and the pytest fixture fixture_format has been added to every parametrized case.

New Fixture Format Example

In #1175, a new fixture format is introduced on top of the changes in this branch, and it can be appreciated how much the changes in this PR simplify the fixture format creation.

🔗 Related Issues

✅ Checklist

  • All: Set appropriate labels for the changes.
  • All: Considered squashing commits to improve commit history.
  • All: Added an entry to CHANGELOG.md.
  • All: Considered updating the online docs in the ./docs/ directory.
  • Tests: All converted JSON/YML tests from ethereum/tests have been added to converted-ethereum-tests.txt.
  • Tests: A PR with removal of converted JSON/YML tests from ethereum/tests have been opened.
  • Tests: Included the type and version of evm t8n tool used to locally execute test cases: e.g., ref with commit hash or geth 1.13.1-stable-3f40e65.
  • Tests: Ran mkdocs serve locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.

@marioevz marioevz added scope:pytest Scope: Changes EEST's pytest plugins type:refactor Type: Refactor scope:fw Scope: Framework (evm|tools|forks|pytest) labels Feb 12, 2025
@marioevz marioevz requested a review from danceratopz February 12, 2025 22:06
Copy link
Member

@danceratopz danceratopz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really amazing! 😄

I tried out the src/cli/check_fixtures command; it was trying to load the fixtures/.meta/eels_resolutions.json file and was correctly hitting "Fixture does not have an info field, cannot determine fixture format". Really nice. I fixed up the check_fixtures, but we currently don't use it anywhere.

The FixturesDict class to cache the fixtures in consume is a really nice addition!

@marioevz marioevz force-pushed the fixtures-consume-refactor branch from 1c91b20 to 6672261 Compare February 14, 2025 16:54
@marioevz marioevz merged commit 6baa2aa into main Feb 14, 2025
21 checks passed
@marioevz marioevz deleted the fixtures-consume-refactor branch February 14, 2025 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope:fw Scope: Framework (evm|tools|forks|pytest) scope:pytest Scope: Changes EEST's pytest plugins type:refactor Type: Refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants