diff options
author | Jon Atack <jon@atack.com> | 2020-12-17 16:33:56 +0100 |
---|---|---|
committer | Jon Atack <jon@atack.com> | 2020-12-17 19:56:00 +0100 |
commit | 993d1ecd191a7d9161082d4026f020cbf00835bb (patch) | |
tree | 61fb760240d31cf7acfec84df4459c856307c05c /src/test | |
parent | b7136c11ab6448142cfcc617babe866e428eeeb4 (diff) | |
download | bitcoin-993d1ecd191a7d9161082d4026f020cbf00835bb.tar.xz |
test, fuzz: fix constructing CNode with invalid inbound_onion
as CNode ctor should only be passed inbound_onion = true
when the connection is inbound
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/fuzz/util.h | 2 | ||||
-rw-r--r-- | src/test/net_tests.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/test/fuzz/util.h b/src/test/fuzz/util.h index cf666a8b93..8a2de0f9c9 100644 --- a/src/test/fuzz/util.h +++ b/src/test/fuzz/util.h @@ -298,7 +298,7 @@ CNode ConsumeNode(FuzzedDataProvider& fuzzed_data_provider) noexcept 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 bool inbound_onion = fuzzed_data_provider.ConsumeBool(); + const bool inbound_onion{conn_type == ConnectionType::INBOUND ? fuzzed_data_provider.ConsumeBool() : false}; return {node_id, local_services, my_starting_height, socket, address, keyed_net_group, local_host_nonce, addr_bind, addr_name, conn_type, inbound_onion}; } diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp index beac65942e..eb2f4cee69 100644 --- a/src/test/net_tests.cpp +++ b/src/test/net_tests.cpp @@ -221,7 +221,7 @@ BOOST_AUTO_TEST_CASE(cnode_simple_test) /* nKeyedNetGroupIn = */ 0, /* nLocalHostNonceIn = */ 0, CAddress(), pszDest, ConnectionType::OUTBOUND_FULL_RELAY, - /* inbound_onion = */ true); + /* inbound_onion = */ false); BOOST_CHECK(pnode3->IsFullOutboundConn() == true); BOOST_CHECK(pnode3->IsManualConn() == false); BOOST_CHECK(pnode3->IsBlockOnlyConn() == false); |