From a9ddf6f4207de6e0a6a1fad4315d6057b081274a Mon Sep 17 00:00:00 2001 From: Tim Flynn Date: Fri, 19 Aug 2016 00:18:45 -0400 Subject: [PATCH] Wait for nodes to sync masternode data during p2p-fullblocktest --- qa/rpc-tests/invalidblockrequest.py | 1 + qa/rpc-tests/p2p-fullblocktest.py | 1 + qa/rpc-tests/test_framework/util.py | 13 +++++++++++++ 3 files changed, 15 insertions(+) diff --git a/qa/rpc-tests/invalidblockrequest.py b/qa/rpc-tests/invalidblockrequest.py index 5a440378fb351..e8d8930b2cbdf 100755 --- a/qa/rpc-tests/invalidblockrequest.py +++ b/qa/rpc-tests/invalidblockrequest.py @@ -34,6 +34,7 @@ def run_test(self): self.tip = None self.block_time = None NetworkThread().start() # Start up network handling in another thread + sync_masternodes(self.nodes) test.run() def get_tests(self): diff --git a/qa/rpc-tests/p2p-fullblocktest.py b/qa/rpc-tests/p2p-fullblocktest.py index 28cc2474f13f1..9aa7a9d08e95c 100755 --- a/qa/rpc-tests/p2p-fullblocktest.py +++ b/qa/rpc-tests/p2p-fullblocktest.py @@ -44,6 +44,7 @@ def run_test(self): test = TestManager(self, self.options.tmpdir) test.add_all_connections(self.nodes) NetworkThread().start() # Start up network handling in another thread + sync_masternodes(self.nodes) test.run() def add_transactions_to_block(self, block, tx_list): diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py index 06c1992bf12d7..daf2836e1ee08 100644 --- a/qa/rpc-tests/test_framework/util.py +++ b/qa/rpc-tests/test_framework/util.py @@ -55,6 +55,15 @@ def get_rpc_proxy(url, node_number, timeout=None): return coverage.AuthServiceProxyWrapper(proxy, coverage_logfile) +def get_mnsync_status(node): + result = node.mnsync("status") + return result['IsSynced'] + +def wait_to_sync(node): + synced = False + while not synced: + synced = get_mnsync_status(node) + time.sleep(0.5) def p2p_port(n): return 11000 + n + os.getpid()%999 @@ -96,6 +105,10 @@ def sync_mempools(rpc_connections, wait=1): break time.sleep(wait) +def sync_masternodes(rpc_connections): + for node in rpc_connections: + wait_to_sync(node) + bitcoind_processes = {} def initialize_datadir(dirname, n):