aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorW. J. van der Laan <laanwj@protonmail.com>2021-05-17 17:01:44 +0200
committerW. J. van der Laan <laanwj@protonmail.com>2021-05-18 21:01:32 +0200
commit6c280adcd865ae3da4df53d630c9bf737283a56f (patch)
tree6bb5471e9a3f1eb17a79353eb3b0a0317d36979e /src/test
parent6d1d33d33491a98bb0dbf64ea7e4743200e71474 (diff)
downloadbitcoin-6c280adcd865ae3da4df53d630c9bf737283a56f.tar.xz
net: Return IPv6 scope id in `CNetAddr::ToStringIP()`
If a scope id is provided, return it back in the string representation. Also bring back the test. Closes #21982. Co-authored-by: Jon Atack <jon@atack.com>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/net_tests.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp
index 1c397481dc..7a122bd8b0 100644
--- a/src/test/net_tests.cpp
+++ b/src/test/net_tests.cpp
@@ -300,13 +300,17 @@ BOOST_AUTO_TEST_CASE(cnetaddr_basic)
// IPv6, scoped/link-local. See https://tools.ietf.org/html/rfc4007
// We support non-negative decimal integers (uint32_t) as zone id indices.
- // Test with a fairly-high value, e.g. 32, to avoid locally reserved ids.
+ // Normal link-local scoped address functionality is to append "%" plus the
+ // zone id, for example, given a link-local address of "fe80::1" and a zone
+ // id of "32", return the address as "fe80::1%32".
const std::string link_local{"fe80::1"};
const std::string scoped_addr{link_local + "%32"};
BOOST_REQUIRE(LookupHost(scoped_addr, addr, false));
BOOST_REQUIRE(addr.IsValid());
BOOST_REQUIRE(addr.IsIPv6());
BOOST_CHECK(!addr.IsBindAny());
+ BOOST_CHECK_EQUAL(addr.ToString(), scoped_addr);
+
// Test that the delimiter "%" and default zone id of 0 can be omitted for the default scope.
BOOST_REQUIRE(LookupHost(link_local + "%0", addr, false));
BOOST_REQUIRE(addr.IsValid());