aboutsummaryrefslogtreecommitdiff
path: root/src/test/net_tests.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@protonmail.com>2020-10-12 18:30:14 +0200
committerWladimir J. van der Laan <laanwj@protonmail.com>2020-10-12 18:40:45 +0200
commitf79a4a895279ba4efa43494270633f94f7d18342 (patch)
treecd511bde84b87f1d0650a6078dae655fe89527f9 /src/test/net_tests.cpp
parentaf22322dab1a2277483b2512723491a5fad1a606 (diff)
parent3984b78cd7f49e409377f2175a56e8e4bd71d1d8 (diff)
Merge #19998: net: Add CNode::ConnectedThroughNetwork member function
3984b78cd7f49e409377f2175a56e8e4bd71d1d8 test: Add tests for CNode::ConnectedThroughNetwork (Hennadii Stepanov) 49fba9c1aa699d3aa47ea4dafe07b47c8d0aac6e net: Add CNode::ConnectedThroughNetwork member function (Hennadii Stepanov) d4dde24034d7467883b290111da60527ab8048f8 net: Add CNode::m_inbound_onion data member (Hennadii Stepanov) Pull request description: This PR: - adds `CNode::ConnectedThroughNetwork` member function - is based on #19991, and only last two commits belong to it - is required for https://github.com/bitcoin-core/gui/pull/86 and #20002 ACKs for top commit: jonatack: re-ACK 3984b78cd7f49e409377f2175a56e8e4bd71d1d8 per `git diff 3989fcf 3984b78c` laanwj: Code review ACK 3984b78cd7f49e409377f2175a56e8e4bd71d1d8 Tree-SHA512: 23a9c8bca8dca75113b5505fe443b294f2d42d03c98c7e34919da12d8396beb8d0ada3a58ae16e3da04b7044395f72cf9c216625afc078256cd6c897ac42bf3d
Diffstat (limited to 'src/test/net_tests.cpp')
-rw-r--r--src/test/net_tests.cpp45
1 files changed, 42 insertions, 3 deletions
diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp
index 121a16e548..37eca8b7ef 100644
--- a/src/test/net_tests.cpp
+++ b/src/test/net_tests.cpp
@@ -185,21 +185,60 @@ BOOST_AUTO_TEST_CASE(cnode_simple_test)
CAddress addr = CAddress(CService(ipv4Addr, 7777), NODE_NETWORK);
std::string pszDest;
- std::unique_ptr<CNode> pnode1 = MakeUnique<CNode>(id++, NODE_NETWORK, height, hSocket, addr, 0, 0, CAddress(), pszDest, ConnectionType::OUTBOUND_FULL_RELAY);
+ std::unique_ptr<CNode> pnode1 = MakeUnique<CNode>(
+ id++, NODE_NETWORK, height, hSocket, addr,
+ /* nKeyedNetGroupIn = */ 0,
+ /* nLocalHostNonceIn = */ 0,
+ CAddress(), pszDest, ConnectionType::OUTBOUND_FULL_RELAY);
BOOST_CHECK(pnode1->IsFullOutboundConn() == true);
BOOST_CHECK(pnode1->IsManualConn() == false);
BOOST_CHECK(pnode1->IsBlockOnlyConn() == false);
BOOST_CHECK(pnode1->IsFeelerConn() == false);
BOOST_CHECK(pnode1->IsAddrFetchConn() == false);
BOOST_CHECK(pnode1->IsInboundConn() == false);
-
- std::unique_ptr<CNode> pnode2 = MakeUnique<CNode>(id++, NODE_NETWORK, height, hSocket, addr, 1, 1, CAddress(), pszDest, ConnectionType::INBOUND);
+ BOOST_CHECK_EQUAL(pnode1->ConnectedThroughNetwork(), Network::NET_IPV4);
+
+ std::unique_ptr<CNode> pnode2 = MakeUnique<CNode>(
+ id++, NODE_NETWORK, height, hSocket, addr,
+ /* nKeyedNetGroupIn = */ 1,
+ /* nLocalHostNonceIn = */ 1,
+ CAddress(), pszDest, ConnectionType::INBOUND,
+ /* inbound_onion = */ false);
BOOST_CHECK(pnode2->IsFullOutboundConn() == false);
BOOST_CHECK(pnode2->IsManualConn() == false);
BOOST_CHECK(pnode2->IsBlockOnlyConn() == false);
BOOST_CHECK(pnode2->IsFeelerConn() == false);
BOOST_CHECK(pnode2->IsAddrFetchConn() == false);
BOOST_CHECK(pnode2->IsInboundConn() == true);
+ BOOST_CHECK_EQUAL(pnode2->ConnectedThroughNetwork(), Network::NET_IPV4);
+
+ std::unique_ptr<CNode> pnode3 = MakeUnique<CNode>(
+ id++, NODE_NETWORK, height, hSocket, addr,
+ /* nKeyedNetGroupIn = */ 0,
+ /* nLocalHostNonceIn = */ 0,
+ CAddress(), pszDest, ConnectionType::OUTBOUND_FULL_RELAY,
+ /* inbound_onion = */ true);
+ BOOST_CHECK(pnode3->IsFullOutboundConn() == true);
+ BOOST_CHECK(pnode3->IsManualConn() == false);
+ BOOST_CHECK(pnode3->IsBlockOnlyConn() == false);
+ BOOST_CHECK(pnode3->IsFeelerConn() == false);
+ BOOST_CHECK(pnode3->IsAddrFetchConn() == false);
+ BOOST_CHECK(pnode3->IsInboundConn() == false);
+ BOOST_CHECK_EQUAL(pnode3->ConnectedThroughNetwork(), Network::NET_IPV4);
+
+ std::unique_ptr<CNode> pnode4 = MakeUnique<CNode>(
+ id++, NODE_NETWORK, height, hSocket, addr,
+ /* nKeyedNetGroupIn = */ 1,
+ /* nLocalHostNonceIn = */ 1,
+ CAddress(), pszDest, ConnectionType::INBOUND,
+ /* inbound_onion = */ true);
+ BOOST_CHECK(pnode4->IsFullOutboundConn() == false);
+ BOOST_CHECK(pnode4->IsManualConn() == false);
+ BOOST_CHECK(pnode4->IsBlockOnlyConn() == false);
+ BOOST_CHECK(pnode4->IsFeelerConn() == false);
+ BOOST_CHECK(pnode4->IsAddrFetchConn() == false);
+ BOOST_CHECK(pnode4->IsInboundConn() == true);
+ BOOST_CHECK_EQUAL(pnode4->ConnectedThroughNetwork(), Network::NET_ONION);
}
BOOST_AUTO_TEST_CASE(cnetaddr_basic)