Skip to content
Prev Previous commit
Next Next commit
fuzz: add CConnman::CreateNodeFromAcceptedSocket() to the tests
  • Loading branch information
vasild committed Aug 16, 2023
commit 1545b555175be1f095bdedd00ff4545db3693371
12 changes: 12 additions & 0 deletions src/test/fuzz/connman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <util/translation.h>

#include <cstdint>
#include <memory>
#include <vector>

namespace {
Expand Down Expand Up @@ -158,6 +159,17 @@ FUZZ_TARGET(connman, .init = initialize_connman)
}

connman.OpenNetworkConnection(to_addr, count_failure, grant_ptr, to_str, conn_type);
},
[&] {
connman.SetNetworkActive(true);

NetPermissionFlags permissions{
ConsumeWeakEnum(fuzzed_data_provider, ALL_NET_PERMISSION_FLAGS)};
auto me = ConsumeAddress(fuzzed_data_provider);
auto peer = ConsumeAddress(fuzzed_data_provider);
auto sock = CreateSock(peer);

connman.CreateNodeFromAcceptedSocketPublic(std::move(sock), permissions, me, peer);
});
}
(void)connman.GetAddedNodeInfo();
Expand Down
8 changes: 8 additions & 0 deletions src/test/util/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ struct ConnmanTestMsg : public CConnman {
m_nodes.clear();
}

void CreateNodeFromAcceptedSocketPublic(std::unique_ptr<Sock> sock,
NetPermissionFlags permissions,
const CAddress& addr_bind,
const CAddress& addr_peer)
{
CreateNodeFromAcceptedSocket(std::move(sock), permissions, addr_bind, addr_peer);
}

void Handshake(CNode& node,
bool successfully_connected,
ServiceFlags remote_services,
Expand Down