Skip to content

Commit f591a1a

Browse files
committed
Merge #19351: test: add two edge case tests for CSubNet
ccef5d7 test: add two edge case tests for CSubNet (Vasil Dimov) Pull request description: This is chopped off from bitcoin/bitcoin#19031. It is needed because later 19031 modifies the related code and the tests ensure that no surprising changes in behavior sneak in. ACKs for top commit: practicalswift: ACK ccef5d7 -- more test coverage is better than less test coverage :) laanwj: ACK ccef5d7 hebasto: ACK ccef5d7, I have reviewed the code and it looks OK, I agree it can be merged. Tree-SHA512: 6d386672b6598aeddd33dabe3512e816cf548d5c1af56c4c9e6f897d513b62ba4659cde73405811a0df286ffee3a3f084ab7caf8e3a2086fa9ddecd1bdcb3c67
2 parents 8ef15e8 + ccef5d7 commit f591a1a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/test/netbase_tests.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ BOOST_AUTO_TEST_CASE(subnet_test)
160160
BOOST_CHECK(ResolveSubNet("1.2.2.20/26").Match(ResolveIP("1.2.2.63")));
161161
// All-Matching IPv6 Matches arbitrary IPv4 and IPv6
162162
BOOST_CHECK(ResolveSubNet("::/0").Match(ResolveIP("1:2:3:4:5:6:7:1234")));
163+
// But not `::` or `0.0.0.0` because they are considered invalid addresses
164+
BOOST_CHECK(!ResolveSubNet("::/0").Match(ResolveIP("::")));
165+
BOOST_CHECK(!ResolveSubNet("::/0").Match(ResolveIP("0.0.0.0")));
163166
BOOST_CHECK(ResolveSubNet("::/0").Match(ResolveIP("1.2.3.4")));
164167
// All-Matching IPv4 does not Match IPv6
165168
BOOST_CHECK(!ResolveSubNet("0.0.0.0/0").Match(ResolveIP("1:2:3:4:5:6:7:1234")));

0 commit comments

Comments
 (0)