From 2738b63e025d240618b3c72c28243c3e4d7d9c79 Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Tue, 23 Sep 2025 14:52:13 +1000 Subject: [PATCH] test: validate behaviour of getpeerinfo last_inv_sequence and inv_to_send Co-Authored-By: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> --- test/functional/p2p_leak_tx.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/functional/p2p_leak_tx.py b/test/functional/p2p_leak_tx.py index a1a00751d1..42e586fca3 100755 --- a/test/functional/p2p_leak_tx.py +++ b/test/functional/p2p_leak_tx.py @@ -12,6 +12,7 @@ from test_framework.util import ( ) from test_framework.wallet import MiniWallet +import time class P2PNode(P2PDataStore): def on_inv(self, msg): @@ -36,8 +37,24 @@ class P2PLeakTxTest(BitcoinTestFramework): self.log.debug("Generate transaction and block") inbound_peer.last_message.pop("inv", None) + + self.gen_node.setmocktime(int(time.time())) # pause time based activities wtxid = self.miniwallet.send_self_transfer(from_node=self.gen_node)["wtxid"] + rawmp = self.gen_node.getrawmempool(False, True) + pi = self.gen_node.getpeerinfo()[0] + assert_equal(rawmp["mempool_sequence"], 2) # our tx cause mempool activity + assert_equal(pi["last_inv_sequence"], 1) # that is after the last inv + assert_equal(pi["inv_to_send"], 1) # and our tx has been queued + self.gen_node.setmocktime(0) + inbound_peer.wait_until(lambda: "inv" in inbound_peer.last_message and inbound_peer.last_message.get("inv").inv[0].hash == int(wtxid, 16)) + + rawmp = self.gen_node.getrawmempool(False, True) + pi = self.gen_node.getpeerinfo()[0] + assert_equal(rawmp["mempool_sequence"], 2) # no mempool update + assert_equal(pi["last_inv_sequence"], 2) # announced the current mempool + assert_equal(pi["inv_to_send"], 0) # nothing left in the queue + want_tx = msg_getdata(inv=inbound_peer.last_message.get("inv").inv) self.generate(self.gen_node, 1)