Skip to content

Commit 5b77f80

Browse files
committed
test: add p2p_lock acquires in p2p_leak_tx.py
1 parent cc8c682 commit 5b77f80

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

test/functional/p2p_leak_tx.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""Test that we don't leak txs to inbound peers that we haven't yet announced to"""
66

77
from test_framework.messages import msg_getdata, CInv, MSG_TX
8-
from test_framework.p2p import P2PDataStore
8+
from test_framework.p2p import p2p_lock, P2PDataStore
99
from test_framework.test_framework import BitcoinTestFramework
1010
from test_framework.util import (
1111
assert_equal,
@@ -39,14 +39,16 @@ def run_test(self):
3939

4040
want_tx = msg_getdata()
4141
want_tx.inv.append(CInv(t=MSG_TX, h=int(txid, 16)))
42-
inbound_peer.last_message.pop('notfound', None)
42+
with p2p_lock:
43+
inbound_peer.last_message.pop('notfound', None)
4344
inbound_peer.send_and_ping(want_tx)
4445

4546
if inbound_peer.last_message.get('notfound'):
4647
self.log.debug('tx {} was not yet announced to us.'.format(txid))
4748
self.log.debug("node has responded with a notfound message. End test.")
4849
assert_equal(inbound_peer.last_message['notfound'].vec[0].hash, int(txid, 16))
49-
inbound_peer.last_message.pop('notfound')
50+
with p2p_lock:
51+
inbound_peer.last_message.pop('notfound')
5052
break
5153
else:
5254
self.log.debug('tx {} was already announced to us. Try test again.'.format(txid))

0 commit comments

Comments
 (0)