Repository navigation
test: run the testkit scenarios at T0 through the live receive path (SNB-517) - #22
Merged
Merged
Conversation
…SNB-517) The testkit exports each scenario's T0 run (signed transactions with prevouts, wallet keys, the expected found-set) as a pinned JSON fixture. testkit_t0 replays those chains in-process through exactly the per-block steps scan_block_range takes: an in-process oracle computes the short data (tweak via compute_tweak_data, cross-checked against the Go index; output and spent 8-byte prefixes), scan_short_block_data decides the fetch, and apply_matched_block feeds apply_block_relevant. Each wallet's found-set is judged against the answer key: amount, label, spent, nothing extra. apply_matched_block is extracted from scan_block_range (same body as in #17 and #19) so the test drives the function production calls. All nine T0 scenarios pass except spent status: every spend the scenarios make goes undetected, because owned_outputs is never written. Those rows are pinned in KNOWN_SPEND_GAP and must keep failing exactly so; #19 fixes them. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Brings in the fix stack (#17, #20, #19, #21) so the T0 harness runs against the receive path that records owned outputs. scanning.rs: both sides extracted apply_matched_block; kept #21's sync_owned_outputs() call after it in the scan loop and its doc line, and kept both test modules (owned_outputs_tests from #21, testkit_t0 from this branch). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The T0 harness replayed each block through a hand copy of the scan loop's per-block steps, and that copy had already fallen behind: the loop on the fix stack records owned outputs (sync_owned_outputs) after apply_matched_block and the copy did not, so nine spends were carried as KNOWN_SPEND_GAP. process_block now drives Scanner::scan_block_stream, the per-block loop scan_block_range and watch_chain run, with the oracle's message streamed in-process and the full block served in place of the P2P fetch (the stream-safety test hooks from #20/#21). There is no copy left to drift: a step added to the loop is exercised here. State files the loop now saves are removed when a scenario ends. KNOWN_SPEND_GAP and its assertions are gone; all nine scenarios must pass with their spends. Dropping the sync_owned_outputs() call from the loop turns exactly those nine spends red again (k-gap, labelled-multi, spent-outputs, dust-boundary, rescan). Fixture provenance now names testkit 68f9f1c, the merge of testkit PR #25 into master; the fixtures are byte-identical to the export at b1f962e. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in the blindbit-cli error display fix from #20. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The deslop moved TempState and run from stream_safety_tests into test_support; TestStream and serve stay where they were. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rently With the T0 testkit scenarios scanning on other test threads, the "balance after scan" call site is often first hit on a thread with no subscriber. While only one scoped dispatcher exists, tracing caches that call site's interest from the current thread alone, so it was cached as "never" and balance_after_scan_counts_earlier_outputs_as_confirmed saw no events (12 of 12 runs). A second live dispatcher makes tracing combine every dispatcher's interest; 0 of 12 runs fail with it. Co-Authored-By: Claude Opus 5.5 <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.
Update 2026-10-30: merged with
mastermasternow carries the Friglet Deslop cleanup (#67–#76), #18, #80 and #81. The merge had no textual conflicts. Two follow-up commits make it build and pass:4cdc1c0: the deslop movedTempStateandrunfromstream_safety_testsintotest_support, sotestkit_t0imports them from there.ca21273: with the nine T0 scenarios scanning on other test threads,balance_after_scan_counts_earlier_outputs_as_confirmedsaw no "balance after scan" events in 12 of 12 runs. tracing caches a call site's interest when it is first hit. While exactly one scoped dispatcher exists, it consults only the current thread's dispatcher, so a call site first hit on a thread with no subscriber is cached as "never". The test now keeps a second dispatcher alive, so the interest stays "sometimes": 0 of 12 runs fail.Verified locally on
ca21273(debug, private target dir):cargo test --workspace: 264 passed, 0 ignored (master's 254 plus the 10 T0 tests).cargo test -p blindbit-lib --features serde testkit_t0: 10 passed.cargo check --workspace --all-targets --all-features: 0 warnings.cargo fmt --all --checkand clippy-D warningson friglet/friglet-ipc/friglet-tray: clean.The original description follows.
What
This is the Rust half of SNB-517 (T0, the in-process library tier).
blindbit-lib/src/scanner/testkit_t0.rsreplays the blindbit-testkit scenarios in-process through blindbit-lib's live receive path. Every block goes throughScanner::scan_block_stream, which is the per-block loop thatscan_block_rangeandwatch_chainrun. Only the gRPC stream and the P2P block fetch are replaced: the stream is an in-process stream, and full blocks are served from memory using #20/#21's stream-safety test hooks. The loop's steps are not copied anywhere in the test, so they cannot drift:BlockScanDataShortResponsefrom the transactions and their prevouts: tweakinput_hash·Aviabdk_sp::receive::compute_tweak_data, the 8-byte prefixes of taproot outputs, and the 8-byte prefixes of spent taproot outputs.scan_short_block_data.scan_transaction_short/match_short_pubkeyplus the spent-prefix check decide whether to fetch the block.apply_matched_block(→apply_block_relevant). The loop then records owned outputs and their spends (sync_owned_outputs), checks the chain, saves state and keeps the block as a checkpoint.Each wallet's found-set is read from the indexer the way the balance reads it:
by_shared_secret, the graph txout,by_label, and spends in the graph. It is judged against the testkit's answer key:must_findoutput is present with the constructed amount, label and spent status;A scanner
restartrescans from block 1 and must reproduce the live found-set. An oraclerestartrecomputes the served data and must reproduce it.No second sender. The transactions come from the testkit's vector-gated sender through
testkit export-fixture(blindbit-testkit PR #25). They are committed underblindbit-lib/tests/data/testkit-t0/, pinned by SHA-256 in the test, and must also match the exportedSHA256SUMS. The regeneration command is in the module docs. The fixture's Go-computed tweak is used only as a cross-check: the Rust tweak must equal it for every transaction, and on these nine scenarios it does,input-typesincluded (NUMS script-path and uncompressed P2PKH exclusions).Scenarios: plain-payment, labelled-multi, k-gap, label-parity, k-counter, spent-outputs, input-types, rescan, dust-boundary. These are the nine the testkit runs at T0, all under
full-basic.Production change:
apply_matched_blockis extracted fromscan_block_rangewith the same body as in #17 and #19, so the test calls the function that production calls.Why T0-rust is not redundant with T1/T2
The testkit already runs a real
blindbit-cliat T1 and friglet at T2, but only against therepos.lockpin, in the testkit's CI, after the fact. This test runs in blindbit-rs's own CI on every PR, in about 0.1 s, with no Go, binary or Docker. #17's vectors cover the BIP-352 math. They do not cover multi-block wallet state: spends in later blocks, rescans, labels plus change, or k-gaps across a whole scenario.Spends (update 2026-10-01)
This branch now merges the fix stack: #21, which carries #19, #17 and #20. All 9 scenarios pass with their spends, and
KNOWN_SPEND_GAPis gone.On
integrationthe test caught that spends were never detected:owned_outputswas never written, which is the bug #19 fixes. When this was first written, the harness copied the loop's per-block steps by hand. That copy had already fallen behind #19, because the loop now callssync_owned_outputs()afterapply_matched_block. That is why the harness now drives the loop itself.Negative check: removing the
sync_owned_outputs()call from the production loop turns exactly the nine former spend rows red again, in k-gap, labelled-multi, spent-outputs, dust-boundary and rescan.Fixture provenance now names testkit
68f9f1c, the merge of testkit #25 into master. The fixtures are byte-identical to that export.Red (mutations applied temporarily, then reverted)
scan_transaction_shortMISSING bob-l3-a: wallet bob did not report 9871a3c8…:0 (40700 sat),MISSING change-a(m = 0)apply_matched_blockpasses no tweaksMISSING big-k1: wallet carol did not report 077e72c1…:1 (40000 sat)scan_short_block_dataMISMATCHED spent-k0 (carol, 19c7dbd6…:0): spent expected true, reported falseKNOWN_SPEND_GAPonintegrationspentmismatches, each namedsync_owned_outputs()from the scan loopspentmismatches, each namedVerification
On the fix stack (head after merging #21
824613f):cargo test --workspace: all ok, blindbit-lib 60 tests.cargo clippy -p blindbit-lib --all-targets: no warnings intestkit_t0.rs.cargo test --workspacepasses on that trial merge.Original verification, against
integration:cargo test -p blindbit-lib: 22 passed (10 new).cargo test --workspace: all ok.cargo clippy --no-deps -p friglet -p friglet-ipc -p friglet-tray --all-targets -- -D warnings(the CI lint step): clean.cargo clippy -p blindbit-lib --all-targets: no warnings intestkit_t0.rs.testkit_t0.rsis rustfmt-clean (file-scoped).scanning.rswas not reformatted.