From e593ae07c4fb41a26c95dbd03301607fc5b4d5e2 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Mon, 21 Mar 2022 18:38:54 +0000 Subject: Bugfix: RPC/blockchain: pruneblockchain: Return the height of the actual last pruned block From 0.14 (2017 Mar) until before 0.19 (2019 Nov), the height of the last block pruned was returned, subject to a bug if there were blocks left unpruned due to sharing files with later blocks. In #15991, this was "fixed" to the current implementation, introducing a new bug: now, it returns the first *unpruned* block. Since the user provides the parameter as a block to include in pruning, it makes more sense to fix the behaviour to match the documentation. --- test/functional/feature_index_prune.py | 6 +++--- test/functional/feature_pruning.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/functional/feature_index_prune.py b/test/functional/feature_index_prune.py index 3ee6a8036c..bc85e43a57 100755 --- a/test/functional/feature_index_prune.py +++ b/test/functional/feature_index_prune.py @@ -73,7 +73,7 @@ class FeatureIndexPruneTest(BitcoinTestFramework): pruneheight_new = node.pruneblockchain(400) # the prune heights used here and below are magic numbers that are determined by the # thresholds at which block files wrap, so they depend on disk serialization and default block file size. - assert_equal(pruneheight_new, 249) + assert_equal(pruneheight_new, 248) self.log.info("check if we can access the tips blockfilter and coinstats when we have pruned some blocks") tip = self.nodes[0].getbestblockhash() @@ -108,7 +108,7 @@ class FeatureIndexPruneTest(BitcoinTestFramework): self.log.info("prune exactly up to the indices best blocks while the indices are disabled") for i in range(3): pruneheight_2 = self.nodes[i].pruneblockchain(1000) - assert_equal(pruneheight_2, 751) + assert_equal(pruneheight_2, 750) # Restart the nodes again with the indices activated self.restart_node(i, extra_args=self.extra_args[i]) @@ -142,7 +142,7 @@ class FeatureIndexPruneTest(BitcoinTestFramework): for node in self.nodes[:2]: with node.assert_debug_log(['limited pruning to height 2489']): pruneheight_new = node.pruneblockchain(2500) - assert_equal(pruneheight_new, 2006) + assert_equal(pruneheight_new, 2005) self.log.info("ensure that prune locks don't prevent indices from failing in a reorg scenario") with self.nodes[0].assert_debug_log(['basic block filter index prune lock moved back to 2480']): diff --git a/test/functional/feature_pruning.py b/test/functional/feature_pruning.py index 77524e85a3..7dbeccbc09 100755 --- a/test/functional/feature_pruning.py +++ b/test/functional/feature_pruning.py @@ -291,7 +291,7 @@ class PruneTest(BitcoinTestFramework): def prune(index): ret = node.pruneblockchain(height=height(index)) - assert_equal(ret, node.getblockchaininfo()['pruneheight']) + assert_equal(ret + 1, node.getblockchaininfo()['pruneheight']) def has_block(index): return os.path.isfile(os.path.join(self.nodes[node_number].datadir, self.chain, "blocks", f"blk{index:05}.dat")) -- cgit v1.2.3