diff options
Diffstat (limited to 'test/functional/test_framework')
-rwxr-xr-x | test/functional/test_framework/comptool.py | 2 | ||||
-rwxr-xr-x | test/functional/test_framework/mininode.py | 26 |
2 files changed, 8 insertions, 20 deletions
diff --git a/test/functional/test_framework/comptool.py b/test/functional/test_framework/comptool.py index cb9a938f94..9f062865a3 100755 --- a/test/functional/test_framework/comptool.py +++ b/test/functional/test_framework/comptool.py @@ -192,7 +192,7 @@ class TestManager(object): return wait_until(disconnected, timeout=10) def wait_for_verack(self): - [node.wait_for_verack() for node in self.test_nodes] + return all(node.wait_for_verack() for node in self.test_nodes) def wait_for_pings(self, counter): def received_pongs(): diff --git a/test/functional/test_framework/mininode.py b/test/functional/test_framework/mininode.py index 3b4d05df6c..b2531a6c9e 100755 --- a/test/functional/test_framework/mininode.py +++ b/test/functional/test_framework/mininode.py @@ -1590,34 +1590,25 @@ class NodeConnCB(object): # Message receiving helper methods - def sync(self, test_function, timeout=60): - while timeout > 0: - with mininode_lock: - if test_function(): - return - time.sleep(0.05) - timeout -= 0.05 - raise AssertionError("Sync failed to complete") - def wait_for_block(self, blockhash, timeout=60): test_function = lambda: self.last_message.get("block") and self.last_message["block"].block.rehash() == blockhash - self.sync(test_function, timeout) + assert wait_until(test_function, timeout=timeout) def wait_for_getdata(self, timeout=60): test_function = lambda: self.last_message.get("getdata") - self.sync(test_function, timeout) + assert wait_until(test_function, timeout=timeout) def wait_for_getheaders(self, timeout=60): test_function = lambda: self.last_message.get("getheaders") - self.sync(test_function, timeout) + 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 - self.sync(test_function, timeout) + assert wait_until(test_function, timeout=timeout) def wait_for_verack(self, timeout=60): test_function = lambda: self.message_count["verack"] - self.sync(test_function, timeout) + assert wait_until(test_function, timeout=timeout) # Message sending helper functions @@ -1635,12 +1626,9 @@ class NodeConnCB(object): def sync_with_ping(self, timeout=60): self.send_message(msg_ping(nonce=self.ping_counter)) test_function = lambda: self.last_message.get("pong") and self.last_message["pong"].nonce == self.ping_counter - success = wait_until(test_function, timeout = timeout) - if not success: - logger.error("sync_with_ping failed!") - raise AssertionError("sync_with_ping failed!") + assert wait_until(test_function, timeout=timeout) self.ping_counter += 1 - return success + return True # The actual NodeConn class # This class provides an interface for a p2p connection to a specified node |