test: Check that redundant verack message is ignored
What changed, and why it matters
This commit only adds a new test to Bitcoin Core's test suite. It verifies that if a peer sends an extra, unnecessary 'verack' message after the handshake is complete, the node ignores it and logs a message. There is no code change to the actual Bitcoin node software, only a new test case.
No action required. This is a test-only change and does not alter Bitcoin Core's runtime behavior or introduce a security issue.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds a functional test in test/functional/p2p_handshake.py that connects a P2PInterface peer, sends a redundant msg_verack(), and asserts the node logs ‘ignoring redundant verack message’. This tests existing node behavior; no production networking code is modified.
Changed components
test/functional/p2p_handshake.pyInspect captured patch +8 / −0
diff --git a/test/functional/p2p_handshake.py b/test/functional/p2p_handshake.py
index 96db741f..774ab429 100755
--- a/test/functional/p2p_handshake.py
+++ b/test/functional/p2p_handshake.py
@@ -16,6 +16,7 @@ from test_framework.messages import (
NODE_NONE,
NODE_P2P_V2,
NODE_WITNESS,
+ msg_verack,
)
from test_framework.p2p import P2PInterface
from test_framework.util import p2p_port
@@ -72,6 +73,13 @@ class P2PHandshakeTest(BitcoinTestFramework):
def run_test(self):
node = self.nodes[0]
+
+ self.log.info("Check that redundant verack message is ignored")
+ verack_conn = node.add_p2p_connection(P2PInterface())
+ with node.assert_debug_log(["ignoring redundant verack message"]):
+ verack_conn.send_and_ping(msg_verack())
+ node.disconnect_p2ps()
+
self.log.info("Check that lacking desired service flags leads to disconnect (non-pruned peers)")
self.test_desirable_service_flags(node, [NODE_NONE, NODE_NETWORK, NODE_WITNESS],
DESIRABLE_SERVICE_FLAGS_FULL, expect_disconnect=True)
Why this scored 12/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.