| 287 | |
| 288 | template <bool ReturnUniquePtr = false> |
| 289 | auto ConsumeNode(FuzzedDataProvider& fuzzed_data_provider, const std::optional<NodeId>& node_id_in = std::nullopt) noexcept |
| 290 | { |
| 291 | const NodeId node_id = node_id_in.value_or(fuzzed_data_provider.ConsumeIntegralInRange<NodeId>(0, std::numeric_limits<NodeId>::max())); |
| 292 | const ServiceFlags local_services = ConsumeWeakEnum(fuzzed_data_provider, ALL_SERVICE_FLAGS); |
| 293 | const auto sock = std::make_shared<FuzzedSock>(fuzzed_data_provider); |
| 294 | const CAddress address = ConsumeAddress(fuzzed_data_provider); |
| 295 | const uint64_t keyed_net_group = fuzzed_data_provider.ConsumeIntegral<uint64_t>(); |
| 296 | const uint64_t local_host_nonce = fuzzed_data_provider.ConsumeIntegral<uint64_t>(); |
| 297 | const CAddress addr_bind = ConsumeAddress(fuzzed_data_provider); |
| 298 | const std::string addr_name = fuzzed_data_provider.ConsumeRandomLengthString(64); |
| 299 | const ConnectionType conn_type = fuzzed_data_provider.PickValueInArray(ALL_CONNECTION_TYPES); |
| 300 | const bool inbound_onion{conn_type == ConnectionType::INBOUND ? fuzzed_data_provider.ConsumeBool() : false}; |
| 301 | if constexpr (ReturnUniquePtr) { |
| 302 | return std::make_unique<CNode>(node_id, |
| 303 | local_services, |
| 304 | sock, |
| 305 | address, |
| 306 | keyed_net_group, |
| 307 | local_host_nonce, |
| 308 | addr_bind, |
| 309 | addr_name, |
| 310 | conn_type, |
| 311 | inbound_onion); |
| 312 | } else { |
| 313 | return CNode{node_id, |
| 314 | local_services, |
| 315 | sock, |
| 316 | address, |
| 317 | keyed_net_group, |
| 318 | local_host_nonce, |
| 319 | addr_bind, |
| 320 | addr_name, |
| 321 | conn_type, |
| 322 | inbound_onion}; |
| 323 | } |
| 324 | } |
| 325 | inline std::unique_ptr<CNode> ConsumeNodeAsUniquePtr(FuzzedDataProvider& fdp, const std::optional<NodeId>& node_id_in = std::nullopt) { return ConsumeNode<true>(fdp, node_id_in); } |
| 326 | |
| 327 | void FillNode(FuzzedDataProvider& fuzzed_data_provider, ConnmanTestMsg& connman, PeerManager& peerman, CNode& node) noexcept; |
no test coverage detected