From ecfe507e07e9bdab210e04ebd3fc3b8ae9d6a094 Mon Sep 17 00:00:00 2001 From: brunoerg Date: Mon, 17 Jul 2023 10:50:48 -0300 Subject: fuzz: use `ConnmanTestMsg` in `connman` Using `ConnmanTestMsg` we can add nodes and be more effective fuzzing functions like `DisconnectNode`, `FindNode`, `GetNodeStats` and other ones. --- src/test/fuzz/connman.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/test/fuzz') diff --git a/src/test/fuzz/connman.cpp b/src/test/fuzz/connman.cpp index 23fadd8984..cdf240dc59 100644 --- a/src/test/fuzz/connman.cpp +++ b/src/test/fuzz/connman.cpp @@ -32,7 +32,7 @@ FUZZ_TARGET(connman, .init = initialize_connman) { FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()}; SetMockTime(ConsumeTime(fuzzed_data_provider)); - CConnman connman{fuzzed_data_provider.ConsumeIntegral(), + ConnmanTestMsg connman{fuzzed_data_provider.ConsumeIntegral(), fuzzed_data_provider.ConsumeIntegral(), *g_setup->m_node.addrman, *g_setup->m_node.netgroupman, @@ -41,6 +41,12 @@ FUZZ_TARGET(connman, .init = initialize_connman) CNode random_node = ConsumeNode(fuzzed_data_provider); CSubNet random_subnet; std::string random_string; + + LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 100) { + CNode& p2p_node{*ConsumeNodeAsUniquePtr(fuzzed_data_provider).release()}; + connman.AddTestNode(p2p_node); + } + LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10000) { CallOneOf( fuzzed_data_provider, @@ -128,4 +134,6 @@ FUZZ_TARGET(connman, .init = initialize_connman) (void)connman.GetTotalBytesSent(); (void)connman.GetTryNewOutboundPeer(); (void)connman.GetUseAddrmanOutgoing(); + + connman.ClearTestNodes(); } -- cgit v1.2.3