Skip to content

Commit bfa3574

Browse files
committed
test: remove double delay 2second when it is sufficient to wait once in feature_llmq_is_retroactive.py
1 parent 2a77568 commit bfa3574

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

test/functional/feature_llmq_is_retroactive.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ def set_test_params(self):
2424
# -whitelist is needed to avoid the trickling logic on node0
2525
self.set_dash_test_params(5, 4, [["-whitelist=127.0.0.1"], [], [], [], ["-minrelaytxfee=0.001"]])
2626

27+
def check_no_is(self, txid, node):
28+
try:
29+
self.log.info(f"Expecting no InstantLock for {txid}")
30+
return node.getrawtransaction(txid, True)["instantlock"]
31+
except:
32+
return False
33+
34+
def sleep_and_check_no_is(self, txid, node, sleep):
35+
time.sleep(sleep)
36+
return self.check_no_is(node, txid)
37+
2738
# random delay before tx is actually send by network could take up to 30 seconds
2839
def wait_for_tx(self, txid, node, expected=True, timeout=60):
2940
def check_tx():
@@ -56,7 +67,7 @@ def run_test(self):
5667
# 3 nodes should be enough to create an IS lock even if nodes 4 and 5 (which have no tx itself)
5768
# are the only "neighbours" in intra-quorum connections for one of them.
5869
self.bump_mocktime(30)
59-
self.wait_for_instantlock(txid, self.nodes[0], False, 5)
70+
self.sleep_and_check_no_is(txid, self.nodes[0], 5)
6071
# Have to disable ChainLocks to avoid signing a block with a "safe" tx too early
6172
self.nodes[0].sporkupdate("SPORK_19_CHAINLOCKS_ENABLED", 4000000000)
6273
self.wait_for_sporks_same()
@@ -94,7 +105,7 @@ def run_test(self):
94105
self.bump_mocktime(30)
95106
self.wait_for_mnauth(self.nodes[3], 2)
96107
# node 3 fully reconnected but the TX wasn't relayed to it, so there should be no IS lock
97-
self.wait_for_instantlock(txid, self.nodes[0], False, 5)
108+
self.sleep_and_check_no_is(txid, self.nodes[0], 5)
98109
# push the tx directly via rpc
99110
self.nodes[3].sendrawtransaction(self.nodes[0].getrawtransaction(txid))
100111
# node 3 should vote on a tx now since it became aware of it via sendrawtransaction
@@ -125,7 +136,7 @@ def run_test(self):
125136
self.bump_mocktime(30)
126137
self.wait_for_mnauth(self.nodes[3], 2)
127138
# node 3 fully reconnected but the TX wasn't relayed to it, so there should be no IS lock
128-
self.wait_for_instantlock(txid, self.nodes[0], False, 5)
139+
self.sleep_and_check_no_is(txid, self.nodes[0], 5)
129140
# Make node0 consider the TX as safe
130141
self.bump_mocktime(10 * 60 + 1)
131142
block = self.generate(self.nodes[0], 1, sync_fun=self.no_op)[0]
@@ -168,19 +179,21 @@ def test_session_timeout(self, do_cycle_llmqs):
168179
self.wait_for_tx(txid_single_node, self.nodes[1])
169180
self.wait_for_tx(txid_single_node, self.nodes[2])
170181
self.bump_mocktime(30)
182+
171183
# Make sure signing is done on nodes 1 and 2 (it's async)
172184
time.sleep(5)
173185

174186
# node 3 fully reconnected but the signing session is already timed out, so no IS lock
175-
self.wait_for_instantlock(txid_all_nodes, self.nodes[0], False, 5)
176-
self.wait_for_instantlock(txid_single_node, self.nodes[0], False, 5)
187+
self.check_no_is(txid_all_nodes, self.nodes[0])
188+
self.check_no_is(txid_single_node, self.nodes[0])
177189
if do_cycle_llmqs:
178190
self.mine_cycle_quorum()
179191
self.mine_cycle_quorum()
180192
self.wait_for_chainlocked_block_all_nodes(self.nodes[0].getbestblockhash(), timeout=30)
181193

182-
self.wait_for_instantlock(txid_all_nodes, self.nodes[0], False, 5)
183-
self.wait_for_instantlock(txid_single_node, self.nodes[0], False, 5)
194+
time.sleep(5)
195+
self.check_no_is(txid_all_nodes, self.nodes[0])
196+
self.check_no_is(txid_single_node, self.nodes[0])
184197
# Make node 0 consider the TX as safe
185198
self.bump_mocktime(10 * 60 + 1)
186199
block = self.generate(self.nodes[0], 1, sync_fun=self.no_op)[0]

test/functional/test_framework/test_framework.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,7 +1930,7 @@ def create_isdlock(self, hextx):
19301930
# due to privacy reasons random delay is used before sending transaction by network
19311931
# most times is just 2-5 seconds, but once in 1000 it's up to 1000 seconds.
19321932
# it's recommended to bump mocktime for 30 seconds before wait_for_instantlock
1933-
def wait_for_instantlock(self, txid, node, expected=True, timeout=60):
1933+
def wait_for_instantlock(self, txid, node, timeout=60):
19341934

19351935
def check_instantlock():
19361936
try:
@@ -1939,8 +1939,7 @@ def check_instantlock():
19391939
return False
19401940

19411941
self.log.info(f"Expecting InstantLock for {txid}")
1942-
if self.wait_until(check_instantlock, timeout=timeout, do_assert=expected) and not expected:
1943-
raise AssertionError("waiting unexpectedly succeeded")
1942+
self.wait_until(check_instantlock, timeout=timeout)
19441943

19451944
def wait_for_chainlocked_block(self, node, block_hash, expected=True, timeout=15):
19461945
def check_chainlocked_block():

0 commit comments

Comments
 (0)