Skip to content

Commit fb67cae

Browse files
author
MarcoFalke
committed
Merge #21297: test: feature_blockfilterindex_prune.py improvements
88c4b9b test: remove unneeded node from feature_blockfilterindex_prune.py (Jon Atack) ace3f4c test: improve assertions in feature_blockfilterindex_prune.py (Jon Atack) Pull request description: - improves the assertions - removes an unneeded node, reducing from two to one, and some unneeded `extra_arg` code ACKs for top commit: MarcoFalke: ACK 88c4b9b brunoerg: Tested ACK 88c4b9b Tree-SHA512: 295700da3a5f583ee02ae2d184db93cce0e13aba69115d5db07f83e96a66b4b850adaff2c3725b6585799565b9ee654b1fee8a6245eaba8c21e1cb5ce524eb2b
2 parents 5ba5bec + 88c4b9b commit fb67cae

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed

test/functional/feature_blockfilterindex_prune.py

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,52 @@
1313

1414
class FeatureBlockfilterindexPruneTest(BitcoinTestFramework):
1515
def set_test_params(self):
16-
self.num_nodes = 2
17-
self.extra_args = [["-fastprune", "-prune=1"], ["-fastprune", "-prune=1", "-blockfilterindex=1"]]
16+
self.num_nodes = 1
17+
self.extra_args = [["-fastprune", "-prune=1", "-blockfilterindex=1"]]
18+
19+
def sync_index(self, height):
20+
expected = {'basic block filter index': {'synced': True, 'best_block_height': height}}
21+
self.wait_until(lambda: self.nodes[0].getindexinfo() == expected)
1822

1923
def run_test(self):
2024
self.log.info("check if we can access a blockfilter when pruning is enabled but no blocks are actually pruned")
21-
self.wait_until(lambda: self.nodes[1].getindexinfo() == {'basic block filter index': {'synced': True, 'best_block_height': 200}})
22-
assert len(self.nodes[1].getblockfilter(self.nodes[1].getbestblockhash())['filter']) > 0
25+
self.sync_index(height=200)
26+
assert_greater_than(len(self.nodes[0].getblockfilter(self.nodes[0].getbestblockhash())['filter']), 0)
2327
# Mine two batches of blocks to avoid hitting NODE_NETWORK_LIMITED_MIN_BLOCKS disconnection
24-
self.nodes[1].generate(250)
28+
self.nodes[0].generate(250)
2529
self.sync_all()
26-
self.nodes[1].generate(250)
30+
self.nodes[0].generate(250)
2731
self.sync_all()
28-
self.wait_until(lambda: self.nodes[1].getindexinfo() == {'basic block filter index': {'synced': True, 'best_block_height': 700}})
32+
self.sync_index(height=700)
33+
2934
self.log.info("prune some blocks")
30-
pruneheight = self.nodes[1].pruneblockchain(400)
35+
pruneheight = self.nodes[0].pruneblockchain(400)
3136
assert_equal(pruneheight, 250)
37+
3238
self.log.info("check if we can access the tips blockfilter when we have pruned some blocks")
33-
assert len(self.nodes[1].getblockfilter(self.nodes[1].getbestblockhash())['filter']) > 0
39+
assert_greater_than(len(self.nodes[0].getblockfilter(self.nodes[0].getbestblockhash())['filter']), 0)
40+
3441
self.log.info("check if we can access the blockfilter of a pruned block")
35-
assert len(self.nodes[1].getblockfilter(self.nodes[1].getblockhash(2))['filter']) > 0
42+
assert_greater_than(len(self.nodes[0].getblockfilter(self.nodes[0].getblockhash(2))['filter']), 0)
43+
3644
self.log.info("start node without blockfilterindex")
37-
self.stop_node(1)
38-
self.start_node(1, extra_args=self.extra_args[0])
45+
self.restart_node(0, extra_args=["-fastprune", "-prune=1"])
46+
3947
self.log.info("make sure accessing the blockfilters throws an error")
40-
assert_raises_rpc_error(-1, "Index is not enabled for filtertype basic", self.nodes[1].getblockfilter, self.nodes[1].getblockhash(2))
41-
self.nodes[1].generate(1000)
48+
assert_raises_rpc_error(-1, "Index is not enabled for filtertype basic", self.nodes[0].getblockfilter, self.nodes[0].getblockhash(2))
49+
self.nodes[0].generate(1000)
50+
4251
self.log.info("prune below the blockfilterindexes best block while blockfilters are disabled")
43-
pruneheight_new = self.nodes[1].pruneblockchain(1000)
52+
pruneheight_new = self.nodes[0].pruneblockchain(1000)
4453
assert_greater_than(pruneheight_new, pruneheight)
45-
self.stop_node(1)
54+
self.stop_node(0)
55+
4656
self.log.info("make sure we get an init error when starting the node again with block filters")
47-
with self.nodes[1].assert_debug_log(["basic block filter index best block of the index goes beyond pruned data. Please disable the index or reindex (which will download the whole blockchain again)"]):
48-
self.nodes[1].assert_start_raises_init_error(extra_args=self.extra_args[1])
57+
with self.nodes[0].assert_debug_log(["basic block filter index best block of the index goes beyond pruned data. Please disable the index or reindex (which will download the whole blockchain again)"]):
58+
self.nodes[0].assert_start_raises_init_error(extra_args=["-fastprune", "-prune=1", "-blockfilterindex=1"])
59+
4960
self.log.info("make sure the node starts again with the -reindex arg")
50-
reindex_args = self.extra_args[1]
51-
reindex_args.append("-reindex")
52-
self.start_node(1, extra_args=reindex_args)
61+
self.start_node(0, extra_args = ["-fastprune", "-prune=1", "-blockfilterindex", "-reindex"])
5362

5463

5564
if __name__ == '__main__':

0 commit comments

Comments
 (0)