Skip to content

Commit 3e3c22f

Browse files
committed
[tests] fix wait_for_inv()
1 parent dc8fc0c commit 3e3c22f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

test/functional/p2p-segwit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -926,9 +926,9 @@ def test_tx_relay_after_segwit_activation(self):
926926
tx3.wit.vtxinwit[0].scriptWitness.stack = [ witness_program ]
927927
# Also check that old_node gets a tx announcement, even though this is
928928
# a witness transaction.
929-
self.old_node.wait_for_inv(CInv(1, tx2.sha256)) # wait until tx2 was inv'ed
929+
self.old_node.wait_for_inv([CInv(1, tx2.sha256)]) # wait until tx2 was inv'ed
930930
self.test_node.test_transaction_acceptance(tx3, with_witness=True, accepted=True)
931-
self.old_node.wait_for_inv(CInv(1, tx3.sha256))
931+
self.old_node.wait_for_inv([CInv(1, tx3.sha256)])
932932

933933
# Test that getrawtransaction returns correct witness information
934934
# hash, size, vsize

test/functional/test_framework/mininode.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1604,7 +1604,12 @@ def wait_for_getheaders(self, timeout=60):
16041604
assert wait_until(test_function, timeout=timeout)
16051605

16061606
def wait_for_inv(self, expected_inv, timeout=60):
1607-
test_function = lambda: self.last_message.get("inv") and self.last_message["inv"] != expected_inv
1607+
"""Waits for an INV message and checks that the first inv object in the message was as expected."""
1608+
if len(expected_inv) > 1:
1609+
raise NotImplementedError("wait_for_inv() will only verify the first inv object")
1610+
test_function = lambda: self.last_message.get("inv") and \
1611+
self.last_message["inv"].inv[0].type == expected_inv[0].type and \
1612+
self.last_message["inv"].inv[0].hash == expected_inv[0].hash
16081613
assert wait_until(test_function, timeout=timeout)
16091614

16101615
def wait_for_verack(self, timeout=60):

0 commit comments

Comments
 (0)