test: Add missing test case for getdata requests from blocks-only peers
What changed, and why it matters
This commit only adds a new test case to Bitcoin Core's test suite. It verifies that a block-relay-only peer cannot request transaction data via getdata messages. There is no change to production code, no bug fix, and no security patch.
No action required. This is a test-only addition with no security relevance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies test/functional/p2p_blocksonly.py to import msg_getdata and add a functional test ensuring that getdata(tx) requests from block-relay-only peers are ignored and do not produce a notfound response. The underlying behavior being tested already exists in the node implementation; this commit merely adds missing test coverage.
Changed components
test/functional/p2p_blocksonly.pyInspect captured patch +11 / −1
diff --git a/test/functional/p2p_blocksonly.py b/test/functional/p2p_blocksonly.py
index 6a251e69..4ffbb80f 100755
--- a/test/functional/p2p_blocksonly.py
+++ b/test/functional/p2p_blocksonly.py
@@ -6,7 +6,7 @@
import time
-from test_framework.messages import msg_tx, msg_inv, CInv, MSG_WTX
+from test_framework.messages import msg_getdata, msg_tx, msg_inv, CInv, MSG_WTX
from test_framework.p2p import P2PInterface, P2PTxInvStore
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal
@@ -93,6 +93,16 @@ class P2PBlocksOnly(BitcoinTestFramework):
assert_equal(self.nodes[0].getpeerinfo()[0]['relaytxes'], False)
self.check_p2p_inv_violation(conn)
+ self.log.info(
+ "Check that getdata(tx) from a block-relay-only connection is ignored"
+ )
+ conn = self.nodes[0].add_outbound_p2p_connection(
+ P2PInterface(), p2p_idx=0, connection_type="block-relay-only"
+ )
+ conn.send_and_ping(msg_getdata([CInv(t=MSG_WTX, h=0x12345)]))
+ assert_equal(self.nodes[0].getpeerinfo()[0]["relaytxes"], False)
+ assert "notfound" not in conn.last_message
+
self.log.info("Check that txs from RPC are not sent to blockrelay connection")
conn = self.nodes[0].add_outbound_p2p_connection(P2PTxInvStore(), p2p_idx=1, connection_type="block-relay-only")
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.