Merge bitcoin/bitcoin#36152: test: cover the feature-negotiation version boundary in p2p_leak
What changed, and why it matters
This commit only adds new test cases to Bitcoin Core's functional test suite. It does not change any production networking code. The tests verify that peers advertising protocol version exactly 70016 receive expected feature-negotiation messages (WTXIDRELAY, SENDADDRV2, and SENDTXRCNCL), pinning down the lower boundary of an existing `>= 70016` check. There is no security vulnerability being fixed here.
No action required. This is a test-coverage improvement. Reviewers may optionally run the updated functional tests to confirm they pass.
Security signals we found
No production code modified
Only functional test files changed
Adds regression coverage for existing version-boundary behavior
No bug fix, hardening, or vulnerability remediation present
Evidence from the diff
The merge commit adds two test-only changes: (1) in p2p_leak.py, a peer advertising nVersion 70016 is added and asserted to receive WTXIDRELAY and SENDADDRV2 but not feature messages (which start at >= 70017); (2) in p2p_sendtxrcncl.py, a test asserts SENDTXRCNCL is sent at version 70016. These complement existing 70015 tests that verify the messages are withheld below the boundary. The production logic in net_processing.cpp is unchanged; the commit only increases regression-test coverage for an off-by-one boundary.
Changed components
test/functional/p2p_leak.pytest/functional/p2p_sendtxrcncl.pyInspect captured patch +26 / −1
### test/functional/p2p_leak.py
@@ -125,14 +125,21 @@ def run_test(self):
pre_wtxidrelay_peer = self.nodes[0].add_p2p_connection(NoVerackIdlePeer(), send_version=False, wait_for_verack=False)
pre_wtxidrelay_peer.send_without_ping(self.create_old_version(70015))
+ # Peer at exactly nVersion == 70016, the lowest version that supports the
+ # feature negotiation messages, so it must receive WTXIDRELAY and SENDADDRV2.
+ wtxidrelay_peer = self.nodes[0].add_p2p_connection(NoVerackIdlePeer(), send_version=False, wait_for_verack=False)
+ wtxidrelay_peer.send_without_ping(self.create_old_version(70016))
+
# Wait until the peer gets the verack in response to the version. Though, don't wait for the node to receive the
# verack, since the peer never sent one
no_verack_idle_peer.wait_for_verack()
pre_wtxidrelay_peer.wait_for_verack()
+ wtxidrelay_peer.wait_for_verack()
no_version_idle_peer.wait_until(lambda: no_version_idle_peer.ever_connected)
no_verack_idle_peer.wait_until(lambda: no_verack_idle_peer.version_received)
pre_wtxidrelay_peer.wait_until(lambda: pre_wtxidrelay_peer.version_received)
+ wtxidrelay_peer.wait_until(lambda: wtxidrelay_peer.version_received)
# Mine a block and make sure that it's not sent to the connected peers
self.generate(self.nodes[0], nblocks=1)
@@ -159,10 +166,16 @@ def run_test(self):
assert not pre_wtxidrelay_peer.got_sendaddrv2
assert not pre_wtxidrelay_peer.got_feature
+ assert not wtxidrelay_peer.unexpected_msg
+ assert wtxidrelay_peer.got_wtxidrelay
+ assert wtxidrelay_peer.got_sendaddrv2
+ assert not wtxidrelay_peer.got_feature # feature messages start at nVersion >= 70017
+
# Expect peers to be disconnected due to timeout
assert not no_version_idle_peer.is_connected
assert not no_verack_idle_peer.is_connected
assert not pre_wtxidrelay_peer.is_connected
+ assert not wtxidrelay_peer.is_connected
self.log.info('Check that the version message does not leak the local address of the node')
p2p_version_store = self.nodes[0].add_p2p_connection(P2PVersionStore())
@@ -177,7 +190,7 @@ def run_test(self):
self.log.info('Check that old peers are disconnected')
p2p_old_peer = self.nodes[0].add_p2p_connection(P2PInterface(), send_version=False, wait_for_verack=False)
- with self.nodes[0].assert_debug_log(["using obsolete version 31799, disconnecting peer=5"]):
+ with self.nodes[0].assert_debug_log(["using obsolete version 31799, disconnecting peer=6"]):
p2p_old_peer.send_without_ping(self.create_old_version(31799))
p2p_old_peer.wait_for_disconnect()
### test/functional/p2p_sendtxrcncl.py
@@ -100,6 +100,18 @@ def run_test(self):
assert not peer.sendtxrcncl_msg_received
self.nodes[0].disconnect_p2ps()
+ self.log.info('SENDTXRCNCL on lowest WTXID version should be sent')
+ peer = self.nodes[0].add_p2p_connection(SendTxrcnclReceiver(), send_version=False, wait_for_verack=False)
+ wtxid_version_msg = msg_version()
+ wtxid_version_msg.nVersion = 70016
+ wtxid_version_msg.strSubVer = P2P_SUBVERSION
+ wtxid_version_msg.nServices = P2P_SERVICES
+ wtxid_version_msg.relay = 1
+ peer.send_without_ping(wtxid_version_msg)
+ peer.wait_for_verack()
+ assert peer.sendtxrcncl_msg_received
+ self.nodes[0].disconnect_p2ps()
+
self.log.info('SENDTXRCNCL for fRelay=false should not be sent')
peer = self.nodes[0].add_p2p_connection(SendTxrcnclReceiver(), send_version=False, wait_for_verack=False)
no_txrelay_version_msg = msg_version()Why this scored 15/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.