Skip to content

Commit 32d35b1

Browse files
committed
test: replace argument is_first to global flag to see if cycle quorum is ready
This flag is easy to forget and if it is forgotten, everything works as expected, but extra 24 * 3 useless blocks are generated for each
1 parent bfa3574 commit 32d35b1

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

test/functional/feature_llmq_connections.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def run_test(self):
8888
try:
8989
with mn.get_node(self).assert_debug_log(['removing masternodes quorum connections']):
9090
with mn.get_node(self).assert_debug_log(['keeping mn quorum connections']):
91-
self.mine_cycle_quorum(is_first=False)
91+
self.mine_cycle_quorum()
9292
mn.get_node(self).mockscheduler(60) # we check for old connections via the scheduler every 60 seconds
9393
removed = True
9494
except:
@@ -103,7 +103,7 @@ def run_test(self):
103103
if len(mn.get_node(self).quorum("memberof", mn.proTxHash)) > 0:
104104
try:
105105
with mn.get_node(self).assert_debug_log(['adding mn inter-quorum connections']):
106-
self.mine_cycle_quorum(is_first=False)
106+
self.mine_cycle_quorum()
107107
added = True
108108
except:
109109
pass # it's ok to not add connections sometimes

test/functional/feature_llmq_rotation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ def run_test(self):
135135
self.log.info("Cycle H+2C height:" + str(self.nodes[0].getblockcount()))
136136
self.log.info("Wait for chainlock")
137137
self.wait_for_chainlocked_block_all_nodes(self.nodes[0].getbestblockhash())
138+
self.cycle_quorum_is_ready = True
138139

139140
b_0 = self.nodes[0].getbestblockhash()
140141

@@ -150,8 +151,7 @@ def run_test(self):
150151
self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_blocks(nodes))
151152
self.wait_for_chainlocked_block_all_nodes(self.nodes[0].getbestblockhash())
152153

153-
154-
(quorum_info_0_0, quorum_info_0_1) = self.mine_cycle_quorum(is_first=False)
154+
(quorum_info_0_0, quorum_info_0_1) = self.mine_cycle_quorum()
155155
assert(self.test_quorum_listextended(quorum_info_0_0, llmq_type_name))
156156
assert(self.test_quorum_listextended(quorum_info_0_1, llmq_type_name))
157157
quorum_members_0_0 = extract_quorum_members(quorum_info_0_0)
@@ -173,7 +173,7 @@ def run_test(self):
173173
self.log.info("Wait for chainlock")
174174
self.wait_for_chainlocked_block_all_nodes(self.nodes[0].getbestblockhash())
175175

176-
(quorum_info_1_0, quorum_info_1_1) = self.mine_cycle_quorum(is_first=False)
176+
(quorum_info_1_0, quorum_info_1_1) = self.mine_cycle_quorum()
177177
assert(self.test_quorum_listextended(quorum_info_1_0, llmq_type_name))
178178
assert(self.test_quorum_listextended(quorum_info_1_1, llmq_type_name))
179179
quorum_members_1_0 = extract_quorum_members(quorum_info_1_0)
@@ -207,7 +207,7 @@ def run_test(self):
207207
self.wait_for_chainlocked_block_all_nodes(self.nodes[0].getbestblockhash())
208208

209209
self.log.info("Mine a quorum to invalidate")
210-
(quorum_info_3_0, quorum_info_3_1) = self.mine_cycle_quorum(is_first=False)
210+
(quorum_info_3_0, quorum_info_3_1) = self.mine_cycle_quorum()
211211

212212
new_quorum_list = self.nodes[0].quorum("list", llmq_type)
213213
assert_equal(len(new_quorum_list[llmq_type_name]), len(quorum_list[llmq_type_name]) + 2)

test/functional/rpc_verifyislock.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def run_test(self):
5858
assert node.verifyislock(request_id, txid, rec_sig, node.getblockcount() + 100)
5959

6060
# Mine one more cycle of rotated quorums
61-
self.mine_cycle_quorum(is_first=False)
61+
self.mine_cycle_quorum()
6262
# Create an ISLOCK using an active quorum which will be replaced when a new cycle happens
6363
request_id = None
6464
utxos = node.listunspent()
@@ -81,7 +81,7 @@ def run_test(self):
8181
# Create the ISDLOCK, then mine a cycle quorum to move renew active set
8282
isdlock = self.create_isdlock(rawtx)
8383
# Mine one block to trigger the "signHeight + dkgInterval" verification for the ISDLOCK
84-
self.mine_cycle_quorum(is_first=False)
84+
self.mine_cycle_quorum()
8585
# Verify the ISLOCK for a transaction that is not yet known by the node
8686
rawtx_txid = node.decoderawtransaction(rawtx)["txid"]
8787
assert_raises_rpc_error(-5, "No such mempool or blockchain transaction", node.getrawtransaction, rawtx_txid)

test/functional/test_framework/test_framework.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,6 +1529,8 @@ def set_dash_test_params(self, num_nodes, masterodes_count, extra_args=None, evo
15291529
# This is EXPIRATION_TIMEOUT + EXPIRATION_BIAS in CQuorumDataRequest
15301530
self.quorum_data_request_expiration_timeout = 360
15311531

1532+
# used by helper mine_cycle_quorum
1533+
self.cycle_quorum_is_ready = False
15321534

15331535
def delay_v20_and_mn_rr(self, height=None):
15341536
self.v20_height = height
@@ -2194,7 +2196,7 @@ def mine_quorum(self, llmq_type_name="llmq_test", llmq_type=100, expected_connec
21942196

21952197
return new_quorum
21962198

2197-
def mine_cycle_quorum(self, is_first=True):
2199+
def mine_cycle_quorum(self):
21982200
spork21_active = self.nodes[0].spork('show')['SPORK_21_QUORUM_ALL_CONNECTED'] <= 1
21992201
spork23_active = self.nodes[0].spork('show')['SPORK_23_QUORUM_POSE'] <= 1
22002202

@@ -2217,10 +2219,12 @@ def mine_cycle_quorum(self, is_first=True):
22172219

22182220
skip_count = cycle_length - (cur_block % cycle_length)
22192221
# move forward to next 3 DKG rounds for the first quorum
2220-
extra_blocks = 24 * 3 if is_first else 0
2222+
extra_blocks = 0 if self.cycle_quorum_is_ready else 24 * 3
22212223
self.move_blocks(nodes, extra_blocks + skip_count)
22222224
self.log.info('Moved from block %d to %d' % (cur_block, self.nodes[0].getblockcount()))
22232225

2226+
self.cycle_quorum_is_ready = True
2227+
22242228
q_0 = self.nodes[0].getbestblockhash()
22252229
self.log.info("Expected quorum_0 at:" + str(self.nodes[0].getblockcount()))
22262230
self.log.info("Expected quorum_0 hash:" + str(q_0))

0 commit comments

Comments
 (0)