@@ -47,6 +47,8 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage)
47
47
48
48
CTransactionRef ptx_potential_parent = nullptr ;
49
49
50
+ std::vector<CTransactionRef> tx_history;
51
+
50
52
LIMITED_WHILE (outpoints.size () < 200'000 && fuzzed_data_provider.ConsumeBool (), 10 * DEFAULT_MAX_ORPHAN_TRANSACTIONS)
51
53
{
52
54
// construct transaction
@@ -75,6 +77,8 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage)
75
77
return new_tx;
76
78
}();
77
79
80
+ tx_history.push_back (tx);
81
+
78
82
const auto wtxid{tx->GetWitnessHash ()};
79
83
80
84
// 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)
195
199
Assert (!orphanage.HaveTxFromPeer (tx->GetWitnessHash (), peer_id));
196
200
Assert (orphanage.UsageByPeer (peer_id) == 0 );
197
201
},
202
+ [&] {
203
+ // Make a block out of txs and then EraseForBlock
204
+ CBlock block;
205
+ int num_txs = fuzzed_data_provider.ConsumeIntegralInRange <unsigned int >(0 , 1000 );
206
+ for (int i{0 }; i < num_txs; ++i) {
207
+ auto & tx_to_remove = PickValue (fuzzed_data_provider, tx_history);
208
+ block.vtx .push_back (tx_to_remove);
209
+ }
210
+ orphanage.EraseForBlock (block);
211
+ for (const auto & tx_removed : block.vtx ) {
212
+ Assert (!orphanage.HaveTx (tx_removed->GetWitnessHash ()));
213
+ Assert (!orphanage.HaveTxFromPeer (tx_removed->GetWitnessHash (), peer_id));
214
+ }
215
+ },
198
216
[&] {
199
217
// test mocktime and expiry
200
218
SetMockTime (ConsumeTime (fuzzed_data_provider));
0 commit comments