|
23 | 23 | wait_until, |
24 | 24 | ) |
25 | 25 |
|
26 | | -MIN_BLOCKS_TO_KEEP = 288 |
27 | | - |
28 | 26 | # Rescans start at the earliest block up to 2 hours before a key timestamp, so |
29 | 27 | # the manual prune RPC avoids pruning blocks in the same window to be |
30 | 28 | # compatible with pruning based on key creation time. |
@@ -273,20 +271,9 @@ def height(index): |
273 | 271 | else: |
274 | 272 | return index |
275 | 273 |
|
276 | | - def prune(index, expected_ret=None): |
| 274 | + def prune(index): |
277 | 275 | ret = node.pruneblockchain(height=height(index)) |
278 | | - # Check the return value. When use_timestamp is True, just check |
279 | | - # that the return value is less than or equal to the expected |
280 | | - # value, because when more than one block is generated per second, |
281 | | - # a timestamp will not be granular enough to uniquely identify an |
282 | | - # individual block. |
283 | | - if expected_ret is None: |
284 | | - expected_ret = index |
285 | | - if use_timestamp: |
286 | | - assert_greater_than(ret, 0) |
287 | | - assert_greater_than(expected_ret + 1, ret) |
288 | | - else: |
289 | | - assert_equal(ret, expected_ret) |
| 276 | + assert_equal(ret, node.getblockchaininfo()['pruneheight']) |
290 | 277 |
|
291 | 278 | def has_block(index): |
292 | 279 | return os.path.isfile(os.path.join(self.nodes[node_number].datadir, "regtest", "blocks", "blk{:05}.dat".format(index))) |
@@ -326,7 +313,7 @@ def has_block(index): |
326 | 313 | assert not has_block(1), "blk00001.dat is still there, should be pruned by now" |
327 | 314 |
|
328 | 315 | # height=1000 should not prune anything more, because tip-288 is in blk00002.dat. |
329 | | - prune(1000, 1001 - MIN_BLOCKS_TO_KEEP) |
| 316 | + prune(1000) |
330 | 317 | assert has_block(2), "blk00002.dat is still there, should be pruned by now" |
331 | 318 |
|
332 | 319 | # advance the tip so blk00002.dat and blk00003.dat can be pruned (the last 288 blocks should now be in blk00004.dat) |
|
0 commit comments