From faaef9434c19e3643322ee442c240c166af5adbd Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Mon, 28 Dec 2020 21:31:33 +0100 Subject: fuzz: [refactor] Extract ALL_CONNECTION_TYPES constant --- src/test/fuzz/util.h | 3 ++- src/test/util/net.h | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'src/test') diff --git a/src/test/fuzz/util.h b/src/test/fuzz/util.h index 8fdb16d2df..cd5da8aae8 100644 --- a/src/test/fuzz/util.h +++ b/src/test/fuzz/util.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -297,7 +298,7 @@ auto ConsumeNode(FuzzedDataProvider& fuzzed_data_provider, const std::optional(); const CAddress addr_bind = ConsumeAddress(fuzzed_data_provider); const std::string addr_name = fuzzed_data_provider.ConsumeRandomLengthString(64); - const ConnectionType conn_type = fuzzed_data_provider.PickValueInArray({ConnectionType::INBOUND, ConnectionType::OUTBOUND_FULL_RELAY, ConnectionType::MANUAL, ConnectionType::FEELER, ConnectionType::BLOCK_RELAY, ConnectionType::ADDR_FETCH}); + const ConnectionType conn_type = fuzzed_data_provider.PickValueInArray(ALL_CONNECTION_TYPES); const bool inbound_onion{conn_type == ConnectionType::INBOUND ? fuzzed_data_provider.ConsumeBool() : false}; if constexpr (ReturnUniquePtr) { return std::make_unique(node_id, local_services, socket, address, keyed_net_group, local_host_nonce, addr_bind, addr_name, conn_type, inbound_onion); diff --git a/src/test/util/net.h b/src/test/util/net.h index 1208e92762..5fad570c29 100644 --- a/src/test/util/net.h +++ b/src/test/util/net.h @@ -30,4 +30,13 @@ struct ConnmanTestMsg : public CConnman { bool ReceiveMsgFrom(CNode& node, CSerializedNetMsg& ser_msg) const; }; +constexpr ConnectionType ALL_CONNECTION_TYPES[]{ + ConnectionType::INBOUND, + ConnectionType::OUTBOUND_FULL_RELAY, + ConnectionType::MANUAL, + ConnectionType::FEELER, + ConnectionType::BLOCK_RELAY, + ConnectionType::ADDR_FETCH, +}; + #endif // BITCOIN_TEST_UTIL_NET_H -- cgit v1.2.3