Skip to content

Commit c157438

Browse files
committed
qa: test that we do disconnect upon a second invalid compact block being announced
This was in fact untested until now. This can be checked with the following diff. ```diff diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 0c4a89c..f8b9adf910a 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1822,7 +1822,7 @@ void PeerManagerImpl::MaybePunishNodeForBlock(NodeId nodeid, const BlockValidati } case BlockValidationResult::BLOCK_INVALID_HEADER: case BlockValidationResult::BLOCK_INVALID_PREV: - if (peer) Misbehaving(*peer, message); + if (!via_compact_block && peer) Misbehaving(*peer, message); return; // Conflicting (but not necessarily invalid) data or different policy: case BlockValidationResult::BLOCK_MISSING_PREV: ```
1 parent fb2dcbb commit c157438

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/functional/p2p_compactblocks.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,13 @@ def test_invalid_tx_in_compactblock(self, test_node):
751751
assert_not_equal(node.getbestblockhash(), block.hash_hex)
752752
test_node.sync_with_ping()
753753

754+
# Now, announcing a second block building on top of the invalid one will get us disconnected.
755+
block.hashPrevBlock = block.hash_int
756+
block.solve()
757+
comp_block.initialize_from_block(block, prefill_list=list(range(len(block.vtx))), use_witness=True)
758+
msg = msg_cmpctblock(comp_block.to_p2p())
759+
test_node.send_await_disconnect(msg)
760+
754761
# Helper for enabling cb announcements
755762
# Send the sendcmpct request and sync headers
756763
def request_cb_announcements(self, peer):
@@ -967,6 +974,9 @@ def run_test(self):
967974
self.log.info("Testing handling of invalid compact blocks...")
968975
self.test_invalid_tx_in_compactblock(self.segwit_node)
969976

977+
# The previous test will lead to a disconnection. Reconnect before continuing.
978+
self.segwit_node = self.nodes[0].add_p2p_connection(TestP2PConn())
979+
970980
self.log.info("Testing invalid index in cmpctblock message...")
971981
self.test_invalid_cmpctblock_message()
972982

0 commit comments

Comments
 (0)