This repository was archived by the owner on May 29, 2026. It is now read-only.
refactor: extract shared BeaconChain test suite - #505
Open
cats2101 wants to merge 1 commit into
Open
Conversation
Factor out common BeaconChain contract tests into BeaconChainTestSuite in core testFixtures. Both InMemoryBeaconChainTest and KvDatabaseTest now extend this shared suite, eliminating duplicated test logic for getSealedBeaconBlocks, state/block CRUD, rollback, and null lookups. Implementation-specific tests remain in their respective test classes: - InMemory: uncommitted visibility, byte-array equality, state-by-number - KvDatabase: persistence across restarts, repeated writes, P2P state Closes Consensys#198
cats2101
force-pushed
the
refactor/shared-beacon-chain-test-suite
branch
from
April 5, 2026 19:19
3f0f54f to
eaf8aea
Compare
Author
|
Gentle ping — anything else needed here? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Factors out common
BeaconChaincontract tests into an abstractBeaconChainTestSuiteincore/src/testFixtures, so bothInMemoryBeaconChainTestandKvDatabaseTestinherit from a single shared suite.BeaconChaininterface contract: CRUD for states and blocks, rollback, null lookups,getSealedBeaconBlockspaginationInMemoryBeaconChainTest: uncommitted change visibility, byte-array equality, state lookup by block numberKvDatabaseTest: persistence across DB restarts, repeated writes, P2P stateNet result: -84 lines of duplicated test code, and KvDatabase now also runs shared tests it previously lacked (e.g. rollback, null lookups, initial state by hash).
Test plan
./gradlew :core:test— 16 tests pass (12 inherited + 4 specific)./gradlew :storage:test— 18 tests pass (12 inherited + 6 specific)Closes #198
Note
Low Risk
Low risk refactor limited to test code and test-fixture dependencies; production logic is unchanged, with main risk being altered test coverage/assumptions for implementations.
Overview
Refactors duplicated
BeaconChaintests into a new sharedBeaconChainTestSuite(incoretest fixtures) that validates common contract behavior (state/block CRUD, rollback, null lookups, andgetSealedBeaconBlockssequencing).Updates
InMemoryBeaconChainTestandKvDatabaseTestto extend the shared suite and keep only implementation-specific assertions (e.g., uncommitted visibility and byte-array key behavior for in-memory; persistence across restarts for RocksDB). Adds JUnit/AssertJ dependencies tocore’stestFixturesso the suite can be reused across modules.Reviewed by Cursor Bugbot for commit eaf8aea. Bugbot is set up for automated code reviews on this repo. Configure here.