@@ -47,6 +47,8 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage)
4747
4848 CTransactionRef ptx_potential_parent = nullptr ;
4949
50+ std::vector<CTransactionRef> tx_history;
51+
5052 LIMITED_WHILE (outpoints.size () < 200'000 && fuzzed_data_provider.ConsumeBool (), 10 * DEFAULT_MAX_ORPHAN_TRANSACTIONS)
5153 {
5254 // construct transaction
@@ -75,6 +77,8 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage)
7577 return new_tx;
7678 }();
7779
80+ tx_history.push_back (tx);
81+
7882 const auto wtxid{tx->GetWitnessHash ()};
7983
8084 // 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)
195199 Assert (!orphanage.HaveTxFromPeer (tx->GetWitnessHash (), peer_id));
196200 Assert (orphanage.UsageByPeer (peer_id) == 0 );
197201 },
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+ },
198216 [&] {
199217 // test mocktime and expiry
200218 SetMockTime (ConsumeTime (fuzzed_data_provider));
0 commit comments