diff --git a/test/functional/feature_asset_locks.py b/test/functional/feature_asset_locks.py index 3a19b5f229..8070b151dc 100755 --- a/test/functional/feature_asset_locks.py +++ b/test/functional/feature_asset_locks.py @@ -256,8 +256,7 @@ class AssetLocksTest(DashTestFramework): for _ in range(2): self.dynamically_add_masternode(evo=True) - self.generate(node, 8) - self.sync_blocks() + self.generate(node, 8, sync_fun=lambda: self.sync_blocks()) self.set_sporks() self.generate(node, 1) diff --git a/test/functional/feature_dip3_v19.py b/test/functional/feature_dip3_v19.py index 0bdfad5b21..56d663013b 100755 --- a/test/functional/feature_dip3_v19.py +++ b/test/functional/feature_dip3_v19.py @@ -86,8 +86,7 @@ class DIP3V19Test(DashTestFramework): evo_info_0 = self.dynamically_add_masternode(evo=True, rnd=7) assert evo_info_0 is not None - self.generate(self.nodes[0], 8) - self.sync_blocks() + self.generate(self.nodes[0], 8, sync_fun=lambda: self.sync_blocks()) self.log.info("Checking that protxs with duplicate EvoNodes fields are rejected") evo_info_1 = self.dynamically_add_masternode(evo=True, rnd=7, should_be_rejected=True) @@ -97,8 +96,7 @@ class DIP3V19Test(DashTestFramework): assert evo_info_2 is None evo_info_3 = self.dynamically_add_masternode(evo=True, rnd=9) assert evo_info_3 is not None - self.generate(self.nodes[0], 8) - self.sync_blocks() + self.generate(self.nodes[0], 8, sync_fun=lambda: self.sync_blocks()) self.dynamically_evo_update_service(evo_info_0, 9, should_be_rejected=True) revoke_protx = self.mninfo[-1].proTxHash diff --git a/test/functional/feature_governance_cl.py b/test/functional/feature_governance_cl.py index fdc9f01ce4..fb7bee08f6 100755 --- a/test/functional/feature_governance_cl.py +++ b/test/functional/feature_governance_cl.py @@ -69,8 +69,7 @@ class DashGovernanceTest (DashTestFramework): n = sb_cycle - self.nodes[0].getblockcount() % sb_cycle for _ in range(n): self.bump_mocktime(156) - self.generate(self.nodes[0], 1) - self.sync_blocks() + self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_blocks()) self.log.info("Prepare proposals") @@ -116,8 +115,7 @@ class DashGovernanceTest (DashTestFramework): assert n >= 0 for _ in range(n + 1): self.bump_mocktime(156) - self.generate(self.nodes[0], 1) - self.sync_blocks(self.nodes[0:5]) + self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_blocks(self.nodes[0:5])) self.log.info("Wait for new trigger and votes on non-isolated nodes") sb_block_height = self.nodes[0].getblockcount() // sb_cycle * sb_cycle + sb_cycle @@ -130,29 +128,25 @@ class DashGovernanceTest (DashTestFramework): self.log.info("Move remaining n blocks until the next Superblock") for _ in range(n - 1): self.bump_mocktime(156) - self.generate(self.nodes[0], 1) - self.sync_blocks(self.nodes[0:5]) + self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_blocks(self.nodes[0:5])) # Confirm all is good self.wait_until(lambda: have_trigger_for_height(self.nodes[0:5], sb_block_height), timeout=5) self.log.info("Mine superblock") self.bump_mocktime(156) - self.generate(self.nodes[0], 1) - self.sync_blocks(self.nodes[0:5]) + self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_blocks(self.nodes[0:5])) self.wait_for_chainlocked_block(self.nodes[0], self.nodes[0].getbestblockhash()) self.log.info("Mine (superblock cycle + 1) blocks on non-isolated nodes to forget about this trigger") for _ in range(sb_cycle): self.bump_mocktime(156) - self.generate(self.nodes[0], 1) - self.sync_blocks(self.nodes[0:5]) + self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_blocks(self.nodes[0:5])) # Should still have at least 1 trigger for the old sb cycle and 0 for the current one assert len(self.nodes[0].gobject("list", "valid", "triggers")) >= 1 assert not have_trigger_for_height(self.nodes[0:5], sb_block_height + sb_cycle) self.bump_mocktime(156) - self.generate(self.nodes[0], 1) - self.sync_blocks(self.nodes[0:5]) + self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_blocks(self.nodes[0:5])) # Trigger scheduler to mark old triggers for deletion self.bump_mocktime(5 * 60) # Let it do the job diff --git a/test/functional/feature_llmq_chainlocks.py b/test/functional/feature_llmq_chainlocks.py index fa90a7e233..10bb909390 100755 --- a/test/functional/feature_llmq_chainlocks.py +++ b/test/functional/feature_llmq_chainlocks.py @@ -238,8 +238,7 @@ class LLMQChainLocksTest(DashTestFramework): self.log.info("Test that new node can mine without Chainlock info") tip_0 = self.nodes[0].getblock(self.nodes[0].getbestblockhash(), 2) - self.generate(self.nodes[added_idx], 1) - self.sync_blocks() + self.generate(self.nodes[added_idx], 1, sync_fun=lambda: self.sync_blocks()) tip_1 = self.nodes[0].getblock(self.nodes[0].getbestblockhash(), 2) assert_equal(tip_1['cbTx']['bestCLSignature'], tip_0['cbTx']['bestCLSignature']) assert_equal(tip_1['cbTx']['bestCLHeightDiff'], tip_0['cbTx']['bestCLHeightDiff'] + 1) diff --git a/test/functional/feature_llmq_evo.py b/test/functional/feature_llmq_evo.py index 524aee2314..b2b60bdb29 100755 --- a/test/functional/feature_llmq_evo.py +++ b/test/functional/feature_llmq_evo.py @@ -89,8 +89,7 @@ class LLMQEvoNodesTest(DashTestFramework): for i in range(self.evo_count): evo_info = self.dynamically_add_masternode(evo=True) evo_protxhash_list.append(evo_info.proTxHash) - self.generate(self.nodes[0], 8) - self.sync_blocks() + self.generate(self.nodes[0], 8, sync_fun=lambda: self.sync_blocks()) expectedUpdated.append(evo_info.proTxHash) b_i = self.nodes[0].getbestblockhash() @@ -116,8 +115,7 @@ class LLMQEvoNodesTest(DashTestFramework): # Generate a few blocks to make EvoNode/MN analysis on a pure MN RewardReallocation window self.bump_mocktime(1) - self.generate(self.nodes[0], 4) - self.sync_blocks() + self.generate(self.nodes[0], 4, sync_fun=lambda: self.sync_blocks()) self.log.info("Test that EvoNodes are paid 1 block in a row after MN RewardReallocation activation") self.test_evo_payments(window_analysis=48, mnrr_active=True) diff --git a/test/functional/feature_llmq_is_cl_conflicts.py b/test/functional/feature_llmq_is_cl_conflicts.py index d81f15431a..2369c59fa4 100755 --- a/test/functional/feature_llmq_is_cl_conflicts.py +++ b/test/functional/feature_llmq_is_cl_conflicts.py @@ -118,9 +118,8 @@ class LLMQ_IS_CL_Conflicts(DashTestFramework): cl = self.create_chainlock(self.nodes[0].getblockcount() + 1, block) if mine_confllicting: - islock_tip = self.generate(self.nodes[0], 1)[-1] # Make sure we won't sent clsig too early - self.sync_blocks() + islock_tip = self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_blocks())[-1] self.test_node.send_clsig(cl) diff --git a/test/functional/feature_llmq_rotation.py b/test/functional/feature_llmq_rotation.py index 709e85b461..8dd187f7ae 100755 --- a/test/functional/feature_llmq_rotation.py +++ b/test/functional/feature_llmq_rotation.py @@ -144,15 +144,13 @@ class LLMQQuorumRotationTest(DashTestFramework): # At this point, we want to wait for CLs just before the self.mine_cycle_quorum to diversify the CLs in CbTx. # Although because here a new quorum cycle is starting, and we don't want to mine them now, mine 8 blocks (to skip all DKG phases) nodes = [self.nodes[0]] + [mn.node for mn in self.mninfo.copy()] - self.generate(self.nodes[0], 8) - self.sync_blocks(nodes) + self.generate(self.nodes[0], 8, sync_fun=lambda: self.sync_blocks(nodes)) self.wait_for_chainlocked_block_all_nodes(self.nodes[0].getbestblockhash()) # And for the remaining blocks, enforce new CL in CbTx skip_count = 23 - (self.nodes[0].getblockcount() % 24) for _ in range(skip_count): - self.generate(self.nodes[0], 1) - self.sync_blocks(nodes) + self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_blocks(nodes)) self.wait_for_chainlocked_block_all_nodes(self.nodes[0].getbestblockhash()) diff --git a/test/functional/feature_llmq_simplepose.py b/test/functional/feature_llmq_simplepose.py index 72b1b3eec7..b984b89bc4 100755 --- a/test/functional/feature_llmq_simplepose.py +++ b/test/functional/feature_llmq_simplepose.py @@ -141,8 +141,7 @@ class LLMQSimplePoSeTest(DashTestFramework): self.log.info("Mining final commitment") self.bump_mocktime(1, nodes=nodes) self.nodes[0].getblocktemplate() # this calls CreateNewBlock - self.generate(self.nodes[0], 1) - self.sync_blocks(nodes) + self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_blocks(nodes)) self.log.info("Waiting for quorum to appear in the list") self.wait_for_quorum_list(q, nodes) @@ -153,8 +152,7 @@ class LLMQSimplePoSeTest(DashTestFramework): # Mine 8 (SIGN_HEIGHT_OFFSET) more blocks to make sure that the new quorum gets eligible for signing sessions self.bump_mocktime(8) - self.generate(self.nodes[0], 8) - self.sync_blocks(nodes) + self.generate(self.nodes[0], 8, sync_fun=lambda: self.sync_blocks(nodes)) self.log.info("New quorum: height=%d, quorumHash=%s, quorumIndex=%d, minedBlock=%s" % (quorum_info["height"], new_quorum, quorum_info["quorumIndex"], quorum_info["minedBlock"])) return new_quorum diff --git a/test/functional/feature_mnehf.py b/test/functional/feature_mnehf.py index d650dfd5f8..3c77a69caf 100755 --- a/test/functional/feature_mnehf.py +++ b/test/functional/feature_mnehf.py @@ -223,15 +223,13 @@ class MnehfTest(DashTestFramework): self.log.info("Testing duplicate EHF signal with same bit") ehf_tx_duplicate = self.send_tx(self.create_mnehf(28, pubkey)) - tip_blockhash = self.generate(node, 1)[0] - self.sync_blocks() + tip_blockhash = self.generate(node, 1, sync_fun=lambda: self.sync_blocks())[0] block = node.getblock(tip_blockhash) assert ehf_tx_duplicate in node.getrawmempool() and ehf_tx_duplicate not in block['tx'] self.log.info("Testing EHF signal with same bit but with newer start time") self.bump_mocktime(int(60 * 60 * 24 * 14), update_schedulers=False) - self.generate(node, 1) - self.sync_blocks() + self.generate(node, 1, sync_fun=lambda: self.sync_blocks()) self.restart_all_nodes(params=[self.mocktime, self.mocktime + 1000000]) self.check_fork('defined') diff --git a/test/functional/interface_zmq_dash.py b/test/functional/interface_zmq_dash.py index 508590af3a..6483b12460 100755 --- a/test/functional/interface_zmq_dash.py +++ b/test/functional/interface_zmq_dash.py @@ -170,8 +170,7 @@ class DashZMQTest (DashTestFramework): def generate_blocks(self, num_blocks): mninfos_online = self.mninfo.copy() nodes = [self.nodes[0]] + [mn.node for mn in mninfos_online] - self.generate(self.nodes[0], num_blocks) - self.sync_blocks(nodes) + self.generate(self.nodes[0], num_blocks, sync_fun=lambda: self.sync_blocks(nodes)) def subscribe(self, publishers): import zmq @@ -375,8 +374,7 @@ class DashZMQTest (DashTestFramework): proposal_hex = ''.join(format(x, '02x') for x in json.dumps(proposal_data).encode()) collateral = self.nodes[0].gobject("prepare", "0", proposal_rev, proposal_time, proposal_hex) self.wait_for_instantlock(collateral, self.nodes[0]) - self.generate(self.nodes[0], 6) - self.sync_blocks() + self.generate(self.nodes[0], 6, sync_fun=lambda: self.sync_blocks()) rpc_proposal_hash = self.nodes[0].gobject("submit", "0", proposal_rev, proposal_time, proposal_hex, collateral) # Validate hashgovernanceobject zmq_governance_object_hash = self.subscribers[ZMQPublisher.hash_governance_object].receive().read(32).hex() diff --git a/test/functional/p2p_quorum_data.py b/test/functional/p2p_quorum_data.py index d72894d217..20f451eac7 100755 --- a/test/functional/p2p_quorum_data.py +++ b/test/functional/p2p_quorum_data.py @@ -135,8 +135,7 @@ class QuorumDataMessagesTest(DashTestFramework): self.bump_mocktime(bump_seconds) # Test with/without expired request cleanup if self.cleanup: - self.generate(node0, 1) - self.sync_blocks() + self.generate(node0, 1, sync_fun=lambda: self.sync_blocks()) def test_basics(): self.log.info("Testing basics of QGETDATA/QDATA") diff --git a/test/functional/p2p_sendheaders_compressed.py b/test/functional/p2p_sendheaders_compressed.py index dc5beb1702..c31c52aa80 100755 --- a/test/functional/p2p_sendheaders_compressed.py +++ b/test/functional/p2p_sendheaders_compressed.py @@ -149,8 +149,8 @@ class SendHeadersTest(BitcoinTestFramework): to-be-reorged-out blocks are mined, so that we don't break later tests. return the list of block hashes newly mined.""" - self.generate(self.nodes[0], length) # make sure all invalidated blocks are node0's - self.sync_blocks(wait=0.1) + # make sure all invalidated blocks are node0's + self.generate(self.nodes[0], length, sync_fun=lambda: self.sync_blocks(wait=0.1)) for p2p in self.nodes[0].p2ps: p2p.wait_for_block_announcement(int(self.nodes[0].getbestblockhash(), 16)) p2p.clear_block_announcements() @@ -158,8 +158,8 @@ class SendHeadersTest(BitcoinTestFramework): tip_height = self.nodes[1].getblockcount() hash_to_invalidate = self.nodes[1].getblockhash(tip_height - (length - 1)) self.nodes[1].invalidateblock(hash_to_invalidate) - all_hashes = self.generate(self.nodes[1], length + 1) # Must be longer than the orig chain - self.sync_blocks(wait=0.1) + # Must be longer than the orig chain + all_hashes = self.generate(self.nodes[1], length + 1, sync_fun=lambda: self.sync_blocks(wait=0.1)) return [int(hash_value, 16) for hash_value in all_hashes] def run_test(self): diff --git a/test/functional/rpc_verifyislock.py b/test/functional/rpc_verifyislock.py index 81800d4b6c..b268f7ea07 100755 --- a/test/functional/rpc_verifyislock.py +++ b/test/functional/rpc_verifyislock.py @@ -44,8 +44,7 @@ class RPCVerifyISLockTest(DashTestFramework): self.mine_cycle_quorum(llmq_type_name='llmq_test_dip0024', llmq_type=103) self.bump_mocktime(1) - self.generate(self.nodes[0], 8) - self.sync_blocks() + self.generate(self.nodes[0], 8, sync_fun=self.sync_blocks()) txid = node.sendtoaddress(node.getnewaddress(), 1) self.wait_for_instantlock(txid, node)