mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-28 23:08:52 +01:00
test: Use wait_until in tests where time was used for polling
This commit is contained in:
@@ -11,7 +11,6 @@ This test takes 30 mins or more (up to 2 hours)
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import *
|
||||
import time
|
||||
import os
|
||||
|
||||
MIN_BLOCKS_TO_KEEP = 288
|
||||
@@ -79,11 +78,8 @@ class PruneTest(BitcoinTestFramework):
|
||||
for i in range(25):
|
||||
mine_large_block(self.nodes[0], self.utxo_cache_0)
|
||||
|
||||
waitstart = time.time()
|
||||
while os.path.isfile(self.prunedir+"blk00000.dat"):
|
||||
time.sleep(0.1)
|
||||
if time.time() - waitstart > 30:
|
||||
raise AssertionError("blk00000.dat not pruned when it should be")
|
||||
# Wait for blk00000.dat to be pruned
|
||||
wait_until(lambda: not os.path.isfile(self.prunedir+"blk00000.dat"), timeout=30)
|
||||
|
||||
self.log.info("Success")
|
||||
usage = calc_usage(self.prunedir)
|
||||
@@ -218,11 +214,8 @@ class PruneTest(BitcoinTestFramework):
|
||||
goalbestheight = first_reorg_height + 1
|
||||
|
||||
self.log.info("Verify node 2 reorged back to the main chain, some blocks of which it had to redownload")
|
||||
waitstart = time.time()
|
||||
while self.nodes[2].getblockcount() < goalbestheight:
|
||||
time.sleep(0.1)
|
||||
if time.time() - waitstart > 900:
|
||||
raise AssertionError("Node 2 didn't reorg to proper height")
|
||||
# Wait for Node 2 to reorg to proper height
|
||||
wait_until(lambda: self.nodes[2].getblockcount() >= goalbestheight, timeout=900)
|
||||
assert(self.nodes[2].getbestblockhash() == goalbesthash)
|
||||
# Verify we can now have the data for a block previously pruned
|
||||
assert(self.nodes[2].getblock(self.forkhash)["height"] == self.forkheight)
|
||||
|
||||
Reference in New Issue
Block a user