aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2017-03-30 08:38:46 -0400
committerJohn Newbery <john@johnnewbery.com>2017-04-18 17:20:09 -0400
commit2a52ae63bfdde948250df1c876dcdd5af99f03b5 (patch)
treed53a338b3c6c9eba1474330412dd0e5953822399 /test/functional/test_framework
parent52e15aa4d067fc4ace12c80be5c82e85c04fcfec (diff)
downloadbitcoin-2a52ae63bfdde948250df1c876dcdd5af99f03b5.tar.xz
Remove duplicate method definitions in NodeConnCB subclasses
All Node classes in individual test cases subclass from NodeConnCB. Many have duplicate definitions for methods that are defined in the base class. This commit removes those duplicate definitions. This commit removes ~290 lines of duplicate code.
Diffstat (limited to 'test/functional/test_framework')
-rwxr-xr-xtest/functional/test_framework/comptool.py2
-rwxr-xr-xtest/functional/test_framework/mininode.py26
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