aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/comptool.py
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2017-08-23 17:11:33 -0400
committerMarcoFalke <falke.marco@gmail.com>2017-08-23 17:12:30 -0400
commit8858b6ddd3bce9daa08da6e05de3ca863a399c15 (patch)
treeeeb5f3af4845e8815d800d64f225784b40015abb /test/functional/test_framework/comptool.py
parent41496e20f36987d27bed6cb83c06a6a978bfdf42 (diff)
parent08ce33f8e95efa81b37ddc6b3350462c61bbfd51 (diff)
downloadbitcoin-8858b6ddd3bce9daa08da6e05de3ca863a399c15.tar.xz
Merge #11068: qa: Move wait_until to util
08ce33f8e qa: Move wait_until to util (MarcoFalke) Pull request description: This moves `wait_until` to `util.py` to make it generally available to python tests. Also, `wait_until` now takes an optional lock that is acquired while testing the predicate. Previously the lock was always acquired, even when it was not necessary, cf. `disconnect_ban.py`. Tree-SHA512: 18e452a017a6566fa8ad09bde058e1b841e167039dc63299e70cfa7a6dcbc779581e60ca3e8eb2f1b610767d5208b9376c203eb11015b250fd0542b5eb4215a8
Diffstat (limited to 'test/functional/test_framework/comptool.py')
-rwxr-xr-xtest/functional/test_framework/comptool.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/test/functional/test_framework/comptool.py b/test/functional/test_framework/comptool.py
index 9f062865a3..bfbc0c3b03 100755
--- a/test/functional/test_framework/comptool.py
+++ b/test/functional/test_framework/comptool.py
@@ -19,7 +19,7 @@ TestNode behaves as follows:
from .mininode import *
from .blockstore import BlockStore, TxStore
-from .util import p2p_port
+from .util import p2p_port, wait_until
import logging
@@ -189,7 +189,7 @@ class TestManager(object):
def wait_for_disconnections(self):
def disconnected():
return all(node.closed for node in self.test_nodes)
- return wait_until(disconnected, timeout=10)
+ wait_until(disconnected, timeout=10, lock=mininode_lock)
def wait_for_verack(self):
return all(node.wait_for_verack() for node in self.test_nodes)
@@ -197,7 +197,7 @@ class TestManager(object):
def wait_for_pings(self, counter):
def received_pongs():
return all(node.received_ping_response(counter) for node in self.test_nodes)
- return wait_until(received_pongs)
+ wait_until(received_pongs, lock=mininode_lock)
# sync_blocks: Wait for all connections to request the blockhash given
# then send get_headers to find out the tip of each node, and synchronize
@@ -210,8 +210,7 @@ class TestManager(object):
)
# --> error if not requested
- if not wait_until(blocks_requested, attempts=20*num_blocks):
- raise AssertionError("Not all nodes requested block")
+ wait_until(blocks_requested, attempts=20*num_blocks, lock=mininode_lock)
# Send getheaders message
[ c.cb.send_getheaders() for c in self.connections ]
@@ -231,8 +230,7 @@ class TestManager(object):
)
# --> error if not requested
- if not wait_until(transaction_requested, attempts=20*num_events):
- raise AssertionError("Not all nodes requested transaction")
+ wait_until(transaction_requested, attempts=20*num_events, lock=mininode_lock)
# Get the mempool
[ c.cb.send_mempool() for c in self.connections ]