test_orphanage_dos_many checks that a normal peer's orphan survives while DoS peers flood the orphanage. I found that the orphanage never fills: the 60 peers send the same 51 orphans as tx, and a tx already held as an orphan is dropped in ReceivedTx without recording its sender. The orphanage peaks at 152 announcements against a limit of 3000, so nothing is evicted.
Here the first peer sends the orphans and the other 59 announce them by inv, which does add them as announcers. The test now asserts that the orphanage holds 3000 announcements, instead of asserting on what it sends. It takes about as long as before.
If LimitOrphans is changed to evict the normal peer's orphan first, the test used to pass and now fails. (test_orphanage_dos_large already catches that change.)
Found while porting these tests to https://github.com/btclib-org/bitcoin-node-tests.
Written with LLM, a computer and the Internet; the mistakes, as usual, are all mine.