|
|
|
@ -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)
|
|
|
|
|