lssa/test_fixtures
jonesmarvin8 7bc4c460a2
fix!(state_machine): reject public transactions that silently drop a d… (#625)
* fix(state_machine): reject public transactions that silently drop a declared account

ValidatedStateDiff::from_public_transaction never checked that the accounts
touched in a program's output matched the caller-declared message.account_ids
— it just folded whatever pairs the program returned into the diff. A program
(or a macro-generated dispatcher wrapping one) that silently drops an account
from both sides of its own output together stays internally consistent
(pre_states.len() == post_states.len()) and passes validate_execution's
existing checks, so the dropped account simply vanishes with no error.

Add a check after the chained-call loop: every account_id in
message.account_ids must appear in the final state_diff, or the transaction is
rejected with the new DeclaredAccountMissingFromOutput error.

Add a dropped_account test-guest program that reproduces the exact shape of
the bug (two pre_states in, one consistent (pre, post) pair out) and a
regression test proving the transaction is now rejected. Verified the test
fails with Ok(()) when the check is removed, and passes once it's restored.

* style: tighten comments and apply nightly rustfmt

Condense the explanatory comments on the new account-accounting check and the
dropped_account test guest, and fix imprecise wording (the account is dropped
from both pre_state and post_states together, not just pre_state). Also
applies cargo +nightly fmt's wrapping of the new error message.

* chore: regenerate test fixture after rebase onto dev
2026-07-23 12:09:16 -04:00
..

test_fixtures

Shared test/bench fixtures that spin up bedrock + sequencer + indexer + wallet end-to-end.

Library

TestContext drives the full stack for integration tests and benches:

let ctx = TestContext::new().await?;              // fast: restores the prebuilt db dump
let ctx = TestContext::builder()
    .from_scratch()                                // apply genesis + claim supply live
    .with_genesis(actions)                         // custom genesis (implies from_scratch)
    .disable_indexer()
    .build().await?;

TestContext::new() restores fixtures/prebuilt_sequencer_db.dump (genesis + initial-supply claim blocks) instead of re-applying genesis and re-proving the private claims, then syncs the wallet. Use from_scratch() to build genesis live.

Binary

regenerate_test_fixture regenerates that dump (needs Docker):

just regenerate-test-fixture   # RISC0_DEV_MODE=1 cargo run -p test_fixtures --bin regenerate_test_fixture

Rerun and commit fixtures/prebuilt_sequencer_db.dump after changing genesis, the default accounts, block format, or initial state.