<commit_before>#!/usr/bin/env python3
# Copyright (c) 2020 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test blockfilterindex in conjunction with prune."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
    assert_raises_rpc_error,
    assert_greater_than,
)


class FeatureBlockfilterindexPruneTest(BitcoinTestFramework):
    def set_test_params(self):
        self.num_nodes = 2
        self.extra_args = [["-fastprune", "-prune=1"], ["-fastprune", "-prune=1", "-blockfilterindex=1"]]

    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
        # 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)
        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
        self.log.info("check if we can access the blockfilter of a pruned block")<commit_msg>test: Intermittent issue in feature_blockfilterindex_prune<commit_after>#!/usr/bin/env python3
# Copyright (c) 2020 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test blockfilterindex in conjunction with prune."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
    assert_equal,
    assert_greater_than,
    assert_raises_rpc_error,
)


class FeatureBlockfilterindexPruneTest(BitcoinTestFramework):
    def set_test_params(self):
        self.num_nodes = 2
        self.extra_args = [["-fastprune", "-prune=1"], ["-fastprune", "-prune=1", "-blockfilterindex=1"]]

    def run_test(self):
        self.log.info("check if we can access a blockfilter when pruning is enabled but no blocks are actually pruned")
        self.wait_until(lambda: self.nodes[1].getindexinfo() == {'basic block filter index': {'synced': True, 'best_block_height': 200}})
        assert len(self.nodes[1].getblockfilter(self.nodes[1].getbestblockhash())['filter']) > 0
        # 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.wait_until(lambda: self.nodes[1].getindexinfo() == {'basic block filter index': {'synced': True, 'best_block_height': 700}})
        self.log.info("prune some blocks")
        pruneheight = self.nodes[1].pruneblockchain(400)
        assert_equal(pruneheight, 250)
        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
        self.log.info("check if we can access the blockfilter of a pruned block")
{'fraction_non_alphanumeric': 0.11190205011389522, 'fraction_numerical': 0.01879271070615034, 'mean_word_length': 3.9829787234042553, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '365462', 'n_tokens_mistral': 1079, 'n_tokens_neox': 1018, 'n_words': 274}