Skip to content

Commit

Permalink
Merge #19351: test: add two edge case tests for CSubNet
Browse files Browse the repository at this point in the history
ccef5d7bf0af8377c6c779295f7b41d5af435c47 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 ccef5d7bf0af8377c6c779295f7b41d5af435c47 -- more test coverage is better than less test coverage :)
  laanwj:
    ACK ccef5d7bf0af8377c6c779295f7b41d5af435c47
  hebasto:
    ACK ccef5d7bf0af8377c6c779295f7b41d5af435c47, I have reviewed the code and it looks OK, I agree it can be merged.

Tree-SHA512: 6d386672b6598aeddd33dabe3512e816cf548d5c1af56c4c9e6f897d513b62ba4659cde73405811a0df286ffee3a3f084ab7caf8e3a2086fa9ddecd1bdcb3c67
  • Loading branch information
nunumichael committed Feb 16, 2021
1 parent 70bcea7 commit 84f3be8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/test/netbase_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,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")));
Expand Down

0 comments on commit 84f3be8

Please sign in to comment.