aboutsummaryrefslogtreecommitdiff
path: root/src/test/fuzz
diff options
context:
space:
mode:
authorbrunoerg <brunoely.gc@gmail.com>2023-07-17 10:50:48 -0300
committerbrunoerg <brunoely.gc@gmail.com>2023-07-22 13:42:17 -0300
commitecfe507e07e9bdab210e04ebd3fc3b8ae9d6a094 (patch)
tree8e11cac1185dd2faee25c5bf4ceb10f4344a48c6 /src/test/fuzz
parentc123e1d2153c1f165292c99312c8c0899877d2c7 (diff)
fuzz: use `ConnmanTestMsg` in `connman`
Using `ConnmanTestMsg` we can add nodes and be more effective fuzzing functions like `DisconnectNode`, `FindNode`, `GetNodeStats` and other ones.
Diffstat (limited to 'src/test/fuzz')
-rw-r--r--src/test/fuzz/connman.cpp10
1 files changed, 9 insertions, 1 deletions
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<uint64_t>(),
+ ConnmanTestMsg connman{fuzzed_data_provider.ConsumeIntegral<uint64_t>(),
fuzzed_data_provider.ConsumeIntegral<uint64_t>(),
*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();
}