Motivated by the discussion in #28970 (https://github.com/bitcoin/bitcoin/pull/28970#discussion_r1553911167), this PR adds test coverage for the logic around the m_recent_rejects
filter, in particular that the filter is cleared after a new block comes in:
https://github.com/bitcoin/bitcoin/blob/f0794cbd405636a7f528a60f2873050b865cf7e8/src/net_processing.cpp#L2199-L2206
As expected, the second part of the test fails if the following patch is applied:
0diff --git a/src/net_processing.cpp b/src/net_processing.cpp
1index 6996af38cb..5cb1090e70 100644
2--- a/src/net_processing.cpp
3+++ b/src/net_processing.cpp
4@@ -2202,7 +2202,7 @@ bool PeerManagerImpl::AlreadyHaveTx(const GenTxid& gtxid)
5 // or a double-spend. Reset the rejects filter and give those
6 // txs a second chance.
7 hashRecentRejectsChainTip = m_chainman.ActiveChain().Tip()->GetBlockHash();
8- m_recent_rejects.reset();
9+ //m_recent_rejects.reset();
10 }
11
12 const uint256& hash = gtxid.GetHash();
I’m still not sure in which file this test fits best, and if there is already test coverage for the first part of the test somewhere. Happy for any suggestions.