Skip to content

Commit 9600ea0

Browse files
committed
test: Add edge case of pruning up to index height
1 parent 698c524 commit 9600ea0

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

test/functional/feature_blockfilterindex_prune.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ def run_test(self):
2424
self.log.info("check if we can access a blockfilter when pruning is enabled but no blocks are actually pruned")
2525
self.sync_index(height=200)
2626
assert_greater_than(len(self.nodes[0].getblockfilter(self.nodes[0].getbestblockhash())['filter']), 0)
27-
# Mine two batches of blocks to avoid hitting NODE_NETWORK_LIMITED_MIN_BLOCKS disconnection
28-
self.generate(self.nodes[0], 250)
29-
self.generate(self.nodes[0], 250)
27+
self.generate(self.nodes[0], 500)
3028
self.sync_index(height=700)
3129

3230
self.log.info("prune some blocks")
@@ -39,16 +37,29 @@ def run_test(self):
3937
self.log.info("check if we can access the blockfilter of a pruned block")
4038
assert_greater_than(len(self.nodes[0].getblockfilter(self.nodes[0].getblockhash(2))['filter']), 0)
4139

40+
# mine and sync index up to a height that will later be the pruneheight
41+
self.generate(self.nodes[0], 298)
42+
self.sync_index(height=998)
43+
4244
self.log.info("start node without blockfilterindex")
4345
self.restart_node(0, extra_args=["-fastprune", "-prune=1"])
4446

4547
self.log.info("make sure accessing the blockfilters throws an error")
4648
assert_raises_rpc_error(-1, "Index is not enabled for filtertype basic", self.nodes[0].getblockfilter, self.nodes[0].getblockhash(2))
47-
self.generate(self.nodes[0], 1000)
49+
self.generate(self.nodes[0], 502)
50+
51+
self.log.info("prune exactly up to the blockfilterindexes best block while blockfilters are disabled")
52+
pruneheight_2 = self.nodes[0].pruneblockchain(1000)
53+
assert_equal(pruneheight_2, 998)
54+
self.restart_node(0, extra_args=["-fastprune", "-prune=1", "-blockfilterindex=1"])
55+
self.log.info("make sure that we can continue with the partially synced index after having pruned up to the index height")
56+
self.sync_index(height=1500)
4857

4958
self.log.info("prune below the blockfilterindexes best block while blockfilters are disabled")
50-
pruneheight_new = self.nodes[0].pruneblockchain(1000)
51-
assert_greater_than(pruneheight_new, pruneheight)
59+
self.restart_node(0, extra_args=["-fastprune", "-prune=1"])
60+
self.generate(self.nodes[0], 1000)
61+
pruneheight_3 = self.nodes[0].pruneblockchain(2000)
62+
assert_greater_than(pruneheight_3, pruneheight_2)
5263
self.stop_node(0)
5364

5465
self.log.info("make sure we get an init error when starting the node again with block filters")

0 commit comments

Comments
 (0)