Skip to content

Commit 170bc2c

Browse files
author
MarcoFalke
committed
Merge #10318: [tests] fix wait_for_inv()
3e3c22f [tests] fix wait_for_inv() (John Newbery) Tree-SHA512: b8070b8461e9c792cc3d9c17fd9d3faf87f550c7c0fc1788e0cd382f0794932b70cc87d480805a3b3c1ca2fdca9f8f1bcb9759300d777d9aaa8d41c016260d93
2 parents 314ebdf + 3e3c22f commit 170bc2c

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
@@ -916,9 +916,9 @@ def test_tx_relay_after_segwit_activation(self):
916916
tx3.wit.vtxinwit[0].scriptWitness.stack = [ witness_program ]
917917
# Also check that old_node gets a tx announcement, even though this is
918918
# a witness transaction.
919-
self.old_node.wait_for_inv(CInv(1, tx2.sha256)) # wait until tx2 was inv'ed
919+
self.old_node.wait_for_inv([CInv(1, tx2.sha256)]) # wait until tx2 was inv'ed
920920
self.test_node.test_transaction_acceptance(tx3, with_witness=True, accepted=True)
921-
self.old_node.wait_for_inv(CInv(1, tx3.sha256))
921+
self.old_node.wait_for_inv([CInv(1, tx3.sha256)])
922922

923923
# Test that getrawtransaction returns correct witness information
924924
# 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)