Merge #9223: unification of Bloom filter representation
b7aa290
unification of Bloom filter representation (S. Matthew English)
This commit is contained in:
commit
5412c08c3c
1 changed files with 10 additions and 10 deletions
|
@ -30,15 +30,15 @@ BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize)
|
||||||
CBloomFilter filter(3, 0.01, 0, BLOOM_UPDATE_ALL);
|
CBloomFilter filter(3, 0.01, 0, BLOOM_UPDATE_ALL);
|
||||||
|
|
||||||
filter.insert(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8"));
|
filter.insert(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8"));
|
||||||
BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "BloomFilter doesn't contain just-inserted object!");
|
BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "Bloom filter doesn't contain just-inserted object!");
|
||||||
// One bit different in first byte
|
// One bit different in first byte
|
||||||
BOOST_CHECK_MESSAGE(!filter.contains(ParseHex("19108ad8ed9bb6274d3980bab5a85c048f0950c8")), "BloomFilter contains something it shouldn't!");
|
BOOST_CHECK_MESSAGE(!filter.contains(ParseHex("19108ad8ed9bb6274d3980bab5a85c048f0950c8")), "Bloom filter contains something it shouldn't!");
|
||||||
|
|
||||||
filter.insert(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32eee"));
|
filter.insert(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32eee"));
|
||||||
BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32eee")), "BloomFilter doesn't contain just-inserted object (2)!");
|
BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32eee")), "Bloom filter doesn't contain just-inserted object (2)!");
|
||||||
|
|
||||||
filter.insert(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729c5"));
|
filter.insert(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729c5"));
|
||||||
BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729c5")), "BloomFilter doesn't contain just-inserted object (3)!");
|
BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729c5")), "Bloom filter doesn't contain just-inserted object (3)!");
|
||||||
|
|
||||||
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
||||||
stream << filter;
|
stream << filter;
|
||||||
|
@ -51,9 +51,9 @@ BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize)
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL_COLLECTIONS(stream.begin(), stream.end(), expected.begin(), expected.end());
|
BOOST_CHECK_EQUAL_COLLECTIONS(stream.begin(), stream.end(), expected.begin(), expected.end());
|
||||||
|
|
||||||
BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "BloomFilter doesn't contain just-inserted object!");
|
BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "Bloom filter doesn't contain just-inserted object!");
|
||||||
filter.clear();
|
filter.clear();
|
||||||
BOOST_CHECK_MESSAGE( !filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "BloomFilter should be empty!");
|
BOOST_CHECK_MESSAGE( !filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "Bloom filter should be empty!");
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize_with_tweak)
|
BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize_with_tweak)
|
||||||
|
@ -62,15 +62,15 @@ BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize_with_tweak)
|
||||||
CBloomFilter filter(3, 0.01, 2147483649UL, BLOOM_UPDATE_ALL);
|
CBloomFilter filter(3, 0.01, 2147483649UL, BLOOM_UPDATE_ALL);
|
||||||
|
|
||||||
filter.insert(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8"));
|
filter.insert(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8"));
|
||||||
BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "BloomFilter doesn't contain just-inserted object!");
|
BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "Bloom filter doesn't contain just-inserted object!");
|
||||||
// One bit different in first byte
|
// One bit different in first byte
|
||||||
BOOST_CHECK_MESSAGE(!filter.contains(ParseHex("19108ad8ed9bb6274d3980bab5a85c048f0950c8")), "BloomFilter contains something it shouldn't!");
|
BOOST_CHECK_MESSAGE(!filter.contains(ParseHex("19108ad8ed9bb6274d3980bab5a85c048f0950c8")), "Bloom filter contains something it shouldn't!");
|
||||||
|
|
||||||
filter.insert(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32eee"));
|
filter.insert(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32eee"));
|
||||||
BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32eee")), "BloomFilter doesn't contain just-inserted object (2)!");
|
BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32eee")), "Bloom filter doesn't contain just-inserted object (2)!");
|
||||||
|
|
||||||
filter.insert(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729c5"));
|
filter.insert(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729c5"));
|
||||||
BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729c5")), "BloomFilter doesn't contain just-inserted object (3)!");
|
BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729c5")), "Bloom filter doesn't contain just-inserted object (3)!");
|
||||||
|
|
||||||
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
||||||
stream << filter;
|
stream << filter;
|
||||||
|
|
Loading…
Reference in a new issue