Skip to content

Commit b7136c1

Browse files
author
MarcoFalke
committed
Merge bitcoin#20686: fuzz, refactor: replace CNode code with fuzz/util.h::ConsumeNode()
23d8f34 fuzz: replace CNode code with fuzz/util.h::ConsumeNode() (Jon Atack) Pull request description: Noticed this while updating the CNode fuzzing in bitcoin#20210. - cc26fab created `test/fuzz/net.cpp` in May 2020 - 79ef832 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 23d8f34 Tree-SHA512: 26f7685395b3d48fcf40dde0d479d5c2fb4e953ec9371940b19eee16bb30aee4840b081e1a918b924a9704c1bef484302ea3e8fe63819a3bba73e7eb805164f1
2 parents 190d3d8 + 23d8f34 commit b7136c1

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

src/test/fuzz/net.cpp

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,7 @@ FUZZ_TARGET_INIT(net, initialize_net)
2828
{
2929
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
3030
SetMockTime(ConsumeTime(fuzzed_data_provider));
31-
const std::optional<CAddress> address = ConsumeDeserializable<CAddress>(fuzzed_data_provider);
32-
if (!address) {
33-
return;
34-
}
35-
const std::optional<CAddress> address_bind = ConsumeDeserializable<CAddress>(fuzzed_data_provider);
36-
if (!address_bind) {
37-
return;
38-
}
39-
40-
CNode node{fuzzed_data_provider.ConsumeIntegral<NodeId>(),
41-
static_cast<ServiceFlags>(fuzzed_data_provider.ConsumeIntegral<uint64_t>()),
42-
fuzzed_data_provider.ConsumeIntegral<int>(),
43-
INVALID_SOCKET,
44-
*address,
45-
fuzzed_data_provider.ConsumeIntegral<uint64_t>(),
46-
fuzzed_data_provider.ConsumeIntegral<uint64_t>(),
47-
*address_bind,
48-
fuzzed_data_provider.ConsumeRandomLengthString(32),
49-
fuzzed_data_provider.PickValueInArray({ConnectionType::INBOUND, ConnectionType::OUTBOUND_FULL_RELAY, ConnectionType::MANUAL, ConnectionType::FEELER, ConnectionType::BLOCK_RELAY, ConnectionType::ADDR_FETCH}),
50-
fuzzed_data_provider.ConsumeBool()};
31+
CNode node{ConsumeNode(fuzzed_data_provider)};
5132
node.SetCommonVersion(fuzzed_data_provider.ConsumeIntegral<int>());
5233
while (fuzzed_data_provider.ConsumeBool()) {
5334
switch (fuzzed_data_provider.ConsumeIntegralInRange<int>(0, 10)) {

0 commit comments

Comments
 (0)