|
13 | 13 |
|
14 | 14 | class FeatureBlockfilterindexPruneTest(BitcoinTestFramework):
|
15 | 15 | 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 | 18 |
|
19 | 19 | def sync_index(self, height):
|
20 | 20 | expected = {'basic block filter index': {'synced': True, 'best_block_height': height}}
|
21 |
| - self.wait_until(lambda: self.nodes[1].getindexinfo() == expected) |
| 21 | + self.wait_until(lambda: self.nodes[0].getindexinfo() == expected) |
22 | 22 |
|
23 | 23 | def run_test(self):
|
24 | 24 | self.log.info("check if we can access a blockfilter when pruning is enabled but no blocks are actually pruned")
|
25 | 25 | self.sync_index(height=200)
|
26 |
| - assert_greater_than(len(self.nodes[1].getblockfilter(self.nodes[1].getbestblockhash())['filter']), 0) |
| 26 | + assert_greater_than(len(self.nodes[0].getblockfilter(self.nodes[0].getbestblockhash())['filter']), 0) |
27 | 27 | # Mine two batches of blocks to avoid hitting NODE_NETWORK_LIMITED_MIN_BLOCKS disconnection
|
28 |
| - self.nodes[1].generate(250) |
| 28 | + self.nodes[0].generate(250) |
29 | 29 | self.sync_all()
|
30 |
| - self.nodes[1].generate(250) |
| 30 | + self.nodes[0].generate(250) |
31 | 31 | self.sync_all()
|
32 | 32 | self.sync_index(height=700)
|
33 | 33 |
|
34 | 34 | self.log.info("prune some blocks")
|
35 |
| - pruneheight = self.nodes[1].pruneblockchain(400) |
| 35 | + pruneheight = self.nodes[0].pruneblockchain(400) |
36 | 36 | assert_equal(pruneheight, 250)
|
37 | 37 |
|
38 | 38 | self.log.info("check if we can access the tips blockfilter when we have pruned some blocks")
|
39 |
| - assert_greater_than(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 | 40 |
|
41 | 41 | self.log.info("check if we can access the blockfilter of a pruned block")
|
42 |
| - assert_greater_than(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 | 43 |
|
44 | 44 | self.log.info("start node without blockfilterindex")
|
45 |
| - self.stop_node(1) |
46 |
| - self.start_node(1, extra_args=self.extra_args[0]) |
| 45 | + self.restart_node(0, extra_args=["-fastprune", "-prune=1"]) |
47 | 46 |
|
48 | 47 | self.log.info("make sure accessing the blockfilters throws an error")
|
49 |
| - assert_raises_rpc_error(-1, "Index is not enabled for filtertype basic", self.nodes[1].getblockfilter, self.nodes[1].getblockhash(2)) |
50 |
| - 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) |
51 | 50 |
|
52 | 51 | self.log.info("prune below the blockfilterindexes best block while blockfilters are disabled")
|
53 |
| - pruneheight_new = self.nodes[1].pruneblockchain(1000) |
| 52 | + pruneheight_new = self.nodes[0].pruneblockchain(1000) |
54 | 53 | assert_greater_than(pruneheight_new, pruneheight)
|
55 |
| - self.stop_node(1) |
| 54 | + self.stop_node(0) |
56 | 55 |
|
57 | 56 | self.log.info("make sure we get an init error when starting the node again with block filters")
|
58 |
| - 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)"]): |
59 |
| - 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"]) |
60 | 59 |
|
61 | 60 | self.log.info("make sure the node starts again with the -reindex arg")
|
62 |
| - reindex_args = self.extra_args[1] |
63 |
| - reindex_args.append("-reindex") |
64 |
| - self.start_node(1, extra_args=reindex_args) |
| 61 | + self.start_node(0, extra_args = ["-fastprune", "-prune=1", "-blockfilterindex", "-reindex"]) |
65 | 62 |
|
66 | 63 |
|
67 | 64 | if __name__ == '__main__':
|
|
0 commit comments