MCPcopy Create free account
hub / github.com/ElementsProject/elements / BOOST_AUTO_TEST_CASE

Function BOOST_AUTO_TEST_CASE

src/test/bloom_tests.cpp:26–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24BOOST_FIXTURE_TEST_SUITE(bloom_tests, BasicTestingSetup)
25
26BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize)
27{
28 CBloomFilter filter(3, 0.01, 0, BLOOM_UPDATE_ALL);
29
30 BOOST_CHECK_MESSAGE( !filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "Bloom filter should be empty!");
31 filter.insert(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8"));
32 BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "Bloom filter doesn't contain just-inserted object!");
33 // One bit different in first byte
34 BOOST_CHECK_MESSAGE(!filter.contains(ParseHex("19108ad8ed9bb6274d3980bab5a85c048f0950c8")), "Bloom filter contains something it shouldn't!");
35
36 filter.insert(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32eee"));
37 BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32eee")), "Bloom filter doesn't contain just-inserted object (2)!");
38
39 filter.insert(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729c5"));
40 BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729c5")), "Bloom filter doesn't contain just-inserted object (3)!");
41
42 CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
43 stream << filter;
44
45 std::vector<uint8_t> expected = ParseHex("03614e9b050000000000000001");
46 auto result{MakeUCharSpan(stream)};
47
48 BOOST_CHECK_EQUAL_COLLECTIONS(result.begin(), result.end(), expected.begin(), expected.end());
49
50 BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "Bloom filter doesn't contain just-inserted object!");
51}
52
53BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize_with_tweak)
54{

Callers

nothing calls this directly

Calls 15

ParseHexFunction · 0.85
MakeUCharSpanFunction · 0.85
DecodeSecretFunction · 0.85
uint256SFunction · 0.85
CBloomFilterClass · 0.85
getBlock13b8aFunction · 0.85
SeedInsecureRandFunction · 0.85
RandomDataFunction · 0.85
IsRelevantAndUpdateMethod · 0.80
COutPointClass · 0.50
CMerkleBlockClass · 0.50
containsMethod · 0.45

Tested by

no test coverage detected