Changeset View
Changeset View
Standalone View
Standalone View
src/test/fuzz/rolling_bloom_filter.cpp
// Copyright (c) 2020 The Bitcoin Core developers | // Copyright (c) 2020 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <bloom.h> | #include <bloom.h> | ||||
#include <optional.h> | |||||
#include <test/fuzz/FuzzedDataProvider.h> | #include <test/fuzz/FuzzedDataProvider.h> | ||||
#include <test/fuzz/fuzz.h> | #include <test/fuzz/fuzz.h> | ||||
#include <test/fuzz/util.h> | #include <test/fuzz/util.h> | ||||
#include <uint256.h> | #include <uint256.h> | ||||
#include <cassert> | #include <cassert> | ||||
#include <cstdint> | #include <cstdint> | ||||
#include <string> | #include <string> | ||||
Show All 13 Lines | while (fuzzed_data_provider.remaining_bytes() > 0) { | ||||
ConsumeRandomLengthByteVector(fuzzed_data_provider); | ConsumeRandomLengthByteVector(fuzzed_data_provider); | ||||
(void)rolling_bloom_filter.contains(b); | (void)rolling_bloom_filter.contains(b); | ||||
rolling_bloom_filter.insert(b); | rolling_bloom_filter.insert(b); | ||||
const bool present = rolling_bloom_filter.contains(b); | const bool present = rolling_bloom_filter.contains(b); | ||||
assert(present); | assert(present); | ||||
break; | break; | ||||
} | } | ||||
case 1: { | case 1: { | ||||
const Optional<uint256> u256 = | const std::optional<uint256> u256 = | ||||
ConsumeDeserializable<uint256>(fuzzed_data_provider); | ConsumeDeserializable<uint256>(fuzzed_data_provider); | ||||
if (!u256) { | if (!u256) { | ||||
break; | break; | ||||
} | } | ||||
(void)rolling_bloom_filter.contains(*u256); | (void)rolling_bloom_filter.contains(*u256); | ||||
rolling_bloom_filter.insert(*u256); | rolling_bloom_filter.insert(*u256); | ||||
const bool present = rolling_bloom_filter.contains(*u256); | const bool present = rolling_bloom_filter.contains(*u256); | ||||
assert(present); | assert(present); | ||||
break; | break; | ||||
} | } | ||||
case 2: | case 2: | ||||
rolling_bloom_filter.reset(); | rolling_bloom_filter.reset(); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
} | } |