Skip to content

Commit 2738b63

Browse files
ajtownsMarcoFalke
andcommitted
test: validate behaviour of getpeerinfo last_inv_sequence and inv_to_send
Co-Authored-By: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
1 parent 77b2ebb commit 2738b63

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/functional/p2p_leak_tx.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
)
1313
from test_framework.wallet import MiniWallet
1414

15+
import time
1516

1617
class P2PNode(P2PDataStore):
1718
def on_inv(self, msg):
@@ -36,8 +37,24 @@ def test_tx_in_block(self):
3637

3738
self.log.debug("Generate transaction and block")
3839
inbound_peer.last_message.pop("inv", None)
40+
41+
self.gen_node.setmocktime(int(time.time())) # pause time based activities
3942
wtxid = self.miniwallet.send_self_transfer(from_node=self.gen_node)["wtxid"]
43+
rawmp = self.gen_node.getrawmempool(False, True)
44+
pi = self.gen_node.getpeerinfo()[0]
45+
assert_equal(rawmp["mempool_sequence"], 2) # our tx cause mempool activity
46+
assert_equal(pi["last_inv_sequence"], 1) # that is after the last inv
47+
assert_equal(pi["inv_to_send"], 1) # and our tx has been queued
48+
self.gen_node.setmocktime(0)
49+
4050
inbound_peer.wait_until(lambda: "inv" in inbound_peer.last_message and inbound_peer.last_message.get("inv").inv[0].hash == int(wtxid, 16))
51+
52+
rawmp = self.gen_node.getrawmempool(False, True)
53+
pi = self.gen_node.getpeerinfo()[0]
54+
assert_equal(rawmp["mempool_sequence"], 2) # no mempool update
55+
assert_equal(pi["last_inv_sequence"], 2) # announced the current mempool
56+
assert_equal(pi["inv_to_send"], 0) # nothing left in the queue
57+
4158
want_tx = msg_getdata(inv=inbound_peer.last_message.get("inv").inv)
4259
self.generate(self.gen_node, 1)
4360

0 commit comments

Comments
 (0)