From fae8f35df8a2158505f8333d546bc7a13b15e7a9 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Thu, 18 Feb 2021 20:46:39 +0100 Subject: [PATCH 1/3] test: pep8 touched test --- test/functional/feature_blockfilterindex_prune.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/test/functional/feature_blockfilterindex_prune.py b/test/functional/feature_blockfilterindex_prune.py index a380aae0981..d1cc20497da 100755 --- a/test/functional/feature_blockfilterindex_prune.py +++ b/test/functional/feature_blockfilterindex_prune.py @@ -9,6 +9,7 @@ from test_framework.util import ( assert_greater_than, ) + class FeatureBlockfilterindexPruneTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 2 @@ -17,21 +18,21 @@ class FeatureBlockfilterindexPruneTest(BitcoinTestFramework): def run_test(self): # test basic pruning compatibility & filter access of pruned blocks self.log.info("check if we can access a blockfilter when pruning is enabled but no blocks are actually pruned") - assert(len(self.nodes[1].getblockfilter(self.nodes[1].getbestblockhash())['filter']) > 0) + assert len(self.nodes[1].getblockfilter(self.nodes[1].getbestblockhash())['filter']) > 0 self.nodes[1].generate(500) self.sync_all() self.log.info("prune some blocks") pruneheight = self.nodes[1].pruneblockchain(400) - assert(pruneheight != 0) + assert pruneheight != 0 self.log.info("check if we can access the tips blockfilter when we have pruned some blocks") - assert(len(self.nodes[1].getblockfilter(self.nodes[1].getbestblockhash())['filter']) > 0) + assert len(self.nodes[1].getblockfilter(self.nodes[1].getbestblockhash())['filter']) > 0 self.log.info("check if we can access the blockfilter of a pruned block") - assert(len(self.nodes[1].getblockfilter(self.nodes[1].getblockhash(2))['filter']) > 0) + assert len(self.nodes[1].getblockfilter(self.nodes[1].getblockhash(2))['filter']) > 0 self.log.info("start node without blockfilterindex") self.stop_node(1) self.start_node(1, extra_args=self.extra_args[0]) self.log.info("make sure accessing the blockfilters throws an error") - assert_raises_rpc_error(-1,"Index is not enabled for filtertype basic", self.nodes[1].getblockfilter, self.nodes[1].getblockhash(2)) + assert_raises_rpc_error(-1, "Index is not enabled for filtertype basic", self.nodes[1].getblockfilter, self.nodes[1].getblockhash(2)) self.nodes[1].generate(1000) self.log.info("prune below the blockfilterindexes best block while blockfilters are disabled") pruneheight_new = self.nodes[1].pruneblockchain(1000) @@ -45,5 +46,6 @@ class FeatureBlockfilterindexPruneTest(BitcoinTestFramework): reindex_args.append("-reindex") self.start_node(1, extra_args=reindex_args) + if __name__ == '__main__': FeatureBlockfilterindexPruneTest().main() From fab6995629e391d03d28ea81b89c94d9e92172f6 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Thu, 18 Feb 2021 20:43:06 +0100 Subject: [PATCH 2/3] test: Make test actually test something The context manager was not even created, so previously it did not check the debug log --- test/functional/feature_blockfilterindex_prune.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/functional/feature_blockfilterindex_prune.py b/test/functional/feature_blockfilterindex_prune.py index d1cc20497da..369250cfd9a 100755 --- a/test/functional/feature_blockfilterindex_prune.py +++ b/test/functional/feature_blockfilterindex_prune.py @@ -39,8 +39,8 @@ class FeatureBlockfilterindexPruneTest(BitcoinTestFramework): assert_greater_than(pruneheight_new, pruneheight) self.stop_node(1) self.log.info("make sure we get an init error when starting the node again with block filters") - self.nodes[1].assert_start_raises_init_error(extra_args=self.extra_args[1]) - 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)"]) + 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)"]): + self.nodes[1].assert_start_raises_init_error(extra_args=self.extra_args[1]) self.log.info("make sure the node starts again with the -reindex arg") reindex_args = self.extra_args[1] reindex_args.append("-reindex") From fa24247d0ff437a86b105692d342beb5f9f7a015 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Thu, 18 Feb 2021 21:00:28 +0100 Subject: [PATCH 3/3] test: Fix NODE_NETWORK_LIMITED_MIN_BLOCKS disconnection --- test/functional/feature_blockfilterindex_prune.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/functional/feature_blockfilterindex_prune.py b/test/functional/feature_blockfilterindex_prune.py index 369250cfd9a..455073ef9cf 100755 --- a/test/functional/feature_blockfilterindex_prune.py +++ b/test/functional/feature_blockfilterindex_prune.py @@ -19,7 +19,10 @@ class FeatureBlockfilterindexPruneTest(BitcoinTestFramework): # test basic pruning compatibility & filter access of pruned blocks self.log.info("check if we can access a blockfilter when pruning is enabled but no blocks are actually pruned") assert len(self.nodes[1].getblockfilter(self.nodes[1].getbestblockhash())['filter']) > 0 - self.nodes[1].generate(500) + # Mine two batches of blocks to avoid hitting NODE_NETWORK_LIMITED_MIN_BLOCKS disconnection + self.nodes[1].generate(250) + self.sync_all() + self.nodes[1].generate(250) self.sync_all() self.log.info("prune some blocks") pruneheight = self.nodes[1].pruneblockchain(400)