Skip to content

Commit

Permalink
[fuzz] test new orphanage methods
Browse files Browse the repository at this point in the history
  • Loading branch information
glozow committed Sep 13, 2023
1 parent c9354f1 commit 2a8158e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/test/fuzz/txorphan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,14 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage)
// AddTx should return false if tx is too big or already have it
// tx weight is unknown, we only check when tx is already in orphanage
{
auto bytes_before = orphanage.BytesFromPeer(peer_id);
bool add_tx = orphanage.AddTx(tx, peer_id, {});
// have_tx == true -> add_tx == false
Assert(!have_tx || !add_tx);
if (!have_tx && add_tx) {
Assert(orphanage.BytesFromPeer(peer_id) == bytes_before + tx->GetTotalSize());
Assert(orphanage.TotalOrphanBytes() == bytes_before + orphanage.TotalOrphanBytes());
}
}
have_tx = orphanage.HaveTx(GenTxid::Txid(tx->GetHash())) || orphanage.HaveTx(GenTxid::Wtxid(tx->GetHash()));
{
Expand All @@ -127,6 +132,7 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage)
},
[&] {
orphanage.EraseForPeer(peer_id);
Assert(orphanage.BytesFromPeer(peer_id) == 0);
},
[&] {
// test mocktime and expiry
Expand Down

0 comments on commit 2a8158e

Please sign in to comment.