net: Make addr relay mockable, add test #18454

pull MarcoFalke wants to merge 3 commits into bitcoin:master from MarcoFalke:2003-qaAddrRelay changing 4 files +86 −14
  1. MarcoFalke commented at 11:24 PM on March 27, 2020: member

    As usual:

    • Switch to std::chrono time to be type-safe and mockable
    • Add basic test that relies on mocktime to add code coverage
  2. net: Make addr relay mockable fa47a0b003
  3. fanquake added the label P2P on Mar 27, 2020
  4. jonatack commented at 11:50 PM on March 27, 2020: member

    Concept ACK. The code changes look good, will review the new test.

  5. DrahtBot commented at 12:10 AM on March 28, 2020: member

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--2502f1a698b3751726fa55edcda76cd3-->

    Coverage

    Coverage Change (pull 18454, e7908f9c13b4663e09448f879368afe7555708df) Reference (master, f2c416bcf5f898dd996106871dbbd7051851ccac)
    Lines +0.0732 % 90.1870 %
    Functions +0.0586 % 85.9068 %
    Branches +0.0256 % 51.7375 %

    <sup>Updated at: 2020-03-28T00:10:40.605800.</sup>

  6. practicalswift commented at 11:22 AM on March 28, 2020: contributor

    Concept ACK

    Thanks taking on this unglamourous (in the short-run) but important (in the long-run) work.

  7. MarcoFalke force-pushed on Mar 28, 2020
  8. promag commented at 12:48 AM on March 30, 2020: member

    Code review ACK fa5bf23d527a450e72c2bf13d013e5393b664ca3, clean change, just read the new test.

  9. naumenkogs commented at 1:51 PM on April 2, 2020: member

    Code looks good. I can't understand what the test is actually testing for?

  10. net: Pass connman const when relaying address fa1793c1c4
  11. MarcoFalke force-pushed on Apr 2, 2020
  12. MarcoFalke commented at 1:58 PM on April 2, 2020: member

    It is a basic test to check that addr messages can be received (and are then relayed). For more information you can read the lines self.log.info(...)

  13. MarcoFalke commented at 2:03 PM on April 2, 2020: member

    Force pushed because I had to re-arrange the commits. Diff to previous review should be empty.

  14. naumenkogs commented at 2:03 PM on April 2, 2020: member

    Yeah I tried reading that, just wanted to confirm. So, it actually doesn't test the new behavior (mockability)? Because setmocktime is called at the very end and nothing is really tested after it.

  15. MarcoFalke commented at 2:06 PM on April 2, 2020: member

    assert_debug_log is a context manager, so the checks in it are executed at the end.

    You can check that the test fails by compiling current master, then checking out this branch, then running the functional tests without recompiling.

    You can also check that this test fails by removing the call to setmocktime in the functional test.

  16. naumenkogs commented at 2:13 PM on April 2, 2020: member

    utACK fad3f58fd5a9d35d5a6e3467b1b5bcf18081ca41, although I would prefer to comment the last lines of the test. I think it's counter-intuitive of what you are actually trying to demonstrate.

  17. MarcoFalke commented at 2:18 PM on April 2, 2020: member

    @naumenkogs Happy to do that, could you leave suggestions for in-line comments please, so that I can take them?

  18. test: Add basic addr relay test fa1da3d4bf
  19. MarcoFalke force-pushed on Apr 2, 2020
  20. MarcoFalke commented at 3:31 PM on April 2, 2020: member

    Removed last commit after chat with @naumenkogs to keep this pull focussed on one topic. The test in the last commit can be added later, if needed.

  21. naumenkogs commented at 3:59 PM on April 2, 2020: member

    utACK fa1da3d

  22. MarcoFalke commented at 4:39 PM on April 8, 2020: member

    @promag Mind to re-ACK after I dropped one commit?

  23. promag commented at 1:04 PM on April 10, 2020: member

    ACK fa1da3d4bfc0511a89f5b19d5a4d89e55ff7ccde (fabe56e44b6f683e24e37246a7a8851190947cb3 before #18454 (comment)), fa5bf23d527a450e72c2bf13d013e5393b664ca3 was dropped since last review.

  24. MarcoFalke merged this on Apr 10, 2020
  25. MarcoFalke closed this on Apr 10, 2020

  26. MarcoFalke deleted the branch on Apr 10, 2020
  27. sidhujag referenced this in commit ecebd70177 on Apr 13, 2020
  28. jasonbcox referenced this in commit ada27e66ec on Nov 21, 2020
  29. random-zebra referenced this in commit b4751e10ce on Aug 11, 2021
  30. DrahtBot locked this on Feb 15, 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-04-17 06:14 UTC

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