diff options
author | Roy Shao <ycshao0402@gmail.com> | 2020-06-09 16:41:08 -0400 |
---|---|---|
committer | Roy Shao <ycshao0402@gmail.com> | 2020-06-18 13:32:36 -0400 |
commit | cc84460c164bcb2a874d4f08b3a2624e5ee9ff0a (patch) | |
tree | 1d0dc6761d311af87a244334f832ec800012d30b /test/functional/test_framework/util.py | |
parent | 9ad6f14175c19b5d47267c3dd5840c14bad43c83 (diff) | |
download | bitcoin-cc84460c164bcb2a874d4f08b3a2624e5ee9ff0a.tar.xz |
test: move sync_blocks and sync_mempool functions to test_framework.py
Diffstat (limited to 'test/functional/test_framework/util.py')
-rw-r--r-- | test/functional/test_framework/util.py | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py index 52306c8c3d..bf6dc44baa 100644 --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -420,50 +420,6 @@ def connect_nodes(from_connection, node_num): wait_until(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in from_connection.getpeerinfo())) -def sync_blocks(rpc_connections, *, wait=1, timeout=60): - """ - Wait until everybody has the same tip. - - sync_blocks needs to be called with an rpc_connections set that has least - one node already synced to the latest, stable tip, otherwise there's a - chance it might return before all nodes are stably synced. - """ - stop_time = time.time() + timeout - while time.time() <= stop_time: - best_hash = [x.getbestblockhash() for x in rpc_connections] - if best_hash.count(best_hash[0]) == len(rpc_connections): - return - # Check that each peer has at least one connection - assert (all([len(x.getpeerinfo()) for x in rpc_connections])) - time.sleep(wait) - raise AssertionError("Block sync timed out after {}s:{}".format( - timeout, - "".join("\n {!r}".format(b) for b in best_hash), - )) - - -def sync_mempools(rpc_connections, *, wait=1, timeout=60, flush_scheduler=True): - """ - Wait until everybody has the same transactions in their memory - pools - """ - stop_time = time.time() + timeout - while time.time() <= stop_time: - pool = [set(r.getrawmempool()) for r in rpc_connections] - if pool.count(pool[0]) == len(rpc_connections): - if flush_scheduler: - for r in rpc_connections: - r.syncwithvalidationinterfacequeue() - return - # Check that each peer has at least one connection - assert (all([len(x.getpeerinfo()) for x in rpc_connections])) - time.sleep(wait) - raise AssertionError("Mempool sync timed out after {}s:{}".format( - timeout, - "".join("\n {!r}".format(m) for m in pool), - )) - - # Transaction/Block functions ############################# |