From d2f0124052cd43756f31d31b1c3db8781b909293 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Fri, 15 May 2020 17:02:05 +0200 Subject: [PATCH] test: add two edge case tests for CSubNet --- src/test/netbase_tests.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/netbase_tests.cpp b/src/test/netbase_tests.cpp index 2cc51f8e3e3..e1e2dc19755 100644 --- a/src/test/netbase_tests.cpp +++ b/src/test/netbase_tests.cpp @@ -141,6 +141,9 @@ BOOST_AUTO_TEST_CASE(subnet_test) BOOST_CHECK(ResolveSubNet("1.2.2.20/26").Match(ResolveIP("1.2.2.63"))); // All-Matching IPv6 Matches arbitrary IPv4 and IPv6 BOOST_CHECK(ResolveSubNet("::/0").Match(ResolveIP("1:2:3:4:5:6:7:1234"))); + // But not `::` or `0.0.0.0` because they are considered invalid addresses + BOOST_CHECK(!ResolveSubNet("::/0").Match(ResolveIP("::"))); + BOOST_CHECK(!ResolveSubNet("::/0").Match(ResolveIP("0.0.0.0"))); BOOST_CHECK(ResolveSubNet("::/0").Match(ResolveIP("1.2.3.4"))); // All-Matching IPv4 does not Match IPv6 BOOST_CHECK(!ResolveSubNet("0.0.0.0/0").Match(ResolveIP("1:2:3:4:5:6:7:1234")));