test: Add test for CNetAddr::ToString IPv6 address formatting (RFC 5952) #21477

pull practicalswift wants to merge 1 commits into bitcoin:master from practicalswift:test-canonical-ipv6 changing 1 files +54 −0
  1. practicalswift commented at 2:32 pm on March 19, 2021: contributor

    Test that CNetAddr::ToString formats IPv6 addresses with zero compression and canonicalisation as described in RFC 5952 (“A Recommendation for IPv6 Address Text Representation”).

    Solving #21466 will hopefully be trivial with the ability to check zero compression correctness against these tests.

  2. practicalswift renamed this:
    tests: Add test for CNetAddr::ToString IPv6 address formatting (RFC 5952)
    test: Add test for CNetAddr::ToString IPv6 address formatting (RFC 5952)
    on Mar 19, 2021
  3. DrahtBot added the label Tests on Mar 19, 2021
  4. in src/test/net_tests.cpp:411 in 685a661cbd outdated
    405+        {"000:000:000:000:000:000:000:000", "::"},
    406+        {"00:00:00:00:00:00:00:00", "::"},
    407+        {"0:0:0:0:0:0:0:0", "::"},
    408+        {"0:0:0:0:0:0:0:1", "::1"},
    409+        {"2001:0:0:1:0:0:0:1", "2001:0:0:1::1"},
    410+        {"2001:0db8:0:0:1:0:0:1", "2001:db8::1:0:0:1"},
    


    vasild commented at 2:56 pm on March 19, 2021:

    2001:0db8:0:0:1:0:0:1 can be represented as 2001:db8::1:0:0:1, but also as 2001:0db8:0:0:1::1.

    Are we guaranteed that all getnameinfo() on different platforms will use the variants in this test? I think no.

    (similarly in some others below)


    practicalswift commented at 3:15 pm on March 19, 2021:

    RFC 5952 tells us that there is one (and only one) canonical representation of 2001:0db8:0:0:1:0:0:1 which is 2001:db8::1:0:0:1.

    Testing CNetAddr::ToString’s conformance with RFC 5952 is the entire point of this PR :)


    vasild commented at 3:25 pm on March 19, 2021:

    RFC 5952 tells us that there is one (and only one) canonical representation

    Where is that text?

    I see the following, which seems to be the opposite:

    https://tools.ietf.org/html/rfc5952#section-2.2

    ‘The “::” can only appear once in an address.’ This gives a choice on where in a single address to compress the zero. 2001:db8::aaaa:0:0:1 2001:db8:0:0:aaaa::1


    practicalswift commented at 3:52 pm on March 19, 2021:

    @vasild

    The text you’re quoting is describing the problem: the problem being that there are multiple ways to represent a given IPv6 address (in the absence of canonicalisation rules).

    The RFC describes how to solve that problem using canonicalisation :)

    See the first paragraph of the RFC: “This document defines a canonical textual representation format.”

    Note that “canonical textual representation” in this context means one (and only one) way to format a given IPv6 address.

    Perhaps reading https://en.wikipedia.org/wiki/IPv6_address#Representation makes the role of canonicalisation in the context IPv6 address formatting more clear? :)


    vasild commented at 12:42 pm on March 21, 2021:
    My bad, https://tools.ietf.org/html/rfc5952#section-4.2.3 is pretty clear. Sorry for the noise.
  5. tests: Add test for CNetAddr::ToString IPv6 address formatting (RFC 5952) 732c7bddeb
  6. practicalswift force-pushed on Mar 19, 2021
  7. vasild approved
  8. vasild commented at 12:49 pm on March 21, 2021: member
    ACK 732c7bddeb9cd4e9fe80ebb7ee98d0f9fcc6a9d3
  9. MarcoFalke merged this on Mar 29, 2021
  10. MarcoFalke closed this on Mar 29, 2021

  11. sidhujag referenced this in commit 561ede4d32 on Mar 29, 2021
  12. practicalswift deleted the branch on Apr 10, 2021
  13. PastaPastaPasta referenced this in commit 4a11855818 on Jun 27, 2021
  14. PastaPastaPasta referenced this in commit 7d36737848 on Jun 28, 2021
  15. PastaPastaPasta referenced this in commit 7a8e2977da on Jun 29, 2021
  16. DrahtBot locked this on Aug 16, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-04-11 00:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me