mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-30 15:54:03 +02:00
index: Access functions for global block filter indexes.
This commit is contained in:
@@ -265,4 +265,43 @@ BOOST_FIXTURE_TEST_CASE(blockfilter_index_initial_sync, TestChain100Setup)
|
||||
filter_index.Stop();
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(blockfilter_index_init_destroy, BasicTestingSetup)
|
||||
{
|
||||
SetDataDir("tempdir");
|
||||
|
||||
BlockFilterIndex* filter_index;
|
||||
|
||||
filter_index = GetBlockFilterIndex(BlockFilterType::BASIC);
|
||||
BOOST_CHECK(filter_index == nullptr);
|
||||
|
||||
BOOST_CHECK(InitBlockFilterIndex(BlockFilterType::BASIC, 1 << 20, true, false));
|
||||
|
||||
filter_index = GetBlockFilterIndex(BlockFilterType::BASIC);
|
||||
BOOST_CHECK(filter_index != nullptr);
|
||||
BOOST_CHECK(filter_index->GetFilterType() == BlockFilterType::BASIC);
|
||||
|
||||
// Initialize returns false if index already exists.
|
||||
BOOST_CHECK(!InitBlockFilterIndex(BlockFilterType::BASIC, 1 << 20, true, false));
|
||||
|
||||
int iter_count = 0;
|
||||
ForEachBlockFilterIndex([&iter_count](BlockFilterIndex& _index) { iter_count++; });
|
||||
BOOST_CHECK_EQUAL(iter_count, 1);
|
||||
|
||||
BOOST_CHECK(DestroyBlockFilterIndex(BlockFilterType::BASIC));
|
||||
|
||||
// Destroy returns false because index was already destroyed.
|
||||
BOOST_CHECK(!DestroyBlockFilterIndex(BlockFilterType::BASIC));
|
||||
|
||||
filter_index = GetBlockFilterIndex(BlockFilterType::BASIC);
|
||||
BOOST_CHECK(filter_index == nullptr);
|
||||
|
||||
// Reinitialize index.
|
||||
BOOST_CHECK(InitBlockFilterIndex(BlockFilterType::BASIC, 1 << 20, true, false));
|
||||
|
||||
DestroyAllBlockFilterIndexes();
|
||||
|
||||
filter_index = GetBlockFilterIndex(BlockFilterType::BASIC);
|
||||
BOOST_CHECK(filter_index == nullptr);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
Reference in New Issue
Block a user