From 3e3c22f09d37169fa88327323c3755be6dbd9a62 Mon Sep 17 00:00:00 2001 From: John Newbery Date: Tue, 2 May 2017 16:34:44 -0400 Subject: [PATCH] [tests] fix wait_for_inv() --- test/functional/p2p-segwit.py | 4 ++-- test/functional/test_framework/mininode.py | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/test/functional/p2p-segwit.py b/test/functional/p2p-segwit.py index 335777b2a..1499ca525 100755 --- a/test/functional/p2p-segwit.py +++ b/test/functional/p2p-segwit.py @@ -926,9 +926,9 @@ class SegWitTest(BitcoinTestFramework): tx3.wit.vtxinwit[0].scriptWitness.stack = [ witness_program ] # Also check that old_node gets a tx announcement, even though this is # a witness transaction. - self.old_node.wait_for_inv(CInv(1, tx2.sha256)) # wait until tx2 was inv'ed + self.old_node.wait_for_inv([CInv(1, tx2.sha256)]) # wait until tx2 was inv'ed self.test_node.test_transaction_acceptance(tx3, with_witness=True, accepted=True) - self.old_node.wait_for_inv(CInv(1, tx3.sha256)) + self.old_node.wait_for_inv([CInv(1, tx3.sha256)]) # Test that getrawtransaction returns correct witness information # hash, size, vsize diff --git a/test/functional/test_framework/mininode.py b/test/functional/test_framework/mininode.py index 03db0d109..70bba566c 100755 --- a/test/functional/test_framework/mininode.py +++ b/test/functional/test_framework/mininode.py @@ -1604,7 +1604,12 @@ class NodeConnCB(object): assert wait_until(test_function, timeout=timeout) def wait_for_inv(self, expected_inv, timeout=60): - test_function = lambda: self.last_message.get("inv") and self.last_message["inv"] != expected_inv + """Waits for an INV message and checks that the first inv object in the message was as expected.""" + if len(expected_inv) > 1: + raise NotImplementedError("wait_for_inv() will only verify the first inv object") + test_function = lambda: self.last_message.get("inv") and \ + self.last_message["inv"].inv[0].type == expected_inv[0].type and \ + self.last_message["inv"].inv[0].hash == expected_inv[0].hash assert wait_until(test_function, timeout=timeout) def wait_for_verack(self, timeout=60):