|
10 | 10 | """ |
11 | 11 |
|
12 | 12 | from test_framework.test_framework import BitcoinTestFramework |
13 | | -from test_framework.util import assert_equal, assert_greater_than, assert_raises_rpc_error, connect_nodes, mine_large_block, sync_blocks, wait_until |
| 13 | +from test_framework.util import assert_equal, assert_raises_rpc_error, connect_nodes, mine_large_block, sync_blocks, wait_until |
14 | 14 |
|
15 | 15 | import os |
16 | 16 |
|
17 | | -MIN_BLOCKS_TO_KEEP = 288 |
18 | | - |
19 | 17 | # Rescans start at the earliest block up to 2 hours before a key timestamp, so |
20 | 18 | # the manual prune RPC avoids pruning blocks in the same window to be |
21 | 19 | # compatible with pruning based on key creation time. |
@@ -250,20 +248,9 @@ def height(index): |
250 | 248 | else: |
251 | 249 | return index |
252 | 250 |
|
253 | | - def prune(index, expected_ret=None): |
| 251 | + def prune(index): |
254 | 252 | ret = node.pruneblockchain(height=height(index)) |
255 | | - # Check the return value. When use_timestamp is True, just check |
256 | | - # that the return value is less than or equal to the expected |
257 | | - # value, because when more than one block is generated per second, |
258 | | - # a timestamp will not be granular enough to uniquely identify an |
259 | | - # individual block. |
260 | | - if expected_ret is None: |
261 | | - expected_ret = index |
262 | | - if use_timestamp: |
263 | | - assert_greater_than(ret, 0) |
264 | | - assert_greater_than(expected_ret + 1, ret) |
265 | | - else: |
266 | | - assert_equal(ret, expected_ret) |
| 253 | + assert_equal(ret, node.getblockchaininfo()['pruneheight']) |
267 | 254 |
|
268 | 255 | def has_block(index): |
269 | 256 | return os.path.isfile(os.path.join(self.nodes[node_number].datadir, "regtest", "blocks", "blk{:05}.dat".format(index))) |
@@ -308,7 +295,7 @@ def has_block(index): |
308 | 295 | raise AssertionError("blk00001.dat is still there, should be pruned by now") |
309 | 296 |
|
310 | 297 | # height=1000 should not prune anything more, because tip-288 is in blk00002.dat. |
311 | | - prune(1000, 1001 - MIN_BLOCKS_TO_KEEP) |
| 298 | + prune(1000) |
312 | 299 | if not has_block(2): |
313 | 300 | raise AssertionError("blk00002.dat is still there, should be pruned by now") |
314 | 301 |
|
|
0 commit comments