test: cover the hub_ops cache cleanup scope - #101
Open
nklyy wants to merge 1 commit into
Open
Conversation
sync_with_hub empties the whole hub_ops/ directory when an operation reaches a terminal state, but that directory is a wallet-wide flat cache keyed by file_id and shared by every operation. A wallet that already downloaded a pending operation's files loses them, which in a service sharing one wallet directory across flows shows up as a file vanishing from under a concurrent reader mid-signing. The test has a lagging cosigner cache a pending operation's files and then catch up on an older approved one, asserting that the completed operation's files are dropped while the pending one's survive.
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.
Adds a reproducer for #100. No fix here - the test documents the expected invariant so the fix (whichever shape it takes) has something to turn green.
What the test does (sync_with_hub_cleanup_keeps_other_operations_files, src/wallet/test/multisig/mod.rs)
A 2-of-3 multisig with a hub:
Then two assertions:
Why it matters beyond the cache
hub_ops/ is flat and wallet-wide (multisig.rs, get_cached_file_path), so the cleanup at the end of sync_with_hub deletes files belonging to operations it knows nothing about. In a long-running service several flows share one wallet directory: one has already resolved a file path from get_or_download_files while a neighbouring sync_with_hub removes the file underneath it, and reading the PSBT or consignment fails mid-signing. Without the race it still forces a re-download of every other pending operation's files, so a hub outage blocks operations whose files were already local.
The test reproduces the same loss deterministically, without concurrency.
Possible fixes (from #100, both keep the current semantics)
Verification
Compile-checked and lint-clean (cargo check --tests --features electrum, clippy, fmt). The run itself needs the tests/compose.yaml stack (bitcoind regtest, electrs, esplora, rgb-proxy, postgres, the multisig hub), so the failing assertion is expected to show up in CI rather than in this description.