This adds a test that passes on master and fails with the diff from #34618 applied, as davidgumberg asked in #34722. It covers both things that diff removes for a compact block more than two blocks ahead of the tip.
If the node already requested the block from this peer, it sends another getdata for the full block. Without that getdata, the block stays in flight from this peer and nothing requests it again until the block download timeout disconnects the peer. This check is the one shuv-amp proposed in #34722.
Otherwise, from a high-bandwidth peer, the node handles the header as a headers message (fRevertToHeaderProcessing). Most of that work is done anyway. As 151henry151 pointed out in #34618, one part is not: protecting an outbound peer from eviction (m_chain_sync.m_protect). The test checks for the "Protecting outbound peer" debug log line.
Each check fails when only its branch is disabled: fRevertToHeaderProcessing = false fails the protection check, and if (false) in place of if (requested_block_from_this_peer) makes the getdata check time out. shuv-amp first tested the two branches separately in #34618.
Fixes #34618.
Written with LLM, a computer and the Internet; the mistakes, as usual, are all mine.