Skip to content

Commit e2264b5

Browse files
committed
test: follow-up for #7812: use less fixture to test quorum dkgstatus
- Rotation test. The existing check after the DKG finishes now asserts 0 for each masternode. It no longer sums the stale debug sessions. The PR's two added scenarios are removed. - rpc_quorum.py. It now mines to the next DKG start block while the DKG spork is still off. Then it asserts the masternode's active_dkgs is above 0, before turning the spork on. The PR's separate scenario is removed. - test_framework.py. The helper that only the removed scenarios used is gone.
1 parent 3ac0244 commit e2264b5

3 files changed

Lines changed: 3 additions & 93 deletions

File tree

‎test/functional/feature_llmq_rotation.py‎

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ def run_test(self):
8181
llmq_type_name="llmq_test_dip0024"
8282

8383
self.test_node = self.nodes[0].add_p2p_connection(TestP2PConn())
84-
self.test_unknown_active_membership()
8584

8685
# Connect all nodes to node1 so that we always have the whole network connected
8786
# Otherwise only masternode connections will be established between nodes, which won't propagate TXs/blocks
@@ -119,13 +118,10 @@ def run_test(self):
119118
tip = self.nodes[0].getblockcount()
120119
next_dkg = 24 - (tip % 24)
121120
assert next_dkg < 24
122-
stale_sessions = 0
123121
for mn in self.mninfo:
124122
dkg_info = mn.get_node(self).quorum("dkginfo")
125123
assert_equal(dkg_info['active_dkgs'], 0)
126-
stale_sessions += len(mn.get_node(self).quorum("dkgstatus")["session"])
127124
assert_equal(dkg_info['next_dkg'], next_dkg)
128-
assert stale_sessions > 0 # Expired debug sessions do not contribute to the count.
129125

130126
expectedDeleted = []
131127
expectedNew = [h_100_0, h_100_1]
@@ -281,52 +277,6 @@ def run_test(self):
281277
assert_equal(rpc_qr_info["mnListDiffAtHMinus3C"]["baseBlockHash"], genesis_blockhash)
282278

283279
self.test_getqrinfo_base_block_hashes_limit(int(best_block_hash, 16), int(hmc_base_blockhash, 16))
284-
self.test_active_rotated_membership()
285-
286-
def test_unknown_active_membership(self):
287-
self.log.info("Unknown active membership is counted conservatively before v20")
288-
self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 4070908800)
289-
self.wait_for_sporks_same()
290-
tip = self.nodes[0].getblockcount()
291-
start_height = tip + 24 - tip % 24
292-
assert start_height < self.v20_height
293-
self.generate(self.nodes[0], start_height - tip - 1)
294-
node = self.mninfo[0].get_node(self)
295-
upcoming = node.quorum("dkginfo")["upcoming_dkgs"]
296-
assert upcoming
297-
assert all(d["reason"] == "pre-v20 quorum selection needs future quorum base block hash" for d in upcoming)
298-
self.generate(self.nodes[0], 1)
299-
info = node.quorum("dkginfo")
300-
assert info["active_dkgs"] > 0
301-
assert_equal(info["active_dkgs"], self.expected_active_dkgs(upcoming, start_height))
302-
assert_equal(node.quorum("dkgstatus")["session"], [])
303-
self.generate(self.nodes[0], 13)
304-
assert_equal(node.quorum("dkginfo")["active_dkgs"], 0)
305-
306-
def test_active_rotated_membership(self):
307-
self.log.info("Active rotated membership is counted without DKG initialization")
308-
self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 4070908800)
309-
self.wait_for_sporks_same()
310-
node = self.mninfo[0].get_node(self)
311-
tip = self.nodes[0].getblockcount()
312-
start_height = tip + 24 - tip % 24
313-
self.generate(self.nodes[0], start_height - tip - 1)
314-
upcoming = {mn.proTxHash: node.quorum("dkginfo", mn.proTxHash)["upcoming_dkgs"] for mn in self.mninfo}
315-
316-
# Each index's Commit phase ends after 10 blocks, independently of the
317-
# shared mining window starting 12 blocks after the cycle base.
318-
for offset in (0, 1, 9, 10, 11, 12, 13):
319-
height = start_height + offset
320-
self.generate(self.nodes[0], height - self.nodes[0].getblockcount())
321-
counts = [node.quorum("dkginfo", mn.proTxHash)["active_dkgs"] for mn in self.mninfo]
322-
assert_equal(counts, [self.expected_active_dkgs(upcoming[mn.proTxHash], height) for mn in self.mninfo])
323-
# All other enabled regtest types share the cycle base, so only index 1 remains at offset 10.
324-
if offset == 10:
325-
assert sum(counts) > 0
326-
elif offset > 10:
327-
assert_equal(sum(counts), 0)
328-
sessions = node.quorum("dkgstatus")["session"]
329-
assert all(d["status"]["quorumHeight"] < start_height for d in sessions)
330280

331281
def test_duplicate_rotated_commitment(self, quorum_info, llmq_type):
332282
self.log.info("A block mining one rotated commitment twice instead of its sibling is rejected")

‎test/functional/rpc_quorum.py‎

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ def set_test_params(self):
2525
self.set_dash_llmq_test_params(1, 1)
2626

2727
def run_test(self):
28-
self.test_active_dkg_membership()
29-
28+
self.mine_until_mns_confirmed_for_next_dkg()
29+
self.generate(self.nodes[0], 24 - self.nodes[0].getblockcount() % 24)
30+
assert self.mninfo[0].get_node(self).quorum("dkginfo")["active_dkgs"] > 0 # DKG is still disabled by spork
3031
self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 0)
3132
self.wait_for_sporks_same()
3233
self.mine_until_mns_confirmed_for_next_dkg()
@@ -39,41 +40,5 @@ def run_test(self):
3940
if member["proTxHash"] == mn.proTxHash:
4041
assert_equal(member['addresses']['core_p2p'][0], f'127.0.0.1:{mn.nodePort}')
4142

42-
def test_active_dkg_membership(self):
43-
# Keep DKG disabled so no local session record can hide a reporting gap.
44-
# Membership must remain counted for the whole current window anyway.
45-
self.nodes[0].sporkupdate("SPORK_17_QUORUM_DKG_ENABLED", 4070908800)
46-
self.wait_for_sporks_same()
47-
self.mine_until_mns_confirmed_for_next_dkg()
48-
mn = self.mninfo[0]
49-
node = mn.get_node(self)
50-
other = "01" * 32
51-
tip = self.nodes[0].getblockcount()
52-
start_height = tip + 24 - tip % 24
53-
self.generate(self.nodes[0], start_height - tip - 1)
54-
info = node.quorum("dkginfo")
55-
assert_equal(info["active_dkgs"], 0)
56-
upcoming = info["upcoming_dkgs"]
57-
other_upcoming = node.quorum("dkginfo", other)["upcoming_dkgs"]
58-
[llmq_test] = [d for d in upcoming if d["llmqType"] == 100]
59-
assert_equal(llmq_test["blocksUntilStart"], 1)
60-
assert_equal(llmq_test["known"], True)
61-
assert_equal(llmq_test["isMember"], True)
62-
[other_llmq_test] = [d for d in other_upcoming if d["llmqType"] == 100]
63-
assert_equal(other_llmq_test["known"], True)
64-
assert_equal(other_llmq_test["isMember"], False)
65-
66-
for offset in (0, 1, 9, 10):
67-
height = start_height + offset
68-
self.generate(self.nodes[0], height - self.nodes[0].getblockcount())
69-
info = node.quorum("dkginfo")
70-
if offset < 10:
71-
assert info["active_dkgs"] > 0
72-
assert_equal(info["active_dkgs"], self.expected_active_dkgs(upcoming, height))
73-
assert_equal(node.quorum("dkginfo", other)["active_dkgs"], self.expected_active_dkgs(other_upcoming, height))
74-
assert_equal(node.quorum("dkgstatus")["session"], [])
75-
assert all(d["blocksUntilStart"] > 0 for d in info["upcoming_dkgs"])
76-
77-
7843
if __name__ == '__main__':
7944
RPCMasternodeTest().main()

‎test/functional/test_framework/test_framework.py‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2218,11 +2218,6 @@ def get_upcoming_dkg_predictions(self, node, llmq_type):
22182218
if d["llmqType"] == llmq_type]
22192219
for mn in self.mninfo}
22202220

2221-
def expected_active_dkgs(self, upcoming, height):
2222-
# 'quorum dkginfo' active_dkgs at height from earlier upcoming_dkgs entries. Every regtest
2223-
# LLMQ type has dkgPhaseBlocks = 2, so a session is active through Commit for 10 blocks.
2224-
return sum(0 <= height - d["quorumHeight"] < 10 and (not d["known"] or d["isMember"]) for d in upcoming)
2225-
22262221
def verify_upcoming_dkg_predictions(self, predictions, quorum_info):
22272222
# 'quorum info' lists members in member-index order
22282223
members = [m["proTxHash"] for m in quorum_info["members"]]

0 commit comments

Comments
 (0)