Skip to content

refactor: simplify testing framework with proper OOP design#526

Merged
tcoratger merged 1 commit intoleanEthereum:mainfrom
tcoratger:refactor/testing-framework-simplification
Apr 7, 2026
Merged

refactor: simplify testing framework with proper OOP design#526
tcoratger merged 1 commit intoleanEthereum:mainfrom
tcoratger:refactor/testing-framework-simplification

Conversation

@tcoratger
Copy link
Copy Markdown
Collaborator

Summary

  • Move building logic from fixture classes to spec types where it belongs. Each spec type now owns the methods that operate on its own fields.
  • Fixture files are now pure orchestration (~357 lines for fork_choice, ~144 for verify_signatures)
  • Fix bugs (double fixture registration, assert tuple, truncated hex in errors)
  • Remove dead code, modernize typing, improve documentation

What changed

Spec types own their building logic:

Spec Type New Methods
BlockSpec resolve_proposer_index, resolve_parent_root, build_attestations, build_signed_block, build_signed_block_with_store
AggregatedAttestationSpec build_attestation_data, build_invalid_proof
GossipAttestationSpec build_attestation_data, build_signed
GossipAggregatedAttestationSpec build_attestation_data, build_signed

Framework cleanup:

  • Fix double fixture registration bug in BaseFixture
  • Move expect_exception field + serializer to BaseConsensusFixture
  • Rewrite StoreChecks.validate_against_store with explicit checks (no dispatch tables, no unused args)
  • Convert all non-self methods to @staticmethod
  • Modernize typing imports (dict, list, type, set)
  • Delete dead code (_children, supports_fork, transitions_to)
  • Add XmssKeyManager.sign_and_aggregate for common pattern
  • Create test_types/utils.py for shared resolve_checkpoint
  • Update doc-writer agent rules
  • Show full hex in error messages

Net effect

  • -465 lines net reduction (1368 added, 1833 removed)
  • fork_choice.py: 666 → 357 lines
  • verify_signatures.py: 370 → 144 lines
  • Zero duplication between fixture files

Test plan

  • uvx tox -e all-checks passes
  • uv run fill --fork=devnet --clean -n auto generates all 123 fixtures

🤖 Generated with Claude Code

Move building logic from fixture classes to spec types where it belongs.
Each spec type now owns the methods that operate on its own fields:

- BlockSpec: resolve_proposer_index, resolve_parent_root, build_attestations,
  build_signed_block, build_signed_block_with_store
- AggregatedAttestationSpec: build_attestation_data, build_invalid_proof
- GossipAttestationSpec: build_attestation_data, build_signed
- GossipAggregatedAttestationSpec: build_attestation_data, build_signed

Fixture files are now pure orchestration (~357 lines for fork_choice,
~144 for verify_signatures). Also:

- Fix double fixture registration bug in BaseFixture
- Fix assert tuple bug in genesis.py
- Move expect_exception field + serializer to BaseConsensusFixture
- Rewrite StoreChecks.validate_against_store with explicit checks
- Remove dispatch tables and unused arguments
- Convert all non-self methods to @staticmethod
- Modernize typing imports (dict, list, type, set)
- Delete dead code (_children, supports_fork, transitions_to)
- Add XmssKeyManager.sign_and_aggregate for common pattern
- Create test_types/utils.py for shared resolve_checkpoint
- Update doc-writer agent rules for better documentation quality
- Show full hex in error messages instead of truncated

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tcoratger tcoratger merged commit 078a428 into leanEthereum:main Apr 7, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant