Please correct me if I misunderstood something, but before this change CDBWrapper always configured LevelDB with NewBloomFilterPolicy(10), so we never explicitly exercised filter_policy == nullptr.
I agree that a standalone test (like the one I posted above) may be too verbose, but maybe we can extend the existing obfuscation matrix - and add CompactFull() so the read path exercises SST files created with and without a filter policy:
diff --git a/src/test/dbwrapper_tests.cpp b/src/test/dbwrapper_tests.cpp
--- a/src/test/dbwrapper_tests.cpp (revision fac744efa7745f4d02c4e17a0c5fdd6da3d92ae4)
+++ b/src/test/dbwrapper_tests.cpp (date 1782325217634)
@@ -22,7 +22,7 @@
BOOST_AUTO_TEST_CASE(dbwrapper)
{
// Perform tests both obfuscated and non-obfuscated.
- for (const bool obfuscate : {false, true}) {
+ for (const auto [obfuscate, bloom] : {std::pair{true, true}, std::pair{true, false} std::pair{false, true}, std::pair{false, false}}) {
constexpr size_t CACHE_SIZE{1_MiB};
const fs::path path{m_args.GetDataDirBase() / "dbwrapper"};
@@ -31,7 +31,7 @@
// Write values
{
- CDBWrapper dbw{{.path = path, .cache_bytes = CACHE_SIZE, .wipe_data = true, .obfuscate = obfuscate}};
+ CDBWrapper dbw{{.path = path, .cache_bytes = CACHE_SIZE, .wipe_data = true, .obfuscate = obfuscate, .bloom_filter = bloom}};
BOOST_CHECK_EQUAL(obfuscate, !dbw.IsEmpty());
// Ensure that we're doing real obfuscation when obfuscate=true
@@ -44,17 +44,18 @@
dbw.Write(key, value);
key_values.emplace_back(key, value);
}
+ dbw.CompactFull(); // Force SST creation so reads exercise the filter policy
}
// Verify that the obfuscation key is never obfuscated
{
- CDBWrapper dbw{{.path = path, .cache_bytes = CACHE_SIZE, .obfuscate = false}};
+ CDBWrapper dbw{{.path = path, .cache_bytes = CACHE_SIZE, .obfuscate = false, .bloom_filter = bloom}};
BOOST_CHECK_EQUAL(obfuscation, dbwrapper_private::GetObfuscation(dbw));
}
// Read back the values
{
- CDBWrapper dbw{{.path = path, .cache_bytes = CACHE_SIZE, .obfuscate = obfuscate}};
+ CDBWrapper dbw{{.path = path, .cache_bytes = CACHE_SIZE, .obfuscate = obfuscate, .bloom_filter = bloom}};
// Ensure obfuscation is read back correctly
BOOST_CHECK_EQUAL(obfuscation, dbwrapper_private::GetObfuscation(dbw));
@@ -62,10 +63,12 @@
// Verify all written values
for (const auto& [key, expected_value] : key_values) {
+ BOOST_CHECK(dbw.Exists(key));
uint256 read_value{};
BOOST_CHECK(dbw.Read(key, read_value));
BOOST_CHECK_EQUAL(read_value, expected_value);
}
+ BOOST_CHECK(!dbw.Exists(uint8_t{11}));
}
}
}
@@ -197,9 +200,9 @@
BOOST_AUTO_TEST_CASE(dbwrapper_iterator)
{
// Perform tests both obfuscated and non-obfuscated.
- for (const bool obfuscate : {false, true}) {
+ for (const auto [obfuscate, bloom] : {std::pair{true, true}, std::pair{true, false}, std::pair{false, true}, std::pair{false, false}}) {
fs::path ph = m_args.GetDataDirBase() / (obfuscate ? "dbwrapper_iterator_obfuscate_true" : "dbwrapper_iterator_obfuscate_false");
- CDBWrapper dbw({.path = ph, .cache_bytes = 1_MiB, .memory_only = true, .wipe_data = false, .obfuscate = obfuscate});
+ CDBWrapper dbw({.path = ph, .cache_bytes = 1_MiB, .memory_only = true, .wipe_data = false, .obfuscate = obfuscate, .bloom_filter = bloom});
// The two keys are intentionally chosen for ordering
uint8_t key{'j'};