Skip to content

Commit 163aaf2

Browse files
committed
[fuzz] orphanage multiple announcer functions
1 parent 22b023b commit 163aaf2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/test/fuzz/txorphan.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,18 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage)
128128
Assert(!have_tx || !add_tx);
129129
}
130130
},
131+
[&] {
132+
bool have_tx = orphanage.HaveTx(tx->GetWitnessHash());
133+
bool have_tx_and_peer = orphanage.HaveTxFromPeer(tx->GetWitnessHash(), peer_id);
134+
// AddAnnouncer should return false if tx doesn't exist or we already HaveTxFromPeer.
135+
{
136+
bool added_announcer = orphanage.AddAnnouncer(tx->GetWitnessHash(), peer_id);
137+
// have_tx == false -> added_announcer == false
138+
Assert(have_tx || !added_announcer);
139+
// have_tx_and_peer == true -> added_announcer == false
140+
Assert(!have_tx_and_peer || !added_announcer);
141+
}
142+
},
131143
[&] {
132144
bool have_tx = orphanage.HaveTx(tx->GetWitnessHash());
133145
// EraseTx should return 0 if m_orphans doesn't have the tx
@@ -142,6 +154,7 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage)
142154
},
143155
[&] {
144156
orphanage.EraseForPeer(peer_id);
157+
Assert(!orphanage.HaveTxFromPeer(tx->GetWitnessHash(), peer_id));
145158
},
146159
[&] {
147160
// test mocktime and expiry

0 commit comments

Comments
 (0)