refactor(state): split tests.rs monolith into per-concern files#486
Merged
intendednull merged 1 commit intoApr 29, 2026
Merged
Conversation
tests.rs grew to 4714 LOC, 117 #[test] fns, single file. Adding new test = scroll monolith. Split by concern matching #[path] pattern from crates/client/src/lib.rs:49-55: tests/dag.rs — 17 tests (insert, equivocation, topo sort, ManagedDag, pending buffer) tests/materialize.rs — 54 tests (channels, messages, profiles, mute, pin, ephemeral, idempotency) tests/permissions.rs — 31 tests (grant/revoke, check_permission, kick, member edits, set_permission round-trip) tests/stress.rs — 7 tests (1000 events, 100 authors, sort perf, governance scale) tests/sync.rs — 2 tests (joining peer + grant batches) tests/voting.rs — 6 tests (proposal/vote ordering, multi-admin kick majority) All 117 tests preserved verbatim — only relocated. Test count before/after: 227 -> 227 (cargo test -p willow-state). Sixth bucket (stress.rs) added since the issue's five suggested buckets don't cleanly absorb the scale tests; CLAUDE.md guidance says add a sixth file rather than force-fit. Common helpers (genesis_kind, test_dag, do_emit) duplicated per-file with #![allow(unused_imports, dead_code)] so each bucket compiles standalone — every bucket only references a subset, but factoring them into a shared helper module would have required a load-bearing #[path]-glued helpers.rs that the issue's mechanical-split scope didn't ask for. Refs #263 https://claude.ai/code/session_01FHLLfYeh9P9FP7Y47wu9We
intendednull
added a commit
that referenced
this pull request
Apr 29, 2026
tests.rs grew to 4714 LOC, 117 #[test] fns, single file. Adding new test = scroll monolith. Split by concern matching #[path] pattern from crates/client/src/lib.rs:49-55: tests/dag.rs — 17 tests (insert, equivocation, topo sort, ManagedDag, pending buffer) tests/materialize.rs — 54 tests (channels, messages, profiles, mute, pin, ephemeral, idempotency) tests/permissions.rs — 31 tests (grant/revoke, check_permission, kick, member edits, set_permission round-trip) tests/stress.rs — 7 tests (1000 events, 100 authors, sort perf, governance scale) tests/sync.rs — 2 tests (joining peer + grant batches) tests/voting.rs — 6 tests (proposal/vote ordering, multi-admin kick majority) All 117 tests preserved verbatim — only relocated. Test count before/after: 227 -> 227 (cargo test -p willow-state). Sixth bucket (stress.rs) added since the issue's five suggested buckets don't cleanly absorb the scale tests; CLAUDE.md guidance says add a sixth file rather than force-fit. Common helpers (genesis_kind, test_dag, do_emit) duplicated per-file with #![allow(unused_imports, dead_code)] so each bucket compiles standalone — every bucket only references a subset, but factoring them into a shared helper module would have required a load-bearing #[path]-glued helpers.rs that the issue's mechanical-split scope didn't ask for. Refs #263 https://claude.ai/code/session_01FHLLfYeh9P9FP7Y47wu9We Co-authored-by: Claude <noreply@anthropic.com>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
what
crates/state/src/tests.rswas 4714 LOC, 117#[test]fns, one file. Issue #263 say split by concern. Did that.buckets
tests/dag.rstests/materialize.rstests/permissions.rstests/stress.rstests/sync.rstests/voting.rsSum 117. Pre-split file 4714 LOC monolith → 6 files biggest 1916 LOC. Below
materialize.rssource (1625 LOC), within reach.sixth bucket
Issue suggest five buckets. Stress tests no clean fit (large-DAG scale, performance bounds, perf-sensitive). CLAUDE.md guidance per dispatch says add sixth bucket rather than force. Named
stress.rs, theme obvious.wiring
#[path = "tests/<file>.rs"] mod tests_<bucket>;incrates/state/src/lib.rs, matchingcrates/client/src/lib.rs:49-55pattern issue called out. Removedtests.rs.helpers
Each bucket has its own copy of
genesis_kind,test_dag,do_emitplus the original 5-lineuseblock.#![allow(unused_imports, dead_code)]at top of each file so subset-using buckets compile clean. Tradeoff: 30 LOC of duplicated boilerplate per file vs introducing atests/common.rshelper module gated by another#[path]. Issue scope = mechanical split, no new abstraction. Picked duplication.verify
cargo test -p willow-state→ 227 passed (matches pre-split: 227 → 227, zero drift)cargo fmt --check→ cleancargo clippy --workspace --all-targets -- -D warnings→ cleancargo check --target wasm32-unknown-unknown -p willow-state→ cleanSub-PR base = master batch branch, not main → CI workflows scoped
branches: [main]not fire. Local gate green = merge gate.Refs #263
https://claude.ai/code/session_01FHLLfYeh9P9FP7Y47wu9We
Generated by Claude Code