Skip to content

Commit 9f3ffa2

Browse files
committed
Merge #21230: test: Fix NODE_NETWORK_LIMITED_MIN_BLOCKS disconnection
fa24247 test: Fix NODE_NETWORK_LIMITED_MIN_BLOCKS disconnection (MarcoFalke) fab6995 test: Make test actually test something (MarcoFalke) fae8f35 test: pep8 touched test (MarcoFalke) Pull request description: Fix several bugs. Also, fix #21227 ACKs for top commit: jonasschnelli: utACK fa24247 - thanks for fixing. ryanofsky: Code review ACK fa24247 with caveat above that I don't really understand the problem or fix. But the cleanups look good and the fix does seem perfectly safe. More description would be welcome! Tree-SHA512: 67f6ec92f6493aa822ae3fa8a7426a5acdc684044b8bafc0c65b652f63ccce969d0a6f1d1f099d6a91d05f478724869345b70335f2cfcfd00df46aef05cc4f9e
2 parents 3a2d5bf + fa24247 commit 9f3ffa2

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

test/functional/feature_blockfilterindex_prune.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
assert_greater_than,
1010
)
1111

12+
1213
class FeatureBlockfilterindexPruneTest(BitcoinTestFramework):
1314
def set_test_params(self):
1415
self.num_nodes = 2
@@ -17,33 +18,37 @@ def set_test_params(self):
1718
def run_test(self):
1819
# test basic pruning compatibility & filter access of pruned blocks
1920
self.log.info("check if we can access a blockfilter when pruning is enabled but no blocks are actually pruned")
20-
assert(len(self.nodes[1].getblockfilter(self.nodes[1].getbestblockhash())['filter']) > 0)
21-
self.nodes[1].generate(500)
21+
assert len(self.nodes[1].getblockfilter(self.nodes[1].getbestblockhash())['filter']) > 0
22+
# Mine two batches of blocks to avoid hitting NODE_NETWORK_LIMITED_MIN_BLOCKS disconnection
23+
self.nodes[1].generate(250)
24+
self.sync_all()
25+
self.nodes[1].generate(250)
2226
self.sync_all()
2327
self.log.info("prune some blocks")
2428
pruneheight = self.nodes[1].pruneblockchain(400)
25-
assert(pruneheight != 0)
29+
assert pruneheight != 0
2630
self.log.info("check if we can access the tips blockfilter when we have pruned some blocks")
27-
assert(len(self.nodes[1].getblockfilter(self.nodes[1].getbestblockhash())['filter']) > 0)
31+
assert len(self.nodes[1].getblockfilter(self.nodes[1].getbestblockhash())['filter']) > 0
2832
self.log.info("check if we can access the blockfilter of a pruned block")
29-
assert(len(self.nodes[1].getblockfilter(self.nodes[1].getblockhash(2))['filter']) > 0)
33+
assert len(self.nodes[1].getblockfilter(self.nodes[1].getblockhash(2))['filter']) > 0
3034
self.log.info("start node without blockfilterindex")
3135
self.stop_node(1)
3236
self.start_node(1, extra_args=self.extra_args[0])
3337
self.log.info("make sure accessing the blockfilters throws an error")
34-
assert_raises_rpc_error(-1,"Index is not enabled for filtertype basic", self.nodes[1].getblockfilter, self.nodes[1].getblockhash(2))
38+
assert_raises_rpc_error(-1, "Index is not enabled for filtertype basic", self.nodes[1].getblockfilter, self.nodes[1].getblockhash(2))
3539
self.nodes[1].generate(1000)
3640
self.log.info("prune below the blockfilterindexes best block while blockfilters are disabled")
3741
pruneheight_new = self.nodes[1].pruneblockchain(1000)
3842
assert_greater_than(pruneheight_new, pruneheight)
3943
self.stop_node(1)
4044
self.log.info("make sure we get an init error when starting the node again with block filters")
41-
self.nodes[1].assert_start_raises_init_error(extra_args=self.extra_args[1])
42-
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)"])
45+
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)"]):
46+
self.nodes[1].assert_start_raises_init_error(extra_args=self.extra_args[1])
4347
self.log.info("make sure the node starts again with the -reindex arg")
4448
reindex_args = self.extra_args[1]
4549
reindex_args.append("-reindex")
4650
self.start_node(1, extra_args=reindex_args)
4751

52+
4853
if __name__ == '__main__':
4954
FeatureBlockfilterindexPruneTest().main()

0 commit comments

Comments
 (0)