fuzz: Fix assertion in txorphan

EraseTx calls LimitOrphans, which may evict announcements from a peer
that didn't announce the erased transaction, causing that peer's usage
to decrease. Relax the assertion in the EraseTx branch that claimed
usage of a non-announcer peer is unchanged. Also, add assertions for
the other cases.
This commit is contained in:
marcofleon
2026-08-11 17:05:34 +01:00
parent dec68f997e
commit 01dde6b205

View File

@@ -173,11 +173,13 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage)
{
auto bytes_from_peer_before{orphanage->UsageByPeer(peer_id)};
Assert(have_tx == orphanage->EraseTx(tx->GetWitnessHash()));
// After EraseTx, the orphanage may trim itself, so all peers' usage may have gone up or down.
if (have_tx) {
if (!have_tx_and_peer) {
Assert(orphanage->UsageByPeer(peer_id) == bytes_from_peer_before);
}
// After EraseTx, the orphanage may trim itself, so any peer's usage may decrease.
if (!have_tx) {
Assert(orphanage->UsageByPeer(peer_id) == bytes_from_peer_before);
} else if (have_tx_and_peer) {
Assert(orphanage->UsageByPeer(peer_id) <= bytes_from_peer_before - tx_weight);
} else {
Assert(orphanage->UsageByPeer(peer_id) <= bytes_from_peer_before);
}
}
have_tx = orphanage->HaveTx(tx->GetWitnessHash());