blob: 339a7fcfebac1b50f2ea7a4f285a622b8025da89 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
// Copyright (c) 2018 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <blockfilter.h>
#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_SUITE(blockfilter_tests)
BOOST_AUTO_TEST_CASE(gcsfilter_test)
{
GCSFilter::ElementSet included_elements, excluded_elements;
for (int i = 0; i < 100; ++i) {
GCSFilter::Element element1(32);
element1[0] = i;
included_elements.insert(std::move(element1));
GCSFilter::Element element2(32);
element2[1] = i;
excluded_elements.insert(std::move(element2));
}
GCSFilter filter(0, 0, 10, 1 << 10, included_elements);
for (const auto& element : included_elements) {
BOOST_CHECK(filter.Match(element));
auto insertion = excluded_elements.insert(element);
BOOST_CHECK(filter.MatchAny(excluded_elements));
excluded_elements.erase(insertion.first);
}
}
BOOST_AUTO_TEST_SUITE_END()
|