Coverage Report

Created: 2026-07-30 14:31

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/root/bitcoin/src/test/fuzz/cuckoocache.cpp
Line
Count
Source
1
// Copyright (c) 2020-present The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#include <cuckoocache.h>
6
#include <script/sigcache.h>
7
#include <test/fuzz/FuzzedDataProvider.h>
8
#include <test/fuzz/fuzz.h>
9
#include <test/fuzz/util.h>
10
#include <test/util/setup_common.h>
11
#include <util/byte_units.h>
12
13
#include <cstdint>
14
#include <string>
15
#include <vector>
16
17
namespace {
18
FuzzedDataProvider* fuzzed_data_provider_ptr = nullptr;
19
20
struct RandomHasher {
21
    template <uint8_t>
22
    uint32_t operator()(const bool& /* unused */) const
23
0
    {
24
0
        assert(fuzzed_data_provider_ptr != nullptr);
  Branch (24:9): [True: 0, False: 0]
  Branch (24:9): [True: 0, False: 0]
  Branch (24:9): [True: 0, False: 0]
  Branch (24:9): [True: 0, False: 0]
  Branch (24:9): [True: 0, False: 0]
  Branch (24:9): [True: 0, False: 0]
  Branch (24:9): [True: 0, False: 0]
  Branch (24:9): [True: 0, False: 0]
25
0
        return fuzzed_data_provider_ptr->ConsumeIntegral<uint32_t>();
26
0
    }
Unexecuted instantiation: cuckoocache.cpp:_ZNK12_GLOBAL__N_112RandomHasherclILh0EEEjRKb
Unexecuted instantiation: cuckoocache.cpp:_ZNK12_GLOBAL__N_112RandomHasherclILh1EEEjRKb
Unexecuted instantiation: cuckoocache.cpp:_ZNK12_GLOBAL__N_112RandomHasherclILh2EEEjRKb
Unexecuted instantiation: cuckoocache.cpp:_ZNK12_GLOBAL__N_112RandomHasherclILh3EEEjRKb
Unexecuted instantiation: cuckoocache.cpp:_ZNK12_GLOBAL__N_112RandomHasherclILh4EEEjRKb
Unexecuted instantiation: cuckoocache.cpp:_ZNK12_GLOBAL__N_112RandomHasherclILh5EEEjRKb
Unexecuted instantiation: cuckoocache.cpp:_ZNK12_GLOBAL__N_112RandomHasherclILh6EEEjRKb
Unexecuted instantiation: cuckoocache.cpp:_ZNK12_GLOBAL__N_112RandomHasherclILh7EEEjRKb
27
};
28
} // namespace
29
30
FUZZ_TARGET(cuckoocache)
31
0
{
32
0
    FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
33
0
    fuzzed_data_provider_ptr = &fuzzed_data_provider;
34
0
    CuckooCache::cache<int, RandomHasher> cuckoo_cache{};
35
0
    if (fuzzed_data_provider.ConsumeBool()) {
  Branch (35:9): [True: 0, False: 0]
36
0
        const size_t megabytes = fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, 16);
37
0
        cuckoo_cache.setup_bytes(megabytes * 1_MiB);
38
0
    } else {
39
0
        cuckoo_cache.setup(fuzzed_data_provider.ConsumeIntegralInRange<uint32_t>(0, 4096));
40
0
    }
41
0
    LIMITED_WHILE (fuzzed_data_provider.ConsumeBool(), 10000) {
42
0
        if (fuzzed_data_provider.ConsumeBool()) {
  Branch (42:13): [True: 0, False: 0]
43
0
            cuckoo_cache.insert(fuzzed_data_provider.ConsumeBool());
44
0
        } else {
45
0
            auto e = fuzzed_data_provider.ConsumeBool();
46
0
            auto erase = fuzzed_data_provider.ConsumeBool();
47
0
            cuckoo_cache.contains(e, erase);
48
0
        }
49
0
    }
50
0
    fuzzed_data_provider_ptr = nullptr;
51
0
}