mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-08 20:28:55 +02:00
Merge #20686: fuzz, refactor: replace CNode code with fuzz/util.h::ConsumeNode()
23d8f346896c806581189c9eb870c7833c09f5be fuzz: replace CNode code with fuzz/util.h::ConsumeNode() (Jon Atack) Pull request description: Noticed this while updating the CNode fuzzing in #20210. - cc26fab48d76a813d798657b18ae1af08a301150 created `test/fuzz/net.cpp` in May 2020 - 79ef8324d4c85ed16a304e98805724b8a created a CNode factory utility `test/fuzz/util.h::ConsumeNode()` in October 2020 This PR updates `fuzz/net.cpp` from the first commit to use `ConsumeNode()` from the second commit. ACKs for top commit: MarcoFalke: ACK 23d8f346896c806581189c9eb870c7833c09f5be Tree-SHA512: 26f7685395b3d48fcf40dde0d479d5c2fb4e953ec9371940b19eee16bb30aee4840b081e1a918b924a9704c1bef484302ea3e8fe63819a3bba73e7eb805164f1
This commit is contained in:
commit
b7136c11ab
@ -28,26 +28,7 @@ FUZZ_TARGET_INIT(net, initialize_net)
|
||||
{
|
||||
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
|
||||
SetMockTime(ConsumeTime(fuzzed_data_provider));
|
||||
const std::optional<CAddress> address = ConsumeDeserializable<CAddress>(fuzzed_data_provider);
|
||||
if (!address) {
|
||||
return;
|
||||
}
|
||||
const std::optional<CAddress> address_bind = ConsumeDeserializable<CAddress>(fuzzed_data_provider);
|
||||
if (!address_bind) {
|
||||
return;
|
||||
}
|
||||
|
||||
CNode node{fuzzed_data_provider.ConsumeIntegral<NodeId>(),
|
||||
static_cast<ServiceFlags>(fuzzed_data_provider.ConsumeIntegral<uint64_t>()),
|
||||
fuzzed_data_provider.ConsumeIntegral<int>(),
|
||||
INVALID_SOCKET,
|
||||
*address,
|
||||
fuzzed_data_provider.ConsumeIntegral<uint64_t>(),
|
||||
fuzzed_data_provider.ConsumeIntegral<uint64_t>(),
|
||||
*address_bind,
|
||||
fuzzed_data_provider.ConsumeRandomLengthString(32),
|
||||
fuzzed_data_provider.PickValueInArray({ConnectionType::INBOUND, ConnectionType::OUTBOUND_FULL_RELAY, ConnectionType::MANUAL, ConnectionType::FEELER, ConnectionType::BLOCK_RELAY, ConnectionType::ADDR_FETCH}),
|
||||
fuzzed_data_provider.ConsumeBool()};
|
||||
CNode node{ConsumeNode(fuzzed_data_provider)};
|
||||
node.SetCommonVersion(fuzzed_data_provider.ConsumeIntegral<int>());
|
||||
while (fuzzed_data_provider.ConsumeBool()) {
|
||||
switch (fuzzed_data_provider.ConsumeIntegralInRange<int>(0, 10)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user