diff options
Diffstat (limited to 'src/test/net_peer_connection_tests.cpp')
-rw-r--r-- | src/test/net_peer_connection_tests.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/test/net_peer_connection_tests.cpp b/src/test/net_peer_connection_tests.cpp index 2dde6daee5..e60ce8b99d 100644 --- a/src/test/net_peer_connection_tests.cpp +++ b/src/test/net_peer_connection_tests.cpp @@ -43,20 +43,21 @@ static CService ip(uint32_t i) return CService{CNetAddr{s}, Params().GetDefaultPort()}; } +struct PeerTest : LogIPsTestingSetup { /** Create a peer and connect to it. If the optional `address` (IP/CJDNS only) isn't passed, a random address is created. */ -static void AddPeer(NodeId& id, std::vector<CNode*>& nodes, PeerManager& peerman, ConnmanTestMsg& connman, ConnectionType conn_type, bool onion_peer = false, std::optional<std::string> address = std::nullopt) +void AddPeer(NodeId& id, std::vector<CNode*>& nodes, PeerManager& peerman, ConnmanTestMsg& connman, ConnectionType conn_type, bool onion_peer = false, std::optional<std::string> address = std::nullopt) { CAddress addr{}; if (address.has_value()) { addr = CAddress{MaybeFlipIPv6toCJDNS(LookupNumeric(address.value(), Params().GetDefaultPort())), NODE_NONE}; } else if (onion_peer) { - auto tor_addr{g_insecure_rand_ctx.randbytes(ADDR_TORV3_SIZE)}; + auto tor_addr{m_rng.randbytes(ADDR_TORV3_SIZE)}; BOOST_REQUIRE(addr.SetSpecial(OnionToString(tor_addr))); } while (!addr.IsLocal() && !addr.IsRoutable()) { - addr = CAddress{ip(g_insecure_rand_ctx.randbits(32)), NODE_NONE}; + addr = CAddress{ip(m_rng.randbits(32)), NODE_NONE}; } BOOST_REQUIRE(addr.IsValid()); @@ -80,8 +81,9 @@ static void AddPeer(NodeId& id, std::vector<CNode*>& nodes, PeerManager& peerman connman.AddTestNode(node); } +}; // struct PeerTest -BOOST_AUTO_TEST_CASE(test_addnode_getaddednodeinfo_and_connection_detection) +BOOST_FIXTURE_TEST_CASE(test_addnode_getaddednodeinfo_and_connection_detection, PeerTest) { auto connman = std::make_unique<ConnmanTestMsg>(0x1337, 0x1337, *m_node.addrman, *m_node.netgroupman, Params()); auto peerman = PeerManager::make(*connman, *m_node.addrman, nullptr, *m_node.chainman, *m_node.mempool, *m_node.warnings, {}); |