mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 14:53:43 +01:00
@@ -10,12 +10,10 @@ This test takes 30 mins or more (up to 2 hours)
|
||||
"""
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, assert_greater_than, assert_raises_rpc_error, connect_nodes, mine_large_block, sync_blocks, wait_until
|
||||
from test_framework.util import assert_equal, assert_raises_rpc_error, connect_nodes, mine_large_block, sync_blocks, wait_until
|
||||
|
||||
import os
|
||||
|
||||
MIN_BLOCKS_TO_KEEP = 288
|
||||
|
||||
# Rescans start at the earliest block up to 2 hours before a key timestamp, so
|
||||
# the manual prune RPC avoids pruning blocks in the same window to be
|
||||
# compatible with pruning based on key creation time.
|
||||
@@ -250,20 +248,9 @@ class PruneTest(BitcoinTestFramework):
|
||||
else:
|
||||
return index
|
||||
|
||||
def prune(index, expected_ret=None):
|
||||
def prune(index):
|
||||
ret = node.pruneblockchain(height=height(index))
|
||||
# Check the return value. When use_timestamp is True, just check
|
||||
# that the return value is less than or equal to the expected
|
||||
# value, because when more than one block is generated per second,
|
||||
# a timestamp will not be granular enough to uniquely identify an
|
||||
# individual block.
|
||||
if expected_ret is None:
|
||||
expected_ret = index
|
||||
if use_timestamp:
|
||||
assert_greater_than(ret, 0)
|
||||
assert_greater_than(expected_ret + 1, ret)
|
||||
else:
|
||||
assert_equal(ret, expected_ret)
|
||||
assert_equal(ret, node.getblockchaininfo()['pruneheight'])
|
||||
|
||||
def has_block(index):
|
||||
return os.path.isfile(os.path.join(self.nodes[node_number].datadir, "regtest", "blocks", "blk{:05}.dat".format(index)))
|
||||
@@ -308,7 +295,7 @@ class PruneTest(BitcoinTestFramework):
|
||||
raise AssertionError("blk00001.dat is still there, should be pruned by now")
|
||||
|
||||
# height=1000 should not prune anything more, because tip-288 is in blk00002.dat.
|
||||
prune(1000, 1001 - MIN_BLOCKS_TO_KEEP)
|
||||
prune(1000)
|
||||
if not has_block(2):
|
||||
raise AssertionError("blk00002.dat is still there, should be pruned by now")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user