From 163aaf285af91b49c2d788463dc1e1654c88ade6 Mon Sep 17 00:00:00 2001 From: glozow Date: Wed, 31 Jul 2024 10:52:01 +0100 Subject: [PATCH] [fuzz] orphanage multiple announcer functions --- src/test/fuzz/txorphan.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/test/fuzz/txorphan.cpp b/src/test/fuzz/txorphan.cpp index 09056225db1..26afff5bff5 100644 --- a/src/test/fuzz/txorphan.cpp +++ b/src/test/fuzz/txorphan.cpp @@ -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