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.
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
FixtureHeaderin 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()intests/json_loader/helpers/load_blockchain_tests.py: parse the fixture once asBlockchainFixtureand use itsFixtureBlockandInvalidFixtureBlockobjects. 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:
Uint,U256, and other spec types still needs appropriate error handling.src/must not importexecution_testing. Adapters using testing models should live on the testing side.just static.