diff --git a/test/functional/p2p_compactblocks.py b/test/functional/p2p_compactblocks.py index 724a5874373..80041e2b59a 100755 --- a/test/functional/p2p_compactblocks.py +++ b/test/functional/p2p_compactblocks.py @@ -751,6 +751,13 @@ class CompactBlocksTest(BitcoinTestFramework): assert_not_equal(node.getbestblockhash(), block.hash_hex) test_node.sync_with_ping() + # Now, announcing a second block building on top of the invalid one will get us disconnected. + block.hashPrevBlock = block.hash_int + block.solve() + comp_block.initialize_from_block(block, prefill_list=list(range(len(block.vtx))), use_witness=True) + msg = msg_cmpctblock(comp_block.to_p2p()) + test_node.send_await_disconnect(msg) + # Helper for enabling cb announcements # Send the sendcmpct request and sync headers def request_cb_announcements(self, peer): @@ -967,6 +974,9 @@ class CompactBlocksTest(BitcoinTestFramework): self.log.info("Testing handling of invalid compact blocks...") self.test_invalid_tx_in_compactblock(self.segwit_node) + # The previous test will lead to a disconnection. Reconnect before continuing. + self.segwit_node = self.nodes[0].add_p2p_connection(TestP2PConn()) + self.log.info("Testing invalid index in cmpctblock message...") self.test_invalid_cmpctblock_message()