Skip to content

Commit fa6f678

Browse files
author
721217.xyz
committed
test: Fix intermittent sync issue in wallet_pruning
1 parent dc905f6 commit fa6f678

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

test/functional/wallet_pruning.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,15 @@ def skip_test_if_missing_module(self):
3939

4040
def mine_large_blocks(self, node, n):
4141
# Get the block parameters for the first block
42-
best_block = node.getblock(node.getbestblockhash())
42+
best_block = node.getblockheader(node.getbestblockhash())
4343
height = int(best_block["height"]) + 1
4444
self.nTime = max(self.nTime, int(best_block["time"])) + 1
4545
previousblockhash = int(best_block["hash"], 16)
4646
big_script = CScript([OP_RETURN] + [OP_TRUE] * 950000)
47+
# Set mocktime to accept all future blocks
48+
for i in self.nodes:
49+
if i.running:
50+
i.setmocktime(self.nTime + 600 * n)
4751
for _ in range(n):
4852
block = create_block(hashprev=previousblockhash, ntime=self.nTime, coinbase=create_coinbase(height, script_pubkey=big_script))
4953
block.solve()
@@ -57,9 +61,6 @@ def mine_large_blocks(self, node, n):
5761
# Simulate 10 minutes of work time per block
5862
# Important for matching a timestamp with a block +- some window
5963
self.nTime += 600
60-
for n in self.nodes:
61-
if n.running:
62-
n.setmocktime(self.nTime) # Update node's time to accept future blocks
6364
self.sync_all()
6465

6566
def test_wallet_import_pruned(self, wallet_name):

0 commit comments

Comments
 (0)