intermittent unit test failure: test/net_tests.cpp(311): error: in “net_tests/cnetaddr_basic”: check addr_str == scoped_addr || addr_str == “fe80:0:0:0:0:0:0:1” has failed #21682

issue MarcoFalke openend this issue on April 14, 2021
  1. MarcoFalke commented at 5:55 pm on April 14, 2021: member
  2. MarcoFalke added the label Bug on Apr 14, 2021
  3. jonatack commented at 6:23 pm on April 14, 2021: member
    Thanks. Was about to push a fix after @ryanofsky reported on it lately.
  4. jonatack commented at 6:24 pm on April 14, 2021: member
  5. practicalswift commented at 10:45 pm on April 14, 2021: contributor

    I’ve looked at that test before and I don’t think that specific BOOST_CHECK makes much sense TBH :)

    1.) I don’t understand why we test if ToString() output includes %zone_index: it clearly doesn’t on some platforms, so we cannot rely on it anyways. Then why test it?

    2.) And perhaps more fundamentally: why would we even want to have %zone_index in our textual ToString() output? I think the expectation is to get say fe80::1ff:fe23:4567:890a (without zone index) and not say fe80::1ff:fe23:4567:890a%eth2 or fe80::1ff:fe23:4567:890a%3 when doing ipv6_addr.ToString() :)

    Suggested solution:

     0diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp
     1index 8eab26f3d..61cb381aa 100644
     2--- a/src/test/net_tests.cpp
     3+++ b/src/test/net_tests.cpp
     4@@ -307,10 +307,6 @@ BOOST_AUTO_TEST_CASE(cnetaddr_basic)
     5     BOOST_REQUIRE(addr.IsValid());
     6     BOOST_REQUIRE(addr.IsIPv6());
     7     BOOST_CHECK(!addr.IsBindAny());
     8-    const std::string addr_str{addr.ToString()};
     9-    BOOST_CHECK(addr_str == scoped_addr || addr_str == "fe80:0:0:0:0:0:0:1");
    10-    // The fallback case "fe80:0:0:0:0:0:0:1" is needed for macOS 10.14/10.15 and (probably) later.
    11     // Test that the delimiter "%" and default zone id of 0 can be omitted for the default scope.
    12     BOOST_REQUIRE(LookupHost(link_local + "%0", addr, false));
    13     BOOST_REQUIRE(addr.IsValid());
    14     BOOST_REQUIRE(addr.IsIPv6());
    

    :)

  6. MarcoFalke added this to the milestone 22.0 on Apr 15, 2021
  7. MarcoFalke closed this on Apr 17, 2021

  8. jonatack commented at 10:19 am on April 17, 2021: member
    Noting here that this was also fixed by #21690 as I wrote above in #21682 (comment) that I would do. #21690 not only fixed the issue but also kept the test coverage and improved the contextual information to avoid the confusion above and that I think was worth keeping.
  9. sidhujag referenced this in commit 94b99db6d3 on Apr 17, 2021
  10. PastaPastaPasta referenced this in commit 437ecceadc on Jun 27, 2021
  11. PastaPastaPasta referenced this in commit 7d6d33b123 on Jun 28, 2021
  12. PastaPastaPasta referenced this in commit 45711c5738 on Jun 29, 2021
  13. DrahtBot locked this on Aug 18, 2022


MarcoFalke jonatack practicalswift

Labels
Bug

Milestone
22.0


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-12 00:13 UTC

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