test: DB roundtrip tests for storage/blockchain and storage/txpool#3
Open
orrinfrazier wants to merge 1 commit into
Open
test: DB roundtrip tests for storage/blockchain and storage/txpool#3orrinfrazier wants to merge 1 commit into
orrinfrazier wants to merge 1 commit into
Conversation
storage/blockchain had a single test (the compact_history proptest) and storage/txpool had none; the DB read/write ops were untested. Add in-crate #[cfg(test)] roundtrip modules that open a temporary fjall DB and exercise the real ops. The block_infos/tx_infos tapes are positional (tape index == block height), so the real mainnet-height fixtures cannot be round-tripped by height in an empty DB. Two complementary harnesses are used: - blockchain: real fixtures (V1, V2, 0-tx) for height-independent tx/output/block blob fidelity (get_tx pruned+prunable reassembly, output lookups, get_block via a captured BlockInfo), plus a synthetic miner-only genesis chain for the natural height-keyed lifecycle (get_block by height/hash, get_block_complete_entry pruned+non-pruned, chain_height/top_block_height, pop_block restores state). - txpool: add/get roundtrip (V1 + V2, stem flag), key-image double-spend rejection, and remove + re-insert. Adds cuprate-test-utils + tempfile to storage/blockchain dev-dependencies (storage/txpool already had them).
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.
Closes #13
Summary
Adds the first direct roundtrip tests for the storage layer's DB ops.
storage/blockchainhad only thecompact_historyproptest andstorage/txpoolhad none — the read/write logic inops/{block,tx,output}.rsandops/{key_images,tx_read,tx_write}.rswas untested. Implementsissues/S08-1-storage-roundtrip-tests.md.Why
Storage is the chain-integrity layer where a bug means permanent corruption. This was the largest test-coverage gap before a confident public release.
Key design note: positional tapes
The
block_infos/tx_infostapes are positional (tape index == block height). The real mainnet-height fixtures (BLOCK_V1_TX2@202609, etc.) therefore can't be round-tripped by height in an empty DB. Two complementary harnesses are used:get_txreal pruned+prunable reassembly (V1 viav1_prunable_blobs, V2 via pruning stripe), pre-RCT + RCT output lookups, andget_blockvia a capturedBlockInfo.get_blockby height/hash,get_block_complete_entry(pruned + non-pruned),chain_height/top_block_height, andpop_blockrestoring prior state. Needs no consensus machinery (mirrorscuprated's reorg-test block generation).Changes
storage/blockchain/src/ops/tests.rs(new) — 4 tests: fixture block roundtrip (0-tx/V1/V2), V1 tx+output, V2 tx+output, synthetic-chain lifecycle + pop.storage/txpool/src/ops/tests.rs(new) — 3 tests: add/get roundtrip (V1+V2, stem flag), key-image double-spend rejection, remove + re-insert.#[cfg(test)] mod tests;; addedcuprate-test-utils+tempfiletostorage/blockchaindev-deps (txpool already had them).Testing
cargo test -p cuprate-blockchain -p cuprate-txpool— 8 pass (5 blockchain incl. the pre-existing proptest, 3 txpool).cargo clippy -p cuprate-blockchain -p cuprate-txpool --all-targets --all-features -- -D warnings— clean.cargo fmt --check— clean.Acceptance criteria
cargo test -p cuprate-blockchain -p cuprate-txpoolexercises real DB operations