test: fixes p2p_ibd_txrelay wait time

p2p_ibd_txrelay expects no GETDATA to have been received by a peer after
announcing a transaction. The reason is that the node is doing IBD, so
transaction requests are not replied to. However, the way this is checked
is wrong, and the check will pass even if the node **was not** in IBD.

This is due to the mocktime not being properly initialized, so the check
is always performed earlier than it should, making it impossible for the
request to be there
This commit is contained in:
Sergi Delgado Segura 2025-01-29 14:18:51 -05:00
parent b432e36742
commit 1973a9e4f1

View file

@ -47,12 +47,14 @@ class P2PIBDTxRelayTest(BitcoinTestFramework):
assert node.getblockchaininfo()['initialblockdownload'] assert node.getblockchaininfo()['initialblockdownload']
self.wait_until(lambda: all(peer['minfeefilter'] == MAX_FEE_FILTER for peer in node.getpeerinfo())) self.wait_until(lambda: all(peer['minfeefilter'] == MAX_FEE_FILTER for peer in node.getpeerinfo()))
self.nodes[0].setmocktime(int(time.time()))
self.log.info("Check that nodes don't send getdatas for transactions while still in IBD") self.log.info("Check that nodes don't send getdatas for transactions while still in IBD")
peer_inver = self.nodes[0].add_p2p_connection(P2PDataStore()) peer_inver = self.nodes[0].add_p2p_connection(P2PDataStore())
txid = 0xdeadbeef txid = 0xdeadbeef
peer_inver.send_and_ping(msg_inv([CInv(t=MSG_WTX, h=txid)])) peer_inver.send_and_ping(msg_inv([CInv(t=MSG_WTX, h=txid)]))
# The node should not send a getdata, but if it did, it would first delay 2 seconds # The node should not send a getdata, but if it did, it would first delay 2 seconds
self.nodes[0].setmocktime(int(time.time() + NONPREF_PEER_TX_DELAY)) self.nodes[0].bumpmocktime(NONPREF_PEER_TX_DELAY)
peer_inver.sync_with_ping() peer_inver.sync_with_ping()
with p2p_lock: with p2p_lock:
assert txid not in peer_inver.getdata_requests assert txid not in peer_inver.getdata_requests