aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2023-01-11 11:39:42 -0500
committerluigi1111 <luigi1111w@gmail.com>2023-01-11 11:39:42 -0500
commitb363eebd52de5decb47ded0f9ddd10097b853c85 (patch)
tree8a519e4f04f941edf6c2dece0e99cf0e3a9590fe /tests
parentMerge pull request #8640 (diff)
parentp2p: fix exclusive node DNS resolution for certain hosts (diff)
downloadmonero-b363eebd52de5decb47ded0f9ddd10097b853c85.tar.xz
Merge pull request #8643
faaf2af p2p: fix exclusive node DNS resolution for certain hosts (Jeffrey Ryan)
Diffstat (limited to 'tests')
-rw-r--r--tests/unit_tests/net.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/unit_tests/net.cpp b/tests/unit_tests/net.cpp
index 838f1af37..af0f07db0 100644
--- a/tests/unit_tests/net.cpp
+++ b/tests/unit_tests/net.cpp
@@ -938,6 +938,41 @@ TEST(get_network_address, ipv4subnet)
namespace
{
+ void na_host_and_port_test(std::string addr, std::string exp_host, std::string exp_port)
+ {
+ std::string host{"xxxxx"};
+ std::string port{"xxxxx"};
+ net::get_network_address_host_and_port(addr, host, port);
+ EXPECT_EQ(exp_host, host);
+ EXPECT_EQ(exp_port, port);
+ }
+} // anonymous namespace
+
+TEST(get_network_address_host_and_port, ipv4)
+{
+ na_host_and_port_test("9.9.9.9", "9.9.9.9", "xxxxx");
+ na_host_and_port_test("9.9.9.9:18081", "9.9.9.9", "18081");
+}
+
+TEST(get_network_address_host_and_port, ipv6)
+{
+ na_host_and_port_test("::ffff", "::ffff", "xxxxx");
+ na_host_and_port_test("[::ffff]", "::ffff", "xxxxx");
+ na_host_and_port_test("[::ffff]:00231", "::ffff", "00231");
+ na_host_and_port_test("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", "xxxxx");
+ na_host_and_port_test("[7777:7777:7777:7777:7777:7777:7777:7777]", "7777:7777:7777:7777:7777:7777:7777:7777", "xxxxx");
+ na_host_and_port_test("[7777:7777:7777:7777:7777:7777:7777:7777]:48080", "7777:7777:7777:7777:7777:7777:7777:7777", "48080");
+}
+
+TEST(get_network_address_host_and_port, hostname)
+{
+ na_host_and_port_test("localhost", "localhost", "xxxxx");
+ na_host_and_port_test("bar:29080", "bar", "29080"); // Issue https://github.com/monero-project/monero/issues/8633
+ na_host_and_port_test("xmrchain.net:18081", "xmrchain.net", "18081");
+}
+
+namespace
+{
using stream_type = boost::asio::ip::tcp;
struct io_thread