test: fix (w)txid confusion in p2p_leak_tx.py
What changed, and why it matters
This commit fixes a mistake in a single Bitcoin Core test file. The test was accidentally asking for a transaction using the wrong identifier type (a regular transaction ID instead of a witness transaction ID). This only affects an internal functional test, not the actual Bitcoin network software that users run.
No security action needed; this is a test-only correctness fix. Reviewers may optionally verify that the functional test now passes.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch corrects a (w)txid type mismatch in test/functional/p2p_leak_tx.py. Previously the test requested transaction data with MSG_TX but supplied a wtxid, which would always trigger a notfound response because the node expects MSG_WTX for wtxids. The fix renames the variable to wtxid and uses MSG_WTX consistently, making the test’s assertions meaningful again.
Changed components
test/functional/p2p_leak_tx.pyInspect captured patch +6 / −7
diff --git a/test/functional/p2p_leak_tx.py b/test/functional/p2p_leak_tx.py
index 29b00397..e09420ba 100755
--- a/test/functional/p2p_leak_tx.py
+++ b/test/functional/p2p_leak_tx.py
@@ -106,24 +106,23 @@ class P2PLeakTxTest(BitcoinTestFramework):
self.log.info("Running test up to {} times.".format(MAX_REPEATS))
for i in range(MAX_REPEATS):
self.log.info('Run repeat {}'.format(i + 1))
- txid = self.miniwallet.send_self_transfer(from_node=self.gen_node)["wtxid"]
+ wtxid = self.miniwallet.send_self_transfer(from_node=self.gen_node)["wtxid"]
want_tx = msg_getdata()
- want_tx.inv.append(CInv(t=MSG_TX, h=int(txid, 16)))
+ want_tx.inv.append(CInv(t=MSG_WTX, h=int(wtxid, 16)))
with p2p_lock:
inbound_peer.last_message.pop('notfound', None)
inbound_peer.send_and_ping(want_tx)
-
if inbound_peer.last_message.get('notfound'):
- self.log.debug('tx {} was not yet announced to us.'.format(txid))
+ self.log.debug('tx {} was not yet announced to us.'.format(wtxid))
self.log.debug("node has responded with a notfound message. End test.")
- assert_equal(inbound_peer.last_message['notfound'].vec[0].hash, int(txid, 16))
+ assert_equal(inbound_peer.last_message['notfound'].vec[0].hash, int(wtxid, 16))
with p2p_lock:
inbound_peer.last_message.pop('notfound')
break
else:
- self.log.debug('tx {} was already announced to us. Try test again.'.format(txid))
- assert int(txid, 16) in [inv.hash for inv in inbound_peer.last_message['inv'].inv]
+ self.log.debug('tx {} was already announced to us. Try test again.'.format(wtxid))
+ assert int(wtxid, 16) in [inv.hash for inv in inbound_peer.last_message['inv'].inv]
if __name__ == '__main__':
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.