aboutsummaryrefslogtreecommitdiff
path: root/src/test/fuzz/partially_downloaded_block.cpp
diff options
context:
space:
mode:
authordergoegge <n.goeggi@gmail.com>2023-01-19 18:06:24 +0100
committerdergoegge <n.goeggi@gmail.com>2023-01-23 17:29:41 +0100
commita1c36275b5a27ae685f49ff02dabff0adbf51aa1 (patch)
tree7232a22bcf61c98420590f7195afa414426eda39 /src/test/fuzz/partially_downloaded_block.cpp
parenta8ac61ab5e1805df61f4dc94ded44a874725484c (diff)
[fuzz] Assert that omitting missing transactions always fails block reconstruction
Diffstat (limited to 'src/test/fuzz/partially_downloaded_block.cpp')
-rw-r--r--src/test/fuzz/partially_downloaded_block.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/test/fuzz/partially_downloaded_block.cpp b/src/test/fuzz/partially_downloaded_block.cpp
index fa9c18e52b..f8ba4f08d9 100644
--- a/src/test/fuzz/partially_downloaded_block.cpp
+++ b/src/test/fuzz/partially_downloaded_block.cpp
@@ -82,6 +82,9 @@ FUZZ_TARGET_INIT(partially_downloaded_block, initialize_pdb)
auto init_status{pdb.InitData(cmpctblock, extra_txn)};
std::vector<CTransactionRef> missing;
+ // Whether we skipped a transaction that should be included in `missing`.
+ // FillBlock should never return READ_STATUS_OK if that is the case.
+ bool skipped_missing{false};
for (size_t i = 0; i < cmpctblock.BlockTxCount(); i++) {
// If init_status == READ_STATUS_OK then a available transaction in the
// compact block (i.e. IsTxAvailable(i) == true) implies that we marked
@@ -97,6 +100,8 @@ FUZZ_TARGET_INIT(partially_downloaded_block, initialize_pdb)
if (!pdb.IsTxAvailable(i) && !skip) {
missing.push_back(block->vtx[i]);
}
+
+ skipped_missing |= (!pdb.IsTxAvailable(i) && skip);
}
// Mock CheckBlock
@@ -123,6 +128,7 @@ FUZZ_TARGET_INIT(partially_downloaded_block, initialize_pdb)
auto fill_status{pdb.FillBlock(reconstructed_block, missing)};
switch (fill_status) {
case READ_STATUS_OK:
+ assert(!skipped_missing);
assert(!fail_check_block);
assert(block->GetHash() == reconstructed_block.GetHash());
break;