These tests were written as a result of a discussion in pull request bitcoin/bitcoin#7212 about the behavior of the CNetAddr constructor.
BOOST_CHECK(CNetAddr(“250.2.2.2:7777”).ToString() != CService(“250.2.2.2:7777”).ToString()); BOOST_CHECK(CService(“250.2.2.2:7777”).ToString() == CService(“250.2.2.2”,7777).ToString()); BOOST_CHECK(CNetAddr(“250.2.2.2:8333”).IsIPv6()); BOOST_CHECK(CService(“250.2.2.2:8333”).IsIPv4()); BOOST_CHECK(CNetAddr(“250.2.2.2”, 8333).IsIPv4()); BOOST_CHECK(CService(“250.2.2.2”, 8333).IsIPv4());
Notice that because CNetAddr has no port number, very similar looking constructor inputs have very different effects.
Added some tests on the effect of non-canonical IP inputs such as:
BOOST_CHECK(CNetAddr(“1111111111”).ToString() == “66.58.53.199”);
to lock down and document this behavior.