Changeset View
Changeset View
Standalone View
Standalone View
test/functional/feature_pruning.py
Show First 20 Lines • Show All 295 Lines • ▼ Show 20 Lines | def manual_test(self, node_number, use_timestamp): | ||||
# at this point, node has 995 blocks and has not yet run in prune mode | # at this point, node has 995 blocks and has not yet run in prune mode | ||||
self.start_node(node_number) | self.start_node(node_number) | ||||
node = self.nodes[node_number] | node = self.nodes[node_number] | ||||
assert_equal(node.getblockcount(), 995) | assert_equal(node.getblockcount(), 995) | ||||
assert_raises_rpc_error(-1, "not in prune mode", | assert_raises_rpc_error(-1, "not in prune mode", | ||||
node.pruneblockchain, 500) | node.pruneblockchain, 500) | ||||
# now re-start in manual pruning mode | # now re-start in manual pruning mode | ||||
self.stop_node(node_number) | self.restart_node(node_number, extra_args=["-prune=1"]) | ||||
self.start_node(node_number, extra_args=["-prune=1"]) | |||||
node = self.nodes[node_number] | node = self.nodes[node_number] | ||||
assert_equal(node.getblockcount(), 995) | assert_equal(node.getblockcount(), 995) | ||||
def height(index): | def height(index): | ||||
if use_timestamp: | if use_timestamp: | ||||
return node.getblockheader(node.getblockhash(index))[ | return node.getblockheader(node.getblockhash(index))[ | ||||
"time"] + TIMESTAMP_WINDOW | "time"] + TIMESTAMP_WINDOW | ||||
else: | else: | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | def manual_test(self, node_number, use_timestamp): | ||||
prune(1000) | prune(1000) | ||||
assert not has_block( | assert not has_block( | ||||
2), "blk00002.dat is still there, should be pruned by now" | 2), "blk00002.dat is still there, should be pruned by now" | ||||
assert not has_block( | assert not has_block( | ||||
3), "blk00003.dat is still there, should be pruned by now" | 3), "blk00003.dat is still there, should be pruned by now" | ||||
# stop node, start back up with auto-prune at 550 MiB, make sure still | # stop node, start back up with auto-prune at 550 MiB, make sure still | ||||
# runs | # runs | ||||
self.stop_node(node_number) | self.restart_node(node_number, extra_args=["-prune=550"]) | ||||
self.start_node(node_number, extra_args=["-prune=550"]) | |||||
self.log.info("Success") | self.log.info("Success") | ||||
def wallet_test(self): | def wallet_test(self): | ||||
# check that the pruning node's wallet is still in good shape | # check that the pruning node's wallet is still in good shape | ||||
self.log.info("Stop and start pruning node to trigger wallet rescan") | self.log.info("Stop and start pruning node to trigger wallet rescan") | ||||
self.stop_node(2) | self.restart_node( | ||||
self.start_node( | |||||
2, extra_args=["-prune=550", "-noparkdeepreorg", "-maxreorgdepth=-1"]) | 2, extra_args=["-prune=550", "-noparkdeepreorg", "-maxreorgdepth=-1"]) | ||||
self.log.info("Success") | self.log.info("Success") | ||||
# check that wallet loads successfully when restarting a pruned node after IBD. | # check that wallet loads successfully when restarting a pruned node after IBD. | ||||
# this was reported to fail in #7494. | # this was reported to fail in #7494. | ||||
self.log.info("Syncing node 5 to test wallet") | self.log.info("Syncing node 5 to test wallet") | ||||
connect_nodes(self.nodes[0], self.nodes[5]) | connect_nodes(self.nodes[0], self.nodes[5]) | ||||
nds = [self.nodes[0], self.nodes[5]] | nds = [self.nodes[0], self.nodes[5]] | ||||
self.sync_blocks(nds, wait=5, timeout=300) | self.sync_blocks(nds, wait=5, timeout=300) | ||||
# Stop and start to trigger rescan | self.restart_node( | ||||
self.stop_node(5) | |||||
self.start_node( | |||||
5, extra_args=["-prune=550", "-noparkdeepreorg", "-maxreorgdepth=-1"]) | 5, extra_args=["-prune=550", "-noparkdeepreorg", "-maxreorgdepth=-1"]) | ||||
self.log.info("Success") | self.log.info("Success") | ||||
def run_test(self): | def run_test(self): | ||||
self.log.info("Warning! This test requires 4GB of disk space") | self.log.info("Warning! This test requires 4GB of disk space") | ||||
self.log.info("Mining a big blockchain of 995 blocks") | self.log.info("Mining a big blockchain of 995 blocks") | ||||
self.create_big_chain() | self.create_big_chain() | ||||
▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines |