Skip to content

Commit faaef94

Browse files
author
MarcoFalke
committed
fuzz: [refactor] Extract ALL_CONNECTION_TYPES constant
1 parent fa42da2 commit faaef94

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/test/fuzz/util.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <streams.h>
2323
#include <test/fuzz/FuzzedDataProvider.h>
2424
#include <test/fuzz/fuzz.h>
25+
#include <test/util/net.h>
2526
#include <test/util/setup_common.h>
2627
#include <txmempool.h>
2728
#include <uint256.h>
@@ -297,7 +298,7 @@ auto ConsumeNode(FuzzedDataProvider& fuzzed_data_provider, const std::optional<N
297298
const uint64_t local_host_nonce = fuzzed_data_provider.ConsumeIntegral<uint64_t>();
298299
const CAddress addr_bind = ConsumeAddress(fuzzed_data_provider);
299300
const std::string addr_name = fuzzed_data_provider.ConsumeRandomLengthString(64);
300-
const ConnectionType conn_type = fuzzed_data_provider.PickValueInArray({ConnectionType::INBOUND, ConnectionType::OUTBOUND_FULL_RELAY, ConnectionType::MANUAL, ConnectionType::FEELER, ConnectionType::BLOCK_RELAY, ConnectionType::ADDR_FETCH});
301+
const ConnectionType conn_type = fuzzed_data_provider.PickValueInArray(ALL_CONNECTION_TYPES);
301302
const bool inbound_onion{conn_type == ConnectionType::INBOUND ? fuzzed_data_provider.ConsumeBool() : false};
302303
if constexpr (ReturnUniquePtr) {
303304
return std::make_unique<CNode>(node_id, local_services, socket, address, keyed_net_group, local_host_nonce, addr_bind, addr_name, conn_type, inbound_onion);

src/test/util/net.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,13 @@ struct ConnmanTestMsg : public CConnman {
3030
bool ReceiveMsgFrom(CNode& node, CSerializedNetMsg& ser_msg) const;
3131
};
3232

33+
constexpr ConnectionType ALL_CONNECTION_TYPES[]{
34+
ConnectionType::INBOUND,
35+
ConnectionType::OUTBOUND_FULL_RELAY,
36+
ConnectionType::MANUAL,
37+
ConnectionType::FEELER,
38+
ConnectionType::BLOCK_RELAY,
39+
ConnectionType::ADDR_FETCH,
40+
};
41+
3342
#endif // BITCOIN_TEST_UTIL_NET_H

0 commit comments

Comments
 (0)