Skip to content

Commit 0f6cf13

Browse files
committed
refactor: wait 5seconds only once but not for each node in feature_llmq_chainlocks.py
1 parent 873dee0 commit 0f6cf13

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

test/functional/feature_llmq_chainlocks.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,22 @@
1616
from test_framework.test_framework import DashTestFramework
1717
from test_framework.util import assert_equal, assert_raises_rpc_error, force_finish_mnsync
1818

19+
import time
1920

2021
class LLMQChainLocksTest(DashTestFramework):
2122
def set_test_params(self):
2223
self.set_dash_test_params(5, 4)
2324
self.delay_v20_and_mn_rr(height=200)
2425

26+
def sleep_and_assert_no_cl(self, block_hash):
27+
time.sleep(5)
28+
29+
for node in self.nodes:
30+
self.log.info(f"Expecting no ChainLock for {block_hash}")
31+
block = node.getblock(block_hash)
32+
#assert_equal(block["confirmations"], 0)
33+
assert not block["chainlock"]
34+
2535
def run_test(self):
2636
# Connect all nodes to node1 so that we always have the whole network connected
2737
# Otherwise only masternode connections will be established between nodes, which won't propagate TXs/blocks
@@ -84,7 +94,7 @@ def run_test(self):
8494
previous_block_hash = self.nodes[0].getbestblockhash()
8595
for _ in range(2):
8696
block_hash = self.generate(self.nodes[0], 1, sync_fun=self.no_op)[0]
87-
self.wait_for_chainlocked_block_all_nodes(block_hash, timeout=5, expected=False)
97+
self.sleep_and_assert_no_cl(block_hash)
8898
assert self.nodes[0].getblock(previous_block_hash)["chainlock"]
8999

90100
self.nodes[0].sporkupdate("SPORK_19_CHAINLOCKS_ENABLED", 0)

test/functional/test_framework/test_framework.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,9 +1953,9 @@ def check_chainlocked_block():
19531953
if self.wait_until(check_chainlocked_block, timeout=timeout, do_assert=expected) and not expected:
19541954
raise AssertionError("waiting unexpectedly succeeded")
19551955

1956-
def wait_for_chainlocked_block_all_nodes(self, block_hash, timeout=15, expected=True):
1956+
def wait_for_chainlocked_block_all_nodes(self, block_hash, timeout=15):
19571957
for node in self.nodes:
1958-
self.wait_for_chainlocked_block(node, block_hash, expected=expected, timeout=timeout)
1958+
self.wait_for_chainlocked_block(node, block_hash, timeout=timeout)
19591959

19601960
def wait_for_best_chainlock(self, node, block_hash, timeout=15):
19611961
self.wait_until(lambda: node.getbestchainlock()["blockhash"] == block_hash, timeout=timeout)

0 commit comments

Comments
 (0)