mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 06:43:45 +01:00
This is a follow-up to previous commits moving the chain constants out of chainparamsbase. The script removes the chainparamsbase header in all files where it is included, but not used. This is done by filtering against all defined symbols of the header as well as its respective .cpp file. The kernel chainparams now no longer relies on chainparamsbase. -BEGIN VERIFY SCRIPT- sed -i '/#include <chainparamsbase.h>/d' $( git grep -l 'chainparamsbase.h' | xargs grep -L 'CBaseChainParams\|CreateBaseChainParams\|SetupChainParamsBaseOptions\|BaseParams\|SelectBaseParams\|chainparamsbase.cpp' ) -END VERIFY SCRIPT-
80 lines
2.5 KiB
C++
80 lines
2.5 KiB
C++
// Copyright (c) 2020-2022 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#include <chainparams.h>
|
|
#include <net.h>
|
|
#include <net_permissions.h>
|
|
#include <netaddress.h>
|
|
#include <protocol.h>
|
|
#include <random.h>
|
|
#include <test/fuzz/FuzzedDataProvider.h>
|
|
#include <test/fuzz/fuzz.h>
|
|
#include <test/fuzz/util.h>
|
|
#include <test/fuzz/util/net.h>
|
|
#include <test/util/net.h>
|
|
#include <test/util/setup_common.h>
|
|
#include <util/asmap.h>
|
|
#include <util/chaintype.h>
|
|
|
|
#include <cstdint>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
void initialize_net()
|
|
{
|
|
static const auto testing_setup = MakeNoLogFileContext<>(ChainType::MAIN);
|
|
}
|
|
|
|
FUZZ_TARGET_INIT(net, initialize_net)
|
|
{
|
|
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
|
|
SetMockTime(ConsumeTime(fuzzed_data_provider));
|
|
CNode node{ConsumeNode(fuzzed_data_provider)};
|
|
node.SetCommonVersion(fuzzed_data_provider.ConsumeIntegral<int>());
|
|
LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10000) {
|
|
CallOneOf(
|
|
fuzzed_data_provider,
|
|
[&] {
|
|
node.CloseSocketDisconnect();
|
|
},
|
|
[&] {
|
|
CNodeStats stats;
|
|
node.CopyStats(stats);
|
|
},
|
|
[&] {
|
|
const CNode* add_ref_node = node.AddRef();
|
|
assert(add_ref_node == &node);
|
|
},
|
|
[&] {
|
|
if (node.GetRefCount() > 0) {
|
|
node.Release();
|
|
}
|
|
},
|
|
[&] {
|
|
const std::optional<CService> service_opt = ConsumeDeserializable<CService>(fuzzed_data_provider);
|
|
if (!service_opt) {
|
|
return;
|
|
}
|
|
node.SetAddrLocal(*service_opt);
|
|
},
|
|
[&] {
|
|
const std::vector<uint8_t> b = ConsumeRandomLengthByteVector(fuzzed_data_provider);
|
|
bool complete;
|
|
node.ReceiveMsgBytes(b, complete);
|
|
});
|
|
}
|
|
|
|
(void)node.GetAddrLocal();
|
|
(void)node.GetId();
|
|
(void)node.GetLocalNonce();
|
|
const int ref_count = node.GetRefCount();
|
|
assert(ref_count >= 0);
|
|
(void)node.GetCommonVersion();
|
|
|
|
const NetPermissionFlags net_permission_flags = ConsumeWeakEnum(fuzzed_data_provider, ALL_NET_PERMISSION_FLAGS);
|
|
(void)node.HasPermission(net_permission_flags);
|
|
(void)node.ConnectedThroughNetwork();
|
|
}
|