Skip to content

refactor(json-loader): use existing Pydantic fixture models #3617

Description

@danceratopz

The JSON loader passes raw dictionaries through its test runners and manually parses hexadecimal values, handles field aliases, and extracts nested fields. The testing package already has Pydantic models for these fixture formats.

Follow up on #3564 and jochem-brouwer/execution-specs#9. The suggestions PR now uses FixtureHeader in the fork-transition activation check; the broader loader refactor is outside that PR's scope. See the discussion about numeric conversions.

Start with BlockchainTestFixture.runtest() in tests/json_loader/helpers/load_blockchain_tests.py: parse the fixture once as BlockchainFixture and use its FixtureBlock and InvalidFixtureBlock objects. This should replace repeated dictionary access, manual RLP/hash hex parsing, and expected-exception field discovery.

Other candidates to assess separately are the state-test runner (StateFixture) and the header, account, withdrawal, and transaction conversion paths (FixtureHeader, Alloc, FixtureWithdrawal, and transaction models).

Implementation considerations:

  • Keep conversion into fork-specific spec types in explicit adapters. Fixture models permit intentionally invalid numeric values, so conversion to Uint, U256, and other spec types still needs appropriate error handling.
  • Preserve supplied RLP and hashes for verification, including checks against the original fixture data where model fields are computed.
  • Preserve support for older fixture formats and expected-invalid blocks; model validation must not prevent the intended execution checks.
  • Respect the package boundary: src/ must not import execution_testing. Adapters using testing models should live on the testing side.
  • Verify the refactor against representative valid, invalid, and fork-transition fixtures, plus legacy formats supported by the loader, and run just static.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

A-spec-testsArea: tests for specifications e.g. json_infraC-refactorCategory: refactor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions