Browse Source

Merge #10318: [tests] fix wait_for_inv()

3e3c22f [tests] fix wait_for_inv() (John Newbery)

Tree-SHA512: b8070b8461e9c792cc3d9c17fd9d3faf87f550c7c0fc1788e0cd382f0794932b70cc87d480805a3b3c1ca2fdca9f8f1bcb9759300d777d9aaa8d41c016260d93
0.15
MarcoFalke 7 years ago
parent
commit
170bc2c381
No known key found for this signature in database
GPG Key ID: D2EA4850E7528B25
  1. 4
      test/functional/p2p-segwit.py
  2. 7
      test/functional/test_framework/mininode.py

4
test/functional/p2p-segwit.py

@ -916,9 +916,9 @@ class SegWitTest(BitcoinTestFramework): @@ -916,9 +916,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

7
test/functional/test_framework/mininode.py

@ -1604,7 +1604,12 @@ class NodeConnCB(object): @@ -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):

Loading…
Cancel
Save