Skip to content

Commit 993d1ec

Browse files
committed
test, fuzz: fix constructing CNode with invalid inbound_onion
as CNode ctor should only be passed inbound_onion = true when the connection is inbound
1 parent b7136c1 commit 993d1ec

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/test/fuzz/util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ CNode ConsumeNode(FuzzedDataProvider& fuzzed_data_provider) noexcept
298298
const CAddress addr_bind = ConsumeAddress(fuzzed_data_provider);
299299
const std::string addr_name = fuzzed_data_provider.ConsumeRandomLengthString(64);
300300
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 bool inbound_onion = fuzzed_data_provider.ConsumeBool();
301+
const bool inbound_onion{conn_type == ConnectionType::INBOUND ? fuzzed_data_provider.ConsumeBool() : false};
302302
return {node_id, local_services, my_starting_height, socket, address, keyed_net_group, local_host_nonce, addr_bind, addr_name, conn_type, inbound_onion};
303303
}
304304

src/test/net_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ BOOST_AUTO_TEST_CASE(cnode_simple_test)
221221
/* nKeyedNetGroupIn = */ 0,
222222
/* nLocalHostNonceIn = */ 0,
223223
CAddress(), pszDest, ConnectionType::OUTBOUND_FULL_RELAY,
224-
/* inbound_onion = */ true);
224+
/* inbound_onion = */ false);
225225
BOOST_CHECK(pnode3->IsFullOutboundConn() == true);
226226
BOOST_CHECK(pnode3->IsManualConn() == false);
227227
BOOST_CHECK(pnode3->IsBlockOnlyConn() == false);

0 commit comments

Comments
 (0)