test: fix (w)txid confusion in p2p_leak_tx.py

Before, we'd send a MSG_TX with a wtxid in it, which
would always result in a notfound answer
This commit is contained in:
Martin Zumsande 2025-08-01 17:04:44 -04:00
parent 576dd97cb9
commit 99bc552980
1 changed files with 6 additions and 7 deletions

View File

@ -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__':