Changeset View
Changeset View
Standalone View
Standalone View
test/functional/pruning.py
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | def set_test_params(self): | ||||
"-noparkdeepreorg", "-maxreorgdepth=-1"], | "-noparkdeepreorg", "-maxreorgdepth=-1"], | ||||
["-prune=550"]] | ["-prune=550"]] | ||||
def setup_network(self): | def setup_network(self): | ||||
self.setup_nodes() | self.setup_nodes() | ||||
self.prunedir = self.options.tmpdir + "/node2/regtest/blocks/" | self.prunedir = self.options.tmpdir + "/node2/regtest/blocks/" | ||||
connect_nodes(self.nodes[0], 1) | connect_nodes(self.nodes[0], self.nodes[1]) | ||||
connect_nodes(self.nodes[1], 2) | connect_nodes(self.nodes[1], self.nodes[2]) | ||||
connect_nodes(self.nodes[2], 0) | connect_nodes(self.nodes[2], self.nodes[0]) | ||||
connect_nodes(self.nodes[0], 3) | connect_nodes(self.nodes[0], self.nodes[3]) | ||||
connect_nodes(self.nodes[0], 4) | connect_nodes(self.nodes[0], self.nodes[4]) | ||||
sync_blocks(self.nodes[0:5]) | sync_blocks(self.nodes[0:5]) | ||||
def setup_nodes(self): | def setup_nodes(self): | ||||
self.add_nodes(self.num_nodes, self.extra_args, timewait=900) | self.add_nodes(self.num_nodes, self.extra_args, timewait=900) | ||||
self.start_nodes() | self.start_nodes() | ||||
def create_big_chain(self): | def create_big_chain(self): | ||||
# Start by creating some coinbases we can spend later | # Start by creating some coinbases we can spend later | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | def create_chain_with_staleblocks(self): | ||||
self.nodes[1].generate(1) | self.nodes[1].generate(1) | ||||
# Reorg back with 25 block chain from node 0 | # Reorg back with 25 block chain from node 0 | ||||
for i in range(25): | for i in range(25): | ||||
mine_big_block(self.nodes[0], self.utxo_cache_0) | mine_big_block(self.nodes[0], self.utxo_cache_0) | ||||
# Create connections in the order so both nodes can see the reorg | # Create connections in the order so both nodes can see the reorg | ||||
# at the same time | # at the same time | ||||
connect_nodes(self.nodes[1], 0) | connect_nodes(self.nodes[1], self.nodes[0]) | ||||
connect_nodes(self.nodes[2], 0) | connect_nodes(self.nodes[2], self.nodes[0]) | ||||
sync_blocks(self.nodes[0:3]) | sync_blocks(self.nodes[0:3]) | ||||
self.log.info("Usage can be over target because of high stale rate: %d" % | self.log.info("Usage can be over target because of high stale rate: %d" % | ||||
calc_usage(self.prunedir)) | calc_usage(self.prunedir)) | ||||
def reorg_test(self): | def reorg_test(self): | ||||
# Node 1 will mine a 300 block chain starting 287 blocks back from Node | # Node 1 will mine a 300 block chain starting 287 blocks back from Node | ||||
# 0 and Node 2's tip. This will cause Node 2 to do a reorg requiring | # 0 and Node 2's tip. This will cause Node 2 to do a reorg requiring | ||||
Show All 32 Lines | def reorg_test(self): | ||||
self.start_node(1, extra_args=[ | self.start_node(1, extra_args=[ | ||||
"-maxreceivebuffer=20000", "-blockmaxsize=5000", "-checkblocks=5", | "-maxreceivebuffer=20000", "-blockmaxsize=5000", "-checkblocks=5", | ||||
"-disablesafemode", "-noparkdeepreorg", "-maxreorgdepth=-1"]) | "-disablesafemode", "-noparkdeepreorg", "-maxreorgdepth=-1"]) | ||||
self.log.info("Generating new longer chain of 300 more blocks") | self.log.info("Generating new longer chain of 300 more blocks") | ||||
self.nodes[1].generate(300) | self.nodes[1].generate(300) | ||||
self.log.info("Reconnect nodes") | self.log.info("Reconnect nodes") | ||||
connect_nodes(self.nodes[0], 1) | connect_nodes(self.nodes[0], self.nodes[1]) | ||||
connect_nodes(self.nodes[2], 1) | connect_nodes(self.nodes[2], self.nodes[1]) | ||||
sync_blocks(self.nodes[0:3], timeout=120) | sync_blocks(self.nodes[0:3], timeout=120) | ||||
self.log.info("Verify height on node 2: %d" % | self.log.info("Verify height on node 2: %d" % | ||||
self.nodes[2].getblockcount()) | self.nodes[2].getblockcount()) | ||||
self.log.info("Usage possibly still high bc of stale blocks in block files: %d" % | self.log.info("Usage possibly still high bc of stale blocks in block files: %d" % | ||||
calc_usage(self.prunedir)) | calc_usage(self.prunedir)) | ||||
self.log.info( | self.log.info( | ||||
▲ Show 20 Lines • Show All 175 Lines • ▼ Show 20 Lines | def wallet_test(self): | ||||
self.stop_node(2) | self.stop_node(2) | ||||
self.start_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 loads successfully when restarting a pruned node after IBD. | # check that wallet loads 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], 5) | connect_nodes(self.nodes[0], self.nodes[5]) | ||||
nds = [self.nodes[0], self.nodes[5]] | nds = [self.nodes[0], self.nodes[5]] | ||||
sync_blocks(nds, wait=5, timeout=300) | sync_blocks(nds, wait=5, timeout=300) | ||||
self.stop_node(5) # stop and start to trigger rescan | self.stop_node(5) # stop and start to trigger rescan | ||||
self.start_node( | 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): | ||||
▲ Show 20 Lines • Show All 125 Lines • Show Last 20 Lines |