mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
[fuzz] Assert that omitting missing transactions always fails block reconstruction
This commit is contained in:
parent
a8ac61ab5e
commit
a1c36275b5
1 changed files with 6 additions and 0 deletions
|
@ -82,6 +82,9 @@ FUZZ_TARGET_INIT(partially_downloaded_block, initialize_pdb)
|
||||||
auto init_status{pdb.InitData(cmpctblock, extra_txn)};
|
auto init_status{pdb.InitData(cmpctblock, extra_txn)};
|
||||||
|
|
||||||
std::vector<CTransactionRef> missing;
|
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++) {
|
for (size_t i = 0; i < cmpctblock.BlockTxCount(); i++) {
|
||||||
// If init_status == READ_STATUS_OK then a available transaction in the
|
// If init_status == READ_STATUS_OK then a available transaction in the
|
||||||
// compact block (i.e. IsTxAvailable(i) == true) implies that we marked
|
// 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) {
|
if (!pdb.IsTxAvailable(i) && !skip) {
|
||||||
missing.push_back(block->vtx[i]);
|
missing.push_back(block->vtx[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
skipped_missing |= (!pdb.IsTxAvailable(i) && skip);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mock CheckBlock
|
// Mock CheckBlock
|
||||||
|
@ -123,6 +128,7 @@ FUZZ_TARGET_INIT(partially_downloaded_block, initialize_pdb)
|
||||||
auto fill_status{pdb.FillBlock(reconstructed_block, missing)};
|
auto fill_status{pdb.FillBlock(reconstructed_block, missing)};
|
||||||
switch (fill_status) {
|
switch (fill_status) {
|
||||||
case READ_STATUS_OK:
|
case READ_STATUS_OK:
|
||||||
|
assert(!skipped_missing);
|
||||||
assert(!fail_check_block);
|
assert(!fail_check_block);
|
||||||
assert(block->GetHash() == reconstructed_block.GetHash());
|
assert(block->GetHash() == reconstructed_block.GetHash());
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue