mirror of https://github.com/bitcoin/bitcoin.git
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:
parent
576dd97cb9
commit
99bc552980
|
@ -106,24 +106,23 @@ class P2PLeakTxTest(BitcoinTestFramework):
|
||||||
self.log.info("Running test up to {} times.".format(MAX_REPEATS))
|
self.log.info("Running test up to {} times.".format(MAX_REPEATS))
|
||||||
for i in range(MAX_REPEATS):
|
for i in range(MAX_REPEATS):
|
||||||
self.log.info('Run repeat {}'.format(i + 1))
|
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 = 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:
|
with p2p_lock:
|
||||||
inbound_peer.last_message.pop('notfound', None)
|
inbound_peer.last_message.pop('notfound', None)
|
||||||
inbound_peer.send_and_ping(want_tx)
|
inbound_peer.send_and_ping(want_tx)
|
||||||
|
|
||||||
if inbound_peer.last_message.get('notfound'):
|
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.")
|
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:
|
with p2p_lock:
|
||||||
inbound_peer.last_message.pop('notfound')
|
inbound_peer.last_message.pop('notfound')
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
self.log.debug('tx {} was already announced to us. Try test again.'.format(txid))
|
self.log.debug('tx {} was already announced to us. Try test again.'.format(wtxid))
|
||||||
assert int(txid, 16) in [inv.hash for inv in inbound_peer.last_message['inv'].inv]
|
assert int(wtxid, 16) in [inv.hash for inv in inbound_peer.last_message['inv'].inv]
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue