mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
Merge bitcoin/bitcoin#31918: fuzz: add basic TxOrphanage::EraseForBlock cov
Some checks failed
CI / test each commit (push) Has been cancelled
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Has been cancelled
CI / macOS 14 native, arm64, fuzz (push) Has been cancelled
CI / Win64 native, VS 2022 (push) Has been cancelled
CI / Win64 native fuzz, VS 2022 (push) Has been cancelled
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Has been cancelled
Some checks failed
CI / test each commit (push) Has been cancelled
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Has been cancelled
CI / macOS 14 native, arm64, fuzz (push) Has been cancelled
CI / Win64 native, VS 2022 (push) Has been cancelled
CI / Win64 native fuzz, VS 2022 (push) Has been cancelled
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Has been cancelled
8400b742fa
fuzz: add basic TxOrphanage::EraseForBlock cov (Greg Sanders) Pull request description: Currently uncovered ACKs for top commit: dergoegge: utACK8400b742fa
marcofleon: ACK8400b742fa
Tree-SHA512: 8c032ffa15ccce73ee1e0b2425d9c303acd4ec87c43f05de0cb96f4d831faeb5651175a32a7fc3ed81bf9400ee4416ca826999777326c29d06e3bd67cb06068c
This commit is contained in:
commit
e486597f9a
1 changed files with 18 additions and 0 deletions
|
@ -47,6 +47,8 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage)
|
||||||
|
|
||||||
CTransactionRef ptx_potential_parent = nullptr;
|
CTransactionRef ptx_potential_parent = nullptr;
|
||||||
|
|
||||||
|
std::vector<CTransactionRef> tx_history;
|
||||||
|
|
||||||
LIMITED_WHILE(outpoints.size() < 200'000 && fuzzed_data_provider.ConsumeBool(), 10 * DEFAULT_MAX_ORPHAN_TRANSACTIONS)
|
LIMITED_WHILE(outpoints.size() < 200'000 && fuzzed_data_provider.ConsumeBool(), 10 * DEFAULT_MAX_ORPHAN_TRANSACTIONS)
|
||||||
{
|
{
|
||||||
// construct transaction
|
// construct transaction
|
||||||
|
@ -75,6 +77,8 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage)
|
||||||
return new_tx;
|
return new_tx;
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
tx_history.push_back(tx);
|
||||||
|
|
||||||
const auto wtxid{tx->GetWitnessHash()};
|
const auto wtxid{tx->GetWitnessHash()};
|
||||||
|
|
||||||
// Trigger orphanage functions that are called using parents. ptx_potential_parent is a tx we constructed in a
|
// Trigger orphanage functions that are called using parents. ptx_potential_parent is a tx we constructed in a
|
||||||
|
@ -195,6 +199,20 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage)
|
||||||
Assert(!orphanage.HaveTxFromPeer(tx->GetWitnessHash(), peer_id));
|
Assert(!orphanage.HaveTxFromPeer(tx->GetWitnessHash(), peer_id));
|
||||||
Assert(orphanage.UsageByPeer(peer_id) == 0);
|
Assert(orphanage.UsageByPeer(peer_id) == 0);
|
||||||
},
|
},
|
||||||
|
[&] {
|
||||||
|
// Make a block out of txs and then EraseForBlock
|
||||||
|
CBlock block;
|
||||||
|
int num_txs = fuzzed_data_provider.ConsumeIntegralInRange<unsigned int>(0, 1000);
|
||||||
|
for (int i{0}; i < num_txs; ++i) {
|
||||||
|
auto& tx_to_remove = PickValue(fuzzed_data_provider, tx_history);
|
||||||
|
block.vtx.push_back(tx_to_remove);
|
||||||
|
}
|
||||||
|
orphanage.EraseForBlock(block);
|
||||||
|
for (const auto& tx_removed : block.vtx) {
|
||||||
|
Assert(!orphanage.HaveTx(tx_removed->GetWitnessHash()));
|
||||||
|
Assert(!orphanage.HaveTxFromPeer(tx_removed->GetWitnessHash(), peer_id));
|
||||||
|
}
|
||||||
|
},
|
||||||
[&] {
|
[&] {
|
||||||
// test mocktime and expiry
|
// test mocktime and expiry
|
||||||
SetMockTime(ConsumeTime(fuzzed_data_provider));
|
SetMockTime(ConsumeTime(fuzzed_data_provider));
|
||||||
|
|
Loading…
Add table
Reference in a new issue