Repository navigation
test(efficiency): make the ledger-agreement test hermetic - #40
Merged
Merged
Conversation
… not the developer's own the_recorded_ledger_agrees_with_itself read ~/Library/Application Support/io.speedata.lumen and failed on a clean main (565 of 2,547 eligible reads bypassed the optimizer, through the fail-open guards). Its invariants now run on a ledger built in a temp dir with the production schema, with one test per assertion proving it can fail. Auditing the real ledger is opt-in via LUMEN_TEST_REAL_LEDGER=1.
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
the_recorded_ledger_agrees_with_itselfnow asserts its invariants on a fixture ledger built in a temp dir with the production schema (connect_db), instead of reading the developer's ownlumen.db. The body moved unchanged intoassert_ledger_agrees(conn); the two swallowed-errorunwrap_orqueries nowexpect, and an empty ledger now fails rather than passing silently.Why
On a clean
mainit failed on the maintainer's machine (565 of 2,547 eligible reads bypassed the optimizer, via the fail-open guards, per #30). That is a fact about one person's usage, not the code, and an always-red local test teaches people to ignore red.Coverage
should_panictest per assertion (saving > file, clamp in signed era, negative in clamped era, losses swamping the headline, leak share, empty ledger) proves each guard can fail.LUMEN_TEST_REAL_LEDGER=1(prints a skip message otherwise). With it set on the maintainer's machine it still reproduces the original failure.Not touched:
the_recorded_savings_are_priced_and_their_provenance_is_knownalso reads the real ledger; it passes here, left out of scope.Local CI (all green)
cargo fmt --all --checkcargo clippy --workspace --all-targets --exclude Lumen -- -D warningscargo test -p lumen-core -p lumen-cli -p lumen-daemon -p lumen-mcp -p lumen-stats --all-targets --no-fail-fastCloses #35