|
11 | 11 |
|
12 | 12 | from test_framework.test_framework import BitcoinTestFramework |
13 | 13 | from test_framework.util import * |
14 | | -import time |
15 | 14 | import os |
16 | 15 |
|
17 | 16 | MIN_BLOCKS_TO_KEEP = 288 |
@@ -79,11 +78,8 @@ def test_height_min(self): |
79 | 78 | for i in range(25): |
80 | 79 | mine_large_block(self.nodes[0], self.utxo_cache_0) |
81 | 80 |
|
82 | | - waitstart = time.time() |
83 | | - while os.path.isfile(self.prunedir+"blk00000.dat"): |
84 | | - time.sleep(0.1) |
85 | | - if time.time() - waitstart > 30: |
86 | | - raise AssertionError("blk00000.dat not pruned when it should be") |
| 81 | + # Wait for blk00000.dat to be pruned |
| 82 | + wait_until(lambda: not os.path.isfile(self.prunedir+"blk00000.dat"), timeout=30) |
87 | 83 |
|
88 | 84 | self.log.info("Success") |
89 | 85 | usage = calc_usage(self.prunedir) |
@@ -218,11 +214,8 @@ def reorg_back(self): |
218 | 214 | goalbestheight = first_reorg_height + 1 |
219 | 215 |
|
220 | 216 | self.log.info("Verify node 2 reorged back to the main chain, some blocks of which it had to redownload") |
221 | | - waitstart = time.time() |
222 | | - while self.nodes[2].getblockcount() < goalbestheight: |
223 | | - time.sleep(0.1) |
224 | | - if time.time() - waitstart > 900: |
225 | | - raise AssertionError("Node 2 didn't reorg to proper height") |
| 217 | + # Wait for Node 2 to reorg to proper height |
| 218 | + wait_until(lambda: self.nodes[2].getblockcount() >= goalbestheight, timeout=900) |
226 | 219 | assert(self.nodes[2].getbestblockhash() == goalbesthash) |
227 | 220 | # Verify we can now have the data for a block previously pruned |
228 | 221 | assert(self.nodes[2].getblock(self.forkhash)["height"] == self.forkheight) |
|
0 commit comments