[fuzz] orphanage multiple announcer functions

This commit is contained in:
glozow 2024-07-31 10:52:01 +01:00
parent 22b023b09d
commit 163aaf285a

View File

@ -128,6 +128,18 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage)
Assert(!have_tx || !add_tx);
}
},
[&] {
bool have_tx = orphanage.HaveTx(tx->GetWitnessHash());
bool have_tx_and_peer = orphanage.HaveTxFromPeer(tx->GetWitnessHash(), peer_id);
// AddAnnouncer should return false if tx doesn't exist or we already HaveTxFromPeer.
{
bool added_announcer = orphanage.AddAnnouncer(tx->GetWitnessHash(), peer_id);
// have_tx == false -> added_announcer == false
Assert(have_tx || !added_announcer);
// have_tx_and_peer == true -> added_announcer == false
Assert(!have_tx_and_peer || !added_announcer);
}
},
[&] {
bool have_tx = orphanage.HaveTx(tx->GetWitnessHash());
// EraseTx should return 0 if m_orphans doesn't have the tx
@ -142,6 +154,7 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage)
},
[&] {
orphanage.EraseForPeer(peer_id);
Assert(!orphanage.HaveTxFromPeer(tx->GetWitnessHash(), peer_id));
},
[&] {
// test mocktime and expiry