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 opened 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: contributor

    Thanks. Was about to push a fix after @ryanofsky reported on it lately.

  4. jonatack commented at 6:24 PM on April 14, 2021: contributor
  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:

    diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp
    index 8eab26f3d..61cb381aa 100644
    --- a/src/test/net_tests.cpp
    +++ b/src/test/net_tests.cpp
    @@ -307,10 +307,6 @@ BOOST_AUTO_TEST_CASE(cnetaddr_basic)
         BOOST_REQUIRE(addr.IsValid());
         BOOST_REQUIRE(addr.IsIPv6());
         BOOST_CHECK(!addr.IsBindAny());
    -    const std::string addr_str{addr.ToString()};
    -    BOOST_CHECK(addr_str == scoped_addr || addr_str == "fe80:0:0:0:0:0:0:1");
    -    // The fallback case "fe80:0:0:0:0:0:0:1" is needed for macOS 10.14/10.15 and (probably) later.
         // 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());
         BOOST_REQUIRE(addr.IsIPv6());
    

    :)

  6. MarcoFalke added this to the milestone 22.0 on Apr 15, 2021
  7. practicalswift cross-referenced this on Apr 15, 2021 from issue test: Remove intermittently failing and not very meaningful `BOOST_CHECK` in `cnetaddr_basic` by practicalswift
  8. jonatack cross-referenced this on Apr 15, 2021 from issue test: use higher value and per-platform assert in cnetaddr link-local test by jonatack
  9. MarcoFalke closed this on Apr 17, 2021

  10. jonatack commented at 10:19 AM on April 17, 2021: contributor

    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.

  11. sidhujag referenced this in commit 94b99db6d3 on Apr 17, 2021
  12. MarcoFalke cross-referenced this on May 16, 2021 from issue test: Use zero compressed addresses for values in map by shobitb
  13. practicalswift cross-referenced this on May 17, 2021 from issue Regression: CNetAddr scoped id/zone indices functionality by jonatack
  14. practicalswift cross-referenced this on May 17, 2021 from issue net: Return IPv6 scope id in `CNetAddr::ToStringIP()` by laanwj
  15. PastaPastaPasta referenced this in commit 437ecceadc on Jun 27, 2021
  16. PastaPastaPasta referenced this in commit 7d6d33b123 on Jun 28, 2021
  17. PastaPastaPasta referenced this in commit 45711c5738 on Jun 29, 2021
  18. bitcoin locked this on Aug 18, 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: 2026-05-20 06:54 UTC