From 92fed92540959e30acad6c6d9870e24b7bd1b4b8 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 21 May 2019 16:52:59 +0300 Subject: [PATCH] Fix and re-enable pruning.py Pruning works when starting in -litemode --- src/init.cpp | 11 +++++++++-- test/functional/pruning.py | 18 +++++++++--------- test/functional/test_runner.py | 2 +- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 2ceeab77bd..4dc06cfa36 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1213,8 +1213,15 @@ bool AppInitParameterInteraction() nPruneTarget = std::numeric_limits::max(); fPruneMode = true; } else if (nPruneTarget) { - if (nPruneTarget < MIN_DISK_SPACE_FOR_BLOCK_FILES) { - return InitError(strprintf(_("Prune configured below the minimum of %d MiB. Please use a higher number."), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024)); + if (GetBoolArg("-regtest", false)) { + // we use 1MB blocks to test this on regtest + if (nPruneTarget < 550 * 1024 * 1024) { + return InitError(strprintf(_("Prune configured below the minimum of %d MiB. Please use a higher number."), 550)); + } + } else { + if (nPruneTarget < MIN_DISK_SPACE_FOR_BLOCK_FILES) { + return InitError(strprintf(_("Prune configured below the minimum of %d MiB. Please use a higher number."), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024)); + } } LogPrintf("Prune configured to target %uMiB on disk for block and undo files.\n", nPruneTarget / 1024 / 1024); fPruneMode = true; diff --git a/test/functional/pruning.py b/test/functional/pruning.py index cc84c8c085..74a9ebb5a3 100755 --- a/test/functional/pruning.py +++ b/test/functional/pruning.py @@ -45,15 +45,15 @@ class PruneTest(BitcoinTestFramework): self.nodes.append(start_node(1, self.options.tmpdir, ["-maxreceivebuffer=20000","-blockmaxsize=999000", "-checkblocks=5"], timewait=900)) # Create node 2 to test pruning - self.nodes.append(start_node(2, self.options.tmpdir, ["-maxreceivebuffer=20000","-prune=550"], timewait=900)) + self.nodes.append(start_node(2, self.options.tmpdir, ["-litemode","-txindex=0","-maxreceivebuffer=20000","-prune=550"], redirect_stderr=True, timewait=900)) self.prunedir = self.options.tmpdir+"/node2/regtest/blocks/" # Create nodes 3 and 4 to test manual pruning (they will be re-started with manual pruning later) - self.nodes.append(start_node(3, self.options.tmpdir, ["-maxreceivebuffer=20000","-blockmaxsize=999000"], timewait=900)) - self.nodes.append(start_node(4, self.options.tmpdir, ["-maxreceivebuffer=20000","-blockmaxsize=999000"], timewait=900)) + self.nodes.append(start_node(3, self.options.tmpdir, ["-litemode","-txindex=0","-maxreceivebuffer=20000","-blockmaxsize=999000"], redirect_stderr=True, timewait=900)) + self.nodes.append(start_node(4, self.options.tmpdir, ["-litemode","-txindex=0","-maxreceivebuffer=20000","-blockmaxsize=999000"], redirect_stderr=True, timewait=900)) # Create nodes 5 to test wallet in prune mode, but do not connect - self.nodes.append(start_node(5, self.options.tmpdir, ["-prune=550"])) + self.nodes.append(start_node(5, self.options.tmpdir, ["-litemode","-txindex=0","-prune=550"], redirect_stderr=True)) # Determine default relay fee self.relayfee = self.nodes[0].getnetworkinfo()["relayfee"] @@ -228,13 +228,13 @@ class PruneTest(BitcoinTestFramework): def manual_test(self, node_number, use_timestamp): # at this point, node has 995 blocks and has not yet run in prune mode - node = self.nodes[node_number] = start_node(node_number, self.options.tmpdir, timewait=900) + node = self.nodes[node_number] = start_node(node_number, self.options.tmpdir, ["-litemode","-txindex=0"], redirect_stderr=True, timewait=900) assert_equal(node.getblockcount(), 995) assert_raises_jsonrpc(-1, "not in prune mode", node.pruneblockchain, 500) self.stop_node(node_number) # now re-start in manual pruning mode - node = self.nodes[node_number] = start_node(node_number, self.options.tmpdir, ["-prune=1"], timewait=900) + node = self.nodes[node_number] = start_node(node_number, self.options.tmpdir, ["-litemode","-txindex=0","-prune=1"], redirect_stderr=True, timewait=900) assert_equal(node.getblockcount(), 995) def height(index): @@ -308,7 +308,7 @@ class PruneTest(BitcoinTestFramework): # stop node, start back up with auto-prune at 550MB, make sure still runs self.stop_node(node_number) - self.nodes[node_number] = start_node(node_number, self.options.tmpdir, ["-prune=550"], timewait=900) + self.nodes[node_number] = start_node(node_number, self.options.tmpdir, ["-litemode","-txindex=0","-prune=550"], redirect_stderr=True, timewait=900) self.log.info("Success") @@ -316,7 +316,7 @@ class PruneTest(BitcoinTestFramework): # 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.stop_node(2) - start_node(2, self.options.tmpdir, ["-prune=550"]) + start_node(2, self.options.tmpdir, ["-litemode","-txindex=0","-prune=550"], redirect_stderr=True) self.log.info("Success") # check that wallet loads loads successfully when restarting a pruned node after IBD. @@ -326,7 +326,7 @@ class PruneTest(BitcoinTestFramework): nds = [self.nodes[0], self.nodes[5]] sync_blocks(nds, wait=5, timeout=300) self.stop_node(5) #stop and start to trigger rescan - start_node(5, self.options.tmpdir, ["-prune=550"]) + start_node(5, self.options.tmpdir, ["-litemode","-txindex=0","-prune=550"], redirect_stderr=True) self.log.info("Success") def run_test(self): diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index 4cc657b845..fbe3216b1c 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -110,7 +110,7 @@ ZMQ_SCRIPTS = [ EXTENDED_SCRIPTS = [ # These tests are not run by the travis build process. # Longest test should go first, to favor running tests in parallel - # 'pruning.py', # Prune mode is incompatible with -txindex. + 'pruning.py', # NOTE: Prune mode is incompatible with -txindex, should work in litemode though. # vv Tests less than 20m vv 'smartfees.py', # vv Tests less than 5m vv