diff --git a/test/functional/dip3-deterministicmns.py b/test/functional/dip3-deterministicmns.py index da57938b3bd4..79631d239570 100755 --- a/test/functional/dip3-deterministicmns.py +++ b/test/functional/dip3-deterministicmns.py @@ -243,12 +243,12 @@ def start_mn(self, mn): self.add_nodes(1) extra_args = ['-masternode=1', '-masternodeblsprivkey=%s' % mn.blsMnkey] self.start_node(mn.idx, extra_args = self.extra_args + extra_args) + force_finish_mnsync(self.nodes[mn.idx]) for i in range(0, len(self.nodes)): if i < len(self.nodes) and self.nodes[i] is not None and self.nodes[i].process is not None and i != mn.idx: connect_nodes_bi(self.nodes, mn.idx, i) mn.node = self.nodes[mn.idx] self.sync_all() - self.force_finish_mnsync(mn.node) def spend_mn_collateral(self, mn, with_dummy_input_output=False): return self.spend_input(mn.collateral_txid, mn.collateral_vout, 1000, with_dummy_input_output) @@ -276,25 +276,6 @@ def test_protx_update_service(self, mn): self.nodes[0].protx('update_service', mn.protx_hash, '127.0.0.1:%d' % mn.p2p_port, mn.blsMnkey, "", mn.fundsAddr) self.nodes[0].generate(1) - def force_finish_mnsync(self, node): - while True: - s = node.mnsync('next') - if s == 'sync updated to MASTERNODE_SYNC_FINISHED': - break - time.sleep(0.1) - - def force_finish_mnsync_list(self, node): - if node.mnsync('status')['AssetName'] == 'MASTERNODE_SYNC_WAITING': - node.mnsync('next') - - while True: - mnlist = node.masternode('list', 'status') - if len(mnlist) != 0: - time.sleep(0.5) - self.force_finish_mnsync(node) - return - time.sleep(0.1) - def assert_mnlists(self, mns): for node in self.nodes: self.assert_mnlist(node, mns) diff --git a/test/functional/invalidblockrequest.py b/test/functional/invalidblockrequest.py index 6d943dc8acf3..9ff016a513ac 100755 --- a/test/functional/invalidblockrequest.py +++ b/test/functional/invalidblockrequest.py @@ -15,7 +15,7 @@ from test_framework.blocktools import create_block, create_coinbase, create_transaction, network_thread_start from test_framework.mininode import P2PDataStore, COIN from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, sync_masternodes +from test_framework.util import assert_equal class InvalidBlockRequestTest(BitcoinTestFramework): @@ -30,7 +30,6 @@ def run_test(self): node.add_p2p_connection(P2PDataStore()) network_thread_start() - sync_masternodes(self.nodes, True) node.p2p.wait_for_verack() best_block = node.getblock(node.getbestblockhash()) diff --git a/test/functional/p2p-fullblocktest.py b/test/functional/p2p-fullblocktest.py index 3d4993b461c0..aef3793ab711 100755 --- a/test/functional/p2p-fullblocktest.py +++ b/test/functional/p2p-fullblocktest.py @@ -71,7 +71,6 @@ def run_test(self): self.test = TestManager(self, self.options.tmpdir) self.test.add_all_connections(self.nodes) network_thread_start() - sync_masternodes(self.nodes, True) self.test.run() def add_transactions_to_block(self, block, tx_list): diff --git a/test/functional/sporks.py b/test/functional/sporks.py index 81726d54258f..3243daa0e946 100755 --- a/test/functional/sporks.py +++ b/test/functional/sporks.py @@ -63,9 +63,6 @@ def run_test(self): assert(self.get_test_spork_state(self.nodes[0])) assert(self.get_test_spork_state(self.nodes[1])) - # Force finish mnsync node as otherwise it will never send out headers to other peers - wait_to_sync(self.nodes[1], fast_mnsync=True) - # Generate one block to kick off masternode sync, which also starts sporks syncing for node2 self.nodes[1].generate(1) diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index bfabba01839f..ecd0822b881e 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -30,6 +30,7 @@ connect_nodes, copy_datadir, disconnect_nodes, + force_finish_mnsync, initialize_datadir, log_filename, p2p_port, @@ -37,8 +38,6 @@ satoshi_round, sync_blocks, sync_mempools, - sync_masternodes, - wait_to_sync, wait_until, ) @@ -580,7 +579,7 @@ def do_start(idx): self.start_node(idx + start_idx, extra_args=args) self.mninfo[idx].nodeIdx = idx + start_idx self.mninfo[idx].node = self.nodes[idx + start_idx] - wait_to_sync(self.mninfo[idx].node, True) + force_finish_mnsync(self.mninfo[idx].node) def do_connect(idx): for i in range(0, idx + 1): @@ -606,8 +605,6 @@ def do_connect(idx): job.result() jobs.clear() - sync_masternodes(self.nodes, True) - executor.shutdown() def setup_network(self): @@ -624,7 +621,6 @@ def setup_network(self): self.log.info("Creating and starting %s simple nodes", num_simple_nodes) for i in range(0, num_simple_nodes): self.create_simple_node() - sync_masternodes(self.nodes, True) self.log.info("Activating DIP3") if not self.fast_dip3_enforcement: diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py index f724348d556c..ffe84177a3ef 100644 --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -263,20 +263,6 @@ def get_rpc_proxy(url, node_number, timeout=None, coveragedir=None): return coverage.AuthServiceProxyWrapper(proxy, coverage_logfile) -def get_mnsync_status(node): - result = node.mnsync("status") - return result['IsSynced'] - -def wait_to_sync(node, fast_mnsync=False): - while True: - synced = get_mnsync_status(node) - if synced: - break - time.sleep(0.2) - if fast_mnsync: - # skip mnsync states - node.mnsync("next") - def p2p_port(n): assert(n <= MAX_NODES) return PORT_MIN + n + (MAX_NODES * PortSeed.n) % (PORT_RANGE - 1 - MAX_NODES) @@ -449,9 +435,15 @@ def sync_mempools(rpc_connections, *, wait=1, timeout=60): timeout -= wait raise AssertionError("Mempool sync failed") -def sync_masternodes(rpc_connections, fast_mnsync=False): - for node in rpc_connections: - wait_to_sync(node, fast_mnsync) +def force_finish_mnsync(node): + """ + Masternodes won't accept incoming connections while IsSynced is false. + Force them to switch to this state to speed things up. + """ + while True: + if node.mnsync("status")['IsSynced']: + break + node.mnsync("next") # Transaction/Block functions #############################