Skip to content

Composite Store unit tests#3576

Merged
cody-littley merged 5 commits into
mainfrom
cjl/deep-composite-tests
Jun 11, 2026
Merged

Composite Store unit tests#3576
cody-littley merged 5 commits into
mainfrom
cjl/deep-composite-tests

Conversation

@cody-littley

Copy link
Copy Markdown
Contributor

Describe your changes and provide context

New suite of unit tests for composite.Store

@cody-littley cody-littley requested a review from blindchaser June 11, 2026 16:24
@cody-littley cody-littley self-assigned this Jun 11, 2026
@cursor

cursor Bot commented Jun 11, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Test-only additions with no production code changes; increases CI time for the composite package but does not affect runtime behavior.

Overview
Adds a deterministic, oracle-based randomized test suite for CompositeCommitStore (~2k lines of test-only code in random_test_framework_test.go and random_test.go).

The harness drives the full store API (commit, read, iterate, proofs, rollback, export/import, historical LoadVersion) against an in-memory reference model, with deep checks on memiavl vs flatkv placement, physical flatkv rows (including EVM account merge), migration metadata, commit info, and ICS-23 proof routing. Workloads cover bank/staking/evm stores, intra-block last-write-wins conflicts, and flatkv-specific key/value shapes.

Eight scenario tests (go test -run Random): five steady-state WriteModes (CRUD, rollback+restart, WAL replay restart, read-only historical snapshot, state-sync clone, dual-backend crash reconcile) and three migration paths (EVM, all-but-bank, bank) including mid-migration rollback, crash reconcile, and clone-while-in-flight.

Reviewed by Cursor Bugbot for commit 0aeffcb. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedJun 11, 2026, 6:41 PM

@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.38%. Comparing base (9833853) to head (0aeffcb).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3576      +/-   ##
==========================================
- Coverage   59.18%   58.38%   -0.81%     
==========================================
  Files        2210     2139      -71     
  Lines      183250   175208    -8042     
==========================================
- Hits       108460   102292    -6168     
+ Misses      64998    63780    -1218     
+ Partials     9792     9136     -656     
Flag Coverage Δ
sei-db 70.41% <ø> (ø)
sei-db-state-db ?
sei-db-state-db-pr 73.46% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 72 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

// rolled-back keyspace.
func liveKeySetFromOracle(o *storeOracle) *liveKeySet {
s := newLiveKeySet()
for store, m := range o.stores {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Go map iteration order is randomized per run, so the resulting keys slice order is nondeterministic. Every later keysInUse.Sample(...) indexes into that slice, meaning which keys get read/updated/deleted/sampled depends on map order, not the RNG seed. This contradicts the harness's explicit contract ("a given seed yields a byte-identical apply/commit sequence", "fully reproducible from r's seed", framework header lines 158–160 and 439–440). The guarantee holds for Phase 1 only; it's violated everywhere liveKeySetFromOracle is used — steady-state Phases 2+ (random_test.go:82,124,157) and every migration resume (:368,392,410).

Practical impact: when CI fails and prints Random seed: N, re-running with seed N will not reproduce the failing sequence past the first rollback — the printed seed is misleading exactly when you need it. Fix is small: collect the pairs into a slice, sort by (store, key), then Add in sorted order.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

change made

// flatkv (migrated). Use immediately before a mid-migration restart to confirm
// the test actually exercises the in-flight resume path. Ported from the
// migration framework's AssertMigrationInFlight.
func assertMigrationInFlight(t *testing.T, cs *CompositeCommitStore, oracle *storeOracle, migratingStores ...string) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

flakiness: assertMigrationInFlight is seed-dependent and can spuriously fail

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

@cody-littley cody-littley enabled auto-merge June 11, 2026 18:39
@cody-littley cody-littley added this pull request to the merge queue Jun 11, 2026
Merged via the queue into main with commit 57bba16 Jun 11, 2026
60 checks passed
@cody-littley cody-littley deleted the cjl/deep-composite-tests branch June 11, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants