Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2020-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#include <checkqueue.h>6#include <test/fuzz/FuzzedDataProvider.h>7#include <test/fuzz/fuzz.h>8#include <test/fuzz/util.h>10#include <cstdint>11#include <string>12#include <vector>14namespace {15struct DumbCheck {16bool result = false;18explicit DumbCheck(const bool _result) : result(_result)19{20}22std::optional<int> operator()() const23{24if (result) return std::nullopt;25return 1;26}27};28} // namespace30FUZZ_TARGET(checkqueue)31{32FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());34const unsigned int batch_size = fuzzed_data_provider.ConsumeIntegralInRange<unsigned int>(0, 1024);35CCheckQueue<DumbCheck> check_queue_1{batch_size, /*worker_threads_num=*/0};36CCheckQueue<DumbCheck> check_queue_2{batch_size, /*worker_threads_num=*/0};37std::vector<DumbCheck> checks_1;38std::vector<DumbCheck> checks_2;39const int size = fuzzed_data_provider.ConsumeIntegralInRange<int>(0, 1024);40for (int i = 0; i < size; ++i) {41const bool result = fuzzed_data_provider.ConsumeBool();42checks_1.emplace_back(result);43checks_2.emplace_back(result);44}45if (fuzzed_data_provider.ConsumeBool()) {46check_queue_1.Add(std::move(checks_1));47}48if (fuzzed_data_provider.ConsumeBool()) {49(void)check_queue_1.Complete();50}52CCheckQueueControl<DumbCheck> check_queue_control{check_queue_2};53if (fuzzed_data_provider.ConsumeBool()) {54check_queue_control.Add(std::move(checks_2));55}56if (fuzzed_data_provider.ConsumeBool()) {57(void)check_queue_control.Complete();58}59}
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.