diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-03-29 10:47:53 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-07-16 11:35:53 +0000 |
commit | 65c40049633f0c5db3c24af8716bb683520f368c (patch) | |
tree | 9531d5d4c2cfa4e5a5b1ac35cea13af1b173ccbe /tests/unit_tests/net.cpp | |
parent | p2p: store network address directly in blocked host list (diff) | |
download | monero-65c40049633f0c5db3c24af8716bb683520f368c.tar.xz |
allow blocking whole subnets
Diffstat (limited to '')
-rw-r--r-- | tests/unit_tests/net.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/unit_tests/net.cpp b/tests/unit_tests/net.cpp index 326e63db8..3acf75f3b 100644 --- a/tests/unit_tests/net.cpp +++ b/tests/unit_tests/net.cpp @@ -524,6 +524,24 @@ TEST(get_network_address, ipv4) EXPECT_STREQ("23.0.0.254:2000", address->str().c_str()); } +TEST(get_network_address, ipv4subnet) +{ + expect<epee::net_utils::ipv4_network_subnet> address = net::get_ipv4_subnet_address("0.0.0.0", true); + EXPECT_STREQ("0.0.0.0/32", address->str().c_str()); + + address = net::get_ipv4_subnet_address("0.0.0.0"); + EXPECT_TRUE(!address); + + address = net::get_ipv4_subnet_address("0.0.0.0/32"); + EXPECT_STREQ("0.0.0.0/32", address->str().c_str()); + + address = net::get_ipv4_subnet_address("0.0.0.0/0"); + EXPECT_STREQ("0.0.0.0/0", address->str().c_str()); + + address = net::get_ipv4_subnet_address("12.34.56.78/16"); + EXPECT_STREQ("12.34.0.0/16", address->str().c_str()); +} + namespace { using stream_type = boost::asio::ip::tcp; |