Skip to content

Commit 1821cef

Browse files
thepastaclawclaude
andcommitted
test: reuse single-member quorum helper in feature_llmq_singlenode
Address review feedback on mine_quorum_single_member: - Drop the unused skip_maturity parameter; no caller sets it, so the quorum is always matured. - Mine a full DKG cycle per iteration instead of one block at a time. A single-member DKG has no phase/connection waits, so a batched generate reaches the commitment's mining window far more cheaply. - Replace feature_llmq_singlenode.py's local mine_single_node_quorum with the shared helper (and drop the now-unused time import). - Remove quorumIndex (and the now-constant is_mature) from the log; quorumIndex is meaningless for the non-rotating llmq_test quorum. All assertions and test semantics are preserved. rpc_quorum.py, rpc_verifychainlock.py, and feature_llmq_singlenode.py all pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent ea6794e commit 1821cef

2 files changed

Lines changed: 15 additions & 32 deletions

File tree

test/functional/feature_llmq_singlenode.py

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
1212
'''
1313

14-
import time
15-
1614
from test_framework.authproxy import JSONRPCException
1715
from test_framework.test_framework import (
1816
DashTestFramework,
@@ -40,21 +38,6 @@ def set_test_params(self):
4038
evo_count=2)
4139
self.set_dash_llmq_test_params(1, 1)
4240

43-
def mine_single_node_quorum(self):
44-
node = self.nodes[0]
45-
quorums = node.quorum('list')['llmq_test']
46-
47-
skip_count = 24 - (self.nodes[0].getblockcount() % 24)
48-
if skip_count != 0:
49-
self.bump_mocktime(1)
50-
self.generate(self.nodes[0], skip_count)
51-
time.sleep(1)
52-
self.generate(self.nodes[0], 30)
53-
new_quorums_list = node.quorum('list')['llmq_test']
54-
55-
self.log.info(f"Test Quorums at height={node.getblockcount()} : {new_quorums_list}")
56-
assert new_quorums_list != quorums
57-
5841
def check_sigs(self, hasrecsigs, isconflicting1, isconflicting2):
5942
has_sig = False
6043
conflicting_1 = False
@@ -97,7 +80,7 @@ def run_test(self):
9780
self.dynamically_add_masternode(evo=True)
9881
self.connect_nodes(1, 2)
9982

100-
self.mine_single_node_quorum()
83+
self.mine_quorum_single_member()
10184

10285
self.log_connections()
10386
assert_greater_than(len(self.nodes[0].quorum('list')['llmq_test']), 0)
@@ -158,13 +141,13 @@ def run_test(self):
158141
assert_raises_rpc_error(-8, "quorum not found", node.quorum, "verify", q_type, id, msgHash, recsig["sig"], hash_bad)
159142

160143
self.log.info("Mine one more quorum, so that we have 2 active ones, nothing should change")
161-
self.mine_single_node_quorum()
144+
self.mine_quorum_single_member()
162145
self.assert_sigs_nochange(True, False, True, 3)
163146

164147

165148
self.log.info("Mine 2 more quorums, so that the one used for the the recovered sig should become inactive, nothing should change")
166-
self.mine_single_node_quorum()
167-
self.mine_single_node_quorum()
149+
self.mine_quorum_single_member()
150+
self.mine_quorum_single_member()
168151
self.assert_sigs_nochange(True, False, True, 3)
169152

170153
self.log_connections()

test/functional/test_framework/test_framework.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,14 +2229,14 @@ def mine_quorum(self, llmq_type_name="llmq_test", llmq_type=100, expected_connec
22292229

22302230
return new_quorum
22312231

2232-
def mine_quorum_single_member(self, llmq_type_name="llmq_test", llmq_type=100, skip_maturity=False):
2232+
def mine_quorum_single_member(self, llmq_type_name="llmq_test", llmq_type=100):
22332233
"""Mine a single-member (llmq_size == 1) quorum and return its hash.
22342234
22352235
A drop-in for mine_quorum in single-member tests. mine_quorum can't be
22362236
reused here: a one-member DKG has no inter-member connections or probes,
22372237
so its phase/connection waits never complete. Instead advance to the next
2238-
DKG cycle and generate until the quorum is listed, then mature it.
2239-
Mirrors feature_llmq_singlenode.py.
2238+
DKG cycle and mine a full cycle so the commitment is carried through its
2239+
mining window, then mature the quorum. Mirrors feature_llmq_singlenode.py.
22402240
"""
22412241
assert_equal(self.llmq_size, 1)
22422242
node = self.nodes[0]
@@ -2249,23 +2249,23 @@ def mine_quorum_single_member(self, llmq_type_name="llmq_test", llmq_type=100, s
22492249
self.bump_mocktime(1)
22502250
self.generate(node, skip_count)
22512251

2252-
# Generate through the DKG window until a new quorum is mined and listed.
2252+
# Mine through the DKG window a whole cycle at a time until the new
2253+
# quorum is mined and listed. A single-member DKG needs no phase waits,
2254+
# so a batched generate is enough (and far cheaper than block-by-block).
22532255
def new_quorum_mined():
22542256
self.bump_mocktime(1)
2255-
self.generate(node, 1)
2257+
self.generate(node, llmq_cycle_len)
22562258
return len(set(node.quorum("list")[llmq_type_name]) - quorums) > 0
22572259
self.wait_until(new_quorum_mined, timeout=60, sleep=0)
22582260

22592261
new_quorum = (set(node.quorum("list")[llmq_type_name]) - quorums).pop()
22602262
quorum_info = node.quorum("info", llmq_type, new_quorum)
22612263

2262-
if not skip_maturity:
2263-
# Mine 8 (SIGN_HEIGHT_OFFSET) more blocks so the new quorum is eligible for signing.
2264-
self.generate(node, 8)
2264+
# Mine 8 (SIGN_HEIGHT_OFFSET) more blocks so the new quorum is eligible for signing.
2265+
self.generate(node, 8)
22652266

2266-
self.log.info(f"New single-member quorum: height={quorum_info['height']}, quorumHash={new_quorum}, "
2267-
f"is_mature={not skip_maturity}, quorumIndex={quorum_info['quorumIndex']}, "
2268-
f"minedBlock={quorum_info['minedBlock']}")
2267+
self.log.info(f"New single-member quorum: height={quorum_info['height']}, "
2268+
f"quorumHash={new_quorum}, minedBlock={quorum_info['minedBlock']}")
22692269
return new_quorum
22702270

22712271
def mine_cycle_quorum(self):

0 commit comments

Comments
 (0)