diff --git a/test/functional/feature_governance_cl.py b/test/functional/feature_governance_cl.py index 6b1dab92d0..4c6d1a1ba9 100755 --- a/test/functional/feature_governance_cl.py +++ b/test/functional/feature_governance_cl.py @@ -50,14 +50,7 @@ class DashGovernanceTest (DashTestFramework): self.wait_for_sporks_same() self.activate_v19(expected_activation_height=900) self.log.info("Activated v19 at height:" + str(self.nodes[0].getblockcount())) - self.move_to_next_cycle() - self.log.info("Cycle H height:" + str(self.nodes[0].getblockcount())) - self.move_to_next_cycle() - self.log.info("Cycle H+C height:" + str(self.nodes[0].getblockcount())) - self.move_to_next_cycle() - self.log.info("Cycle H+2C height:" + str(self.nodes[0].getblockcount())) - - self.mine_cycle_quorum(llmq_type_name='llmq_test_dip0024', llmq_type=103) + self.mine_cycle_quorum() self.sync_blocks() self.wait_for_chainlocked_block_all_nodes(self.nodes[0].getbestblockhash()) diff --git a/test/functional/feature_llmq_chainlocks.py b/test/functional/feature_llmq_chainlocks.py index 599d350c75..585bc77b79 100755 --- a/test/functional/feature_llmq_chainlocks.py +++ b/test/functional/feature_llmq_chainlocks.py @@ -49,13 +49,7 @@ class LLMQChainLocksTest(DashTestFramework): self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0) self.wait_for_sporks_same() - self.move_to_next_cycle() - self.log.info("Cycle H height:" + str(self.nodes[0].getblockcount())) - self.move_to_next_cycle() - self.log.info("Cycle H+C height:" + str(self.nodes[0].getblockcount())) - self.move_to_next_cycle() - self.log.info("Cycle H+2C height:" + str(self.nodes[0].getblockcount())) - self.mine_cycle_quorum(llmq_type_name="llmq_test_dip0024", llmq_type=103) + self.mine_cycle_quorum() self.wait_for_chainlocked_block_all_nodes(self.nodes[0].getbestblockhash()) self.log.info("Mine single block, ensure it includes latest chainlock") diff --git a/test/functional/feature_llmq_connections.py b/test/functional/feature_llmq_connections.py index 626bcf4d5b..b46d756ba0 100755 --- a/test/functional/feature_llmq_connections.py +++ b/test/functional/feature_llmq_connections.py @@ -76,13 +76,7 @@ class LLMQConnections(DashTestFramework): self.activate_v19(expected_activation_height=900) self.log.info("Activated v19 at height:" + str(self.nodes[0].getblockcount())) - self.move_to_next_cycle() - self.log.info("Cycle H height:" + str(self.nodes[0].getblockcount())) - self.move_to_next_cycle() - self.log.info("Cycle H+C height:" + str(self.nodes[0].getblockcount())) - self.move_to_next_cycle() - self.log.info("Cycle H+2C height:" + str(self.nodes[0].getblockcount())) - self.mine_cycle_quorum(llmq_type_name='llmq_test_dip0024', llmq_type=103) + self.mine_cycle_quorum() # Since we IS quorums are mined only using dip24 (rotation) we need to enable rotation, and continue tests on llmq_test_dip0024 for connections. @@ -93,7 +87,7 @@ class LLMQConnections(DashTestFramework): try: with mn.node.assert_debug_log(['removing masternodes quorum connections']): with mn.node.assert_debug_log(['keeping mn quorum connections']): - self.mine_cycle_quorum(llmq_type_name='llmq_test_dip0024', llmq_type=103) + self.mine_cycle_quorum(is_first=False) mn.node.mockscheduler(60) # we check for old connections via the scheduler every 60 seconds removed = True except: @@ -108,7 +102,7 @@ class LLMQConnections(DashTestFramework): if len(mn.node.quorum("memberof", mn.proTxHash)) > 0: try: with mn.node.assert_debug_log(['adding mn inter-quorum connections']): - self.mine_cycle_quorum(llmq_type_name='llmq_test_dip0024', llmq_type=103) + self.mine_cycle_quorum(is_first=False) added = True except: pass # it's ok to not add connections sometimes diff --git a/test/functional/feature_llmq_is_cl_conflicts.py b/test/functional/feature_llmq_is_cl_conflicts.py index 1f7c835d49..b19572ef77 100755 --- a/test/functional/feature_llmq_is_cl_conflicts.py +++ b/test/functional/feature_llmq_is_cl_conflicts.py @@ -61,14 +61,7 @@ class LLMQ_IS_CL_Conflicts(DashTestFramework): self.activate_v19(expected_activation_height=900) self.log.info("Activated v19 at height:" + str(self.nodes[0].getblockcount())) - self.move_to_next_cycle() - self.log.info("Cycle H height:" + str(self.nodes[0].getblockcount())) - self.move_to_next_cycle() - self.log.info("Cycle H+C height:" + str(self.nodes[0].getblockcount())) - self.move_to_next_cycle() - self.log.info("Cycle H+2C height:" + str(self.nodes[0].getblockcount())) - - self.mine_cycle_quorum(llmq_type_name='llmq_test_dip0024', llmq_type=103) + self.mine_cycle_quorum() # mine single block, wait for chainlock self.generate(self.nodes[0], 1, sync_fun=self.no_op) diff --git a/test/functional/feature_llmq_is_retroactive.py b/test/functional/feature_llmq_is_retroactive.py index ea603e90dd..94269ea423 100755 --- a/test/functional/feature_llmq_is_retroactive.py +++ b/test/functional/feature_llmq_is_retroactive.py @@ -31,15 +31,7 @@ class LLMQ_IS_RetroactiveSigning(DashTestFramework): self.wait_for_sporks_same() self.activate_v19(expected_activation_height=900) - self.log.info("Activated v19 at height:" + str(self.nodes[0].getblockcount())) - self.move_to_next_cycle() - self.log.info("Cycle H height:" + str(self.nodes[0].getblockcount())) - self.move_to_next_cycle() - self.log.info("Cycle H+C height:" + str(self.nodes[0].getblockcount())) - self.move_to_next_cycle() - self.log.info("Cycle H+2C height:" + str(self.nodes[0].getblockcount())) - - self.mine_cycle_quorum(llmq_type_name='llmq_test_dip0024', llmq_type=103) + self.mine_cycle_quorum() # Make sure that all nodes are chainlocked at the same height before starting actual tests self.wait_for_chainlocked_block_all_nodes(self.nodes[0].getbestblockhash(), timeout=30) diff --git a/test/functional/feature_llmq_rotation.py b/test/functional/feature_llmq_rotation.py index 3d933eb8e4..233f39d495 100755 --- a/test/functional/feature_llmq_rotation.py +++ b/test/functional/feature_llmq_rotation.py @@ -154,7 +154,7 @@ class LLMQQuorumRotationTest(DashTestFramework): self.wait_for_chainlocked_block_all_nodes(self.nodes[0].getbestblockhash()) - (quorum_info_0_0, quorum_info_0_1) = self.mine_cycle_quorum(llmq_type_name=llmq_type_name, llmq_type=llmq_type) + (quorum_info_0_0, quorum_info_0_1) = self.mine_cycle_quorum(is_first=False) assert(self.test_quorum_listextended(quorum_info_0_0, llmq_type_name)) assert(self.test_quorum_listextended(quorum_info_0_1, llmq_type_name)) quorum_members_0_0 = extract_quorum_members(quorum_info_0_0) @@ -176,7 +176,7 @@ class LLMQQuorumRotationTest(DashTestFramework): self.log.info("Wait for chainlock") self.wait_for_chainlocked_block_all_nodes(self.nodes[0].getbestblockhash()) - (quorum_info_1_0, quorum_info_1_1) = self.mine_cycle_quorum(llmq_type_name=llmq_type_name, llmq_type=llmq_type) + (quorum_info_1_0, quorum_info_1_1) = self.mine_cycle_quorum(is_first=False) assert(self.test_quorum_listextended(quorum_info_1_0, llmq_type_name)) assert(self.test_quorum_listextended(quorum_info_1_1, llmq_type_name)) quorum_members_1_0 = extract_quorum_members(quorum_info_1_0) @@ -210,7 +210,7 @@ class LLMQQuorumRotationTest(DashTestFramework): self.wait_for_chainlocked_block_all_nodes(self.nodes[0].getbestblockhash()) self.log.info("Mine a quorum to invalidate") - (quorum_info_3_0, quorum_info_3_1) = self.mine_cycle_quorum(llmq_type_name=llmq_type_name, llmq_type=llmq_type) + (quorum_info_3_0, quorum_info_3_1) = self.mine_cycle_quorum(is_first=False) new_quorum_list = self.nodes[0].quorum("list", llmq_type) assert_equal(len(new_quorum_list[llmq_type_name]), len(quorum_list[llmq_type_name]) + 2) @@ -383,6 +383,20 @@ class LLMQQuorumRotationTest(DashTestFramework): return True return False + def move_to_next_cycle(self): + cycle_length = 24 + mninfos_online = self.mninfo.copy() + nodes = [self.nodes[0]] + [mn.node for mn in mninfos_online] + cur_block = self.nodes[0].getblockcount() + + # move forward to next DKG + skip_count = cycle_length - (cur_block % cycle_length) + if skip_count != 0: + self.bump_mocktime(1, nodes=nodes) + self.generate(self.nodes[0], skip_count, sync_fun=self.no_op) + self.sync_blocks(nodes) + self.log.info('Moved from block %d to %d' % (cur_block, self.nodes[0].getblockcount())) + if __name__ == '__main__': LLMQQuorumRotationTest().main() diff --git a/test/functional/feature_notifications.py b/test/functional/feature_notifications.py index 32a983df65..c21cee9311 100755 --- a/test/functional/feature_notifications.py +++ b/test/functional/feature_notifications.py @@ -106,14 +106,7 @@ class NotificationsTest(DashTestFramework): self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0) self.nodes[0].sporkupdate("SPORK_19_CHAINLOCKS_ENABLED", 4070908800) self.wait_for_sporks_same() - self.move_to_next_cycle() - self.log.info("Cycle H height:" + str(self.nodes[0].getblockcount())) - self.move_to_next_cycle() - self.log.info("Cycle H+C height:" + str(self.nodes[0].getblockcount())) - self.move_to_next_cycle() - self.log.info("Cycle H+2C height:" + str(self.nodes[0].getblockcount())) - - (quorum_info_i_0, quorum_info_i_1) = self.mine_cycle_quorum(llmq_type_name='llmq_test_dip0024', llmq_type=103) + (quorum_info_i_0, quorum_info_i_1) = self.mine_cycle_quorum() self.nodes[0].sporkupdate("SPORK_19_CHAINLOCKS_ENABLED", 0) self.wait_for_sporks_same() diff --git a/test/functional/interface_zmq_dash.py b/test/functional/interface_zmq_dash.py index 86b7f8ef7d..b1f64e445d 100755 --- a/test/functional/interface_zmq_dash.py +++ b/test/functional/interface_zmq_dash.py @@ -139,14 +139,8 @@ class DashZMQTest (DashTestFramework): self.wait_for_sporks_same() self.activate_v19(expected_activation_height=900) self.log.info("Activated v19 at height:" + str(self.nodes[0].getblockcount())) - self.move_to_next_cycle() - self.log.info("Cycle H height:" + str(self.nodes[0].getblockcount())) - self.move_to_next_cycle() - self.log.info("Cycle H+C height:" + str(self.nodes[0].getblockcount())) - self.move_to_next_cycle() - self.log.info("Cycle H+2C height:" + str(self.nodes[0].getblockcount())) - self.mine_cycle_quorum(llmq_type_name='llmq_test_dip0024', llmq_type=103) + self.mine_cycle_quorum() self.sync_blocks() self.wait_for_chainlocked_block_all_nodes(self.nodes[0].getbestblockhash()) @@ -162,12 +156,7 @@ class DashZMQTest (DashTestFramework): self.wait_for_chainlocked_block_all_nodes(self.nodes[0].getbestblockhash()) self.test_instantsend_publishers() # At this point, we need to move forward 3 cycles (3 x 24 blocks) so the first 3 quarters can be created (without DKG sessions) - self.move_to_next_cycle() - self.test_instantsend_publishers() - self.move_to_next_cycle() - self.test_instantsend_publishers() - self.move_to_next_cycle() - self.test_instantsend_publishers() + self.generate(self.nodes[0], 24) self.mine_cycle_quorum() self.test_instantsend_publishers() finally: diff --git a/test/functional/p2p_instantsend.py b/test/functional/p2p_instantsend.py index 8fe878ebd5..ee1bc0cd48 100755 --- a/test/functional/p2p_instantsend.py +++ b/test/functional/p2p_instantsend.py @@ -25,13 +25,7 @@ class InstantSendTest(DashTestFramework): self.wait_for_sporks_same() self.activate_v19(expected_activation_height=900) self.log.info("Activated v19 at height:" + str(self.nodes[0].getblockcount())) - self.move_to_next_cycle() - self.log.info("Cycle H height:" + str(self.nodes[0].getblockcount())) - self.move_to_next_cycle() - self.log.info("Cycle H+C height:" + str(self.nodes[0].getblockcount())) - self.move_to_next_cycle() - self.log.info("Cycle H+2C height:" + str(self.nodes[0].getblockcount())) - (quorum_info_i_0, quorum_info_i_1) = self.mine_cycle_quorum(llmq_type_name='llmq_test_dip0024', llmq_type=103) + (quorum_info_i_0, quorum_info_i_1) = self.mine_cycle_quorum() self.test_mempool_doublespend() self.test_block_doublespend() diff --git a/test/functional/rpc_verifyislock.py b/test/functional/rpc_verifyislock.py index 93e9228dcf..94fe291e76 100755 --- a/test/functional/rpc_verifyislock.py +++ b/test/functional/rpc_verifyislock.py @@ -35,14 +35,7 @@ class RPCVerifyISLockTest(DashTestFramework): self.activate_v19(expected_activation_height=900) self.log.info("Activated v19 at height:" + str(self.nodes[0].getblockcount())) - self.move_to_next_cycle() - self.log.info("Cycle H height:" + str(self.nodes[0].getblockcount())) - self.move_to_next_cycle() - self.log.info("Cycle H+C height:" + str(self.nodes[0].getblockcount())) - self.move_to_next_cycle() - self.log.info("Cycle H+2C height:" + str(self.nodes[0].getblockcount())) - - self.mine_cycle_quorum(llmq_type_name='llmq_test_dip0024', llmq_type=103) + self.mine_cycle_quorum() self.bump_mocktime(1) self.generate(self.nodes[0], 8, sync_fun=self.sync_blocks()) @@ -64,7 +57,7 @@ class RPCVerifyISLockTest(DashTestFramework): assert node.verifyislock(request_id, txid, rec_sig, node.getblockcount() + 100) # Mine one more cycle of rotated quorums - self.mine_cycle_quorum(llmq_type_name='llmq_test_dip0024', llmq_type=103) + self.mine_cycle_quorum(is_first=False) # Create an ISLOCK using an active quorum which will be replaced when a new cycle happens request_id = None utxos = node.listunspent() @@ -87,7 +80,7 @@ class RPCVerifyISLockTest(DashTestFramework): # Create the ISDLOCK, then mine a cycle quorum to move renew active set isdlock = self.create_isdlock(rawtx) # Mine one block to trigger the "signHeight + dkgInterval" verification for the ISDLOCK - self.mine_cycle_quorum(llmq_type_name='llmq_test_dip0024', llmq_type=103) + self.mine_cycle_quorum(is_first=False) # Verify the ISLOCK for a transaction that is not yet known by the node rawtx_txid = node.decoderawtransaction(rawtx)["txid"] assert_raises_rpc_error(-5, "No such mempool or blockchain transaction", node.getrawtransaction, rawtx_txid) diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index 933cb31452..6aa7a4a53c 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -1895,31 +1895,32 @@ class DashTestFramework(BitcoinTestFramework): return new_quorum - def mine_cycle_quorum(self, llmq_type_name="llmq_test_dip0024", llmq_type=103, expected_connections=None, expected_members=None, expected_contributions=None, expected_complaints=0, expected_justifications=0, expected_commitments=None, mninfos_online=None): + def mine_cycle_quorum(self, is_first=True): spork21_active = self.nodes[0].spork('show')['SPORK_21_QUORUM_ALL_CONNECTED'] <= 1 spork23_active = self.nodes[0].spork('show')['SPORK_23_QUORUM_POSE'] <= 1 - if expected_connections is None: - expected_connections = (self.llmq_size_dip0024 - 1) if spork21_active else 2 - if expected_members is None: - expected_members = self.llmq_size_dip0024 - if expected_contributions is None: - expected_contributions = self.llmq_size_dip0024 - if expected_commitments is None: - expected_commitments = self.llmq_size_dip0024 - if mninfos_online is None: - mninfos_online = self.mninfo.copy() + llmq_type_name="llmq_test_dip0024" + llmq_type=103 + expected_connections = (self.llmq_size_dip0024 - 1) if spork21_active else 2 + expected_members = self.llmq_size_dip0024 + expected_contributions = self.llmq_size_dip0024 + expected_commitments = self.llmq_size_dip0024 + mninfos_online = self.mninfo.copy() + expected_complaints=0 + expected_justifications=0 - self.log.info("Mining quorum: expected_members=%d, expected_connections=%d, expected_contributions=%d, expected_complaints=%d, expected_justifications=%d, " - "expected_commitments=%d" % (expected_members, expected_connections, expected_contributions, expected_complaints, - expected_justifications, expected_commitments)) + self.log.info(f"Mining quorum: expected_members={expected_members}, expected_connections={expected_connections}, expected_contributions={expected_contributions}, expected_commitments={expected_commitments}, no complains and justfications expected") nodes = [self.nodes[0]] + [mn.node for mn in mninfos_online] - # move forward to next DKG - skip_count = 24 - (self.nodes[0].getblockcount() % 24) + cycle_length = 24 + cur_block = self.nodes[0].getblockcount() - self.move_blocks(nodes, skip_count) + skip_count = cycle_length - (cur_block % cycle_length) + # move forward to next 3 DKG rounds for the first quorum + extra_blocks = 24 * 3 if is_first else 0 + self.move_blocks(nodes, extra_blocks + skip_count) + self.log.info('Moved from block %d to %d' % (cur_block, self.nodes[0].getblockcount())) q_0 = self.nodes[0].getbestblockhash() self.log.info("Expected quorum_0 at:" + str(self.nodes[0].getblockcount())) @@ -2018,20 +2019,6 @@ class DashTestFramework(BitcoinTestFramework): return (quorum_info_0, quorum_info_1) - def move_to_next_cycle(self): - cycle_length = 24 - mninfos_online = self.mninfo.copy() - nodes = [self.nodes[0]] + [mn.node for mn in mninfos_online] - cur_block = self.nodes[0].getblockcount() - - # move forward to next DKG - skip_count = cycle_length - (cur_block % cycle_length) - if skip_count != 0: - self.bump_mocktime(1, nodes=nodes) - self.generate(self.nodes[0], skip_count, sync_fun=self.no_op) - self.sync_blocks(nodes) - self.log.info('Moved from block %d to %d' % (cur_block, self.nodes[0].getblockcount())) - def wait_for_recovered_sig(self, rec_sig_id, rec_sig_msg_hash, llmq_type=100, timeout=10): def check_recovered_sig(): self.bump_mocktime(1)