agreed that this test is a bit of a mess, currently it leaves stalled in-flight requests. Would be willing to look at a refactored test again
diff --git a/test/functional/p2p_compactblocks.py b/test/functional/p2p_compactblocks.py
--- a/test/functional/p2p_compactblocks.py
+++ b/test/functional/p2p_compactblocks.py
@@ -316,6 +316,12 @@ class CompactBlocksTest(BitcoinTestFramework):
bad_peer = self.nodes[0].add_p2p_connection(TestP2PConn())
bad_peer.send_await_disconnect(msg_cmpctblock(invalid_cmpct))
assert_equal(int(self.nodes[0].getbestblockhash(), 16), block2.hashPrevBlock)
+ # Deliver the block so the stalled in-flight requests don't leak into later tests.
+ msg = msg_blocktxn()
+ msg.block_transactions = BlockTransactions(block2.hash_int, [block2.vtx[0]])
+ stall1.send_and_ping(msg)
+ assert_equal(self.nodes[0].getbestblockhash(), block2.hash_hex)
+
# Compare the generated shortids to what we expect based on BIP 152, given
# bitcoind's choice of nonce.
def test_compactblock_construction(self, test_node):