MCPcopy Create free account
hub / github.com/ElementsProject/elements / FUZZ_TARGET_INIT

Function FUZZ_TARGET_INIT

src/test/fuzz/net.cpp:29–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27}
28
29FUZZ_TARGET_INIT(net, initialize_net)
30{
31 FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
32 SetMockTime(ConsumeTime(fuzzed_data_provider));
33 CNode node{ConsumeNode(fuzzed_data_provider)};
34 node.SetCommonVersion(fuzzed_data_provider.ConsumeIntegral<int>());
35 LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10000) {
36 CallOneOf(
37 fuzzed_data_provider,
38 [&] {
39 node.CloseSocketDisconnect();
40 },
41 [&] {
42 CNodeStats stats;
43 node.CopyStats(stats);
44 },
45 [&] {
46 const CNode* add_ref_node = node.AddRef();
47 assert(add_ref_node == &node);
48 },
49 [&] {
50 if (node.GetRefCount() > 0) {
51 node.Release();
52 }
53 },
54 [&] {
55 const std::optional<CInv> inv_opt = ConsumeDeserializable<CInv>(fuzzed_data_provider);
56 if (!inv_opt) {
57 return;
58 }
59 node.AddKnownTx(inv_opt->hash);
60 },
61 [&] {
62 node.PushTxInventory(ConsumeUInt256(fuzzed_data_provider));
63 },
64 [&] {
65 const std::optional<CService> service_opt = ConsumeDeserializable<CService>(fuzzed_data_provider);
66 if (!service_opt) {
67 return;
68 }
69 node.SetAddrLocal(*service_opt);
70 },
71 [&] {
72 const std::vector<uint8_t> b = ConsumeRandomLengthByteVector(fuzzed_data_provider);
73 bool complete;
74 node.ReceiveMsgBytes(b, complete);
75 });
76 }
77
78 (void)node.GetAddrLocal();
79 (void)node.GetId();
80 (void)node.GetLocalNonce();
81 (void)node.GetLocalServices();
82 const int ref_count = node.GetRefCount();
83 assert(ref_count >= 0);
84 (void)node.GetCommonVersion();
85
86 const NetPermissionFlags net_permission_flags = ConsumeWeakEnum(fuzzed_data_provider, ALL_NET_PERMISSION_FLAGS);

Callers

nothing calls this directly

Calls 15

SetMockTimeFunction · 0.85
ConsumeTimeFunction · 0.85
ConsumeNodeFunction · 0.85
CallOneOfFunction · 0.85
ConsumeUInt256Function · 0.85
ConsumeWeakEnumFunction · 0.85
SetCommonVersionMethod · 0.80
ConsumeBoolMethod · 0.80
CloseSocketDisconnectMethod · 0.80
CopyStatsMethod · 0.80
GetRefCountMethod · 0.80

Tested by

no test coverage detected