Skip to content

Commit

Permalink
test: speed up functional test feature_llmq_chainlocks.py
Browse files Browse the repository at this point in the history
  • Loading branch information
knst committed Jan 6, 2025
1 parent a5787c9 commit 0219735
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions test/functional/feature_llmq_chainlocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
'''

import time
from io import BytesIO

from test_framework.messages import CBlock, CCbTx
Expand Down Expand Up @@ -84,7 +83,7 @@ def run_test(self):
previous_block_hash = self.nodes[0].getbestblockhash()
for _ in range(2):
block_hash = self.generate(self.nodes[0], 1, sync_fun=self.no_op)[0]
self.wait_for_chainlocked_block_all_nodes(block_hash, expected=False)
self.wait_for_chainlocked_block_all_nodes(block_hash, timeout=5, expected=False)
assert self.nodes[0].getblock(previous_block_hash)["chainlock"]

self.nodes[0].sporkupdate("SPORK_19_CHAINLOCKS_ENABLED", 0)
Expand Down Expand Up @@ -157,12 +156,10 @@ def run_test(self):
self.nodes[0].invalidateblock(good_tip)
self.log.info("Now try to reorg the chain")
self.generate(self.nodes[0], 2, sync_fun=self.no_op)
time.sleep(6)
assert self.nodes[1].getbestblockhash() == good_tip
self.wait_until(lambda: self.nodes[1].getbestblockhash() == good_tip, timeout=6)
bad_tip = self.generate(self.nodes[0], 2, sync_fun=self.no_op)[-1]
time.sleep(6)
assert self.nodes[0].getbestblockhash() == bad_tip
assert self.nodes[1].getbestblockhash() == good_tip
self.wait_until(lambda: self.nodes[1].getbestblockhash() == good_tip and
self.nodes[0].getbestblockhash() == bad_tip, timeout=6)

self.log.info("Now let the node which is on the wrong chain reorg back to the locked chain")
self.nodes[0].reconsiderblock(good_tip)
Expand All @@ -185,8 +182,7 @@ def run_test(self):
self.restart_node(0)
self.nodes[0].invalidateblock(good_fork)
self.restart_node(0)
time.sleep(1)
assert self.nodes[0].getbestblockhash() == good_tip
self.wait_until(lambda: self.nodes[0].getbestblockhash() == good_tip, timeout=5)

self.log.info("Isolate a node and let it create some transactions which won't get IS locked")
force_finish_mnsync(self.nodes[0])
Expand All @@ -200,10 +196,15 @@ def run_test(self):
for txid in txs:
tx = self.nodes[0].getrawtransaction(txid, 1)
assert "confirmations" not in tx
time.sleep(1)
node0_tip_block = self.nodes[0].getblock(node0_tip)
assert not node0_tip_block["chainlock"]
assert node0_tip_block["previousblockhash"] == good_tip

def test_cb(self):
node0_tip_block = self.nodes[0].getblock(node0_tip)
if node0_tip_block["chainlock"]:
return False
return node0_tip_block["previousblockhash"] == good_tip
self.wait_until(lambda: test_cb(self), timeout=5)


self.log.info("Disable LLMQ based InstantSend for a very short time (this never gets propagated to other nodes)")
self.nodes[0].sporkupdate("SPORK_2_INSTANTSEND_ENABLED", 4070908800)
self.log.info("Now the TXs should be included")
Expand Down

0 comments on commit 0219735

Please sign in to comment.