test: check localaddresses in getnetworkinfo for nodes with proxy #24258

pull brunoerg wants to merge 1 commits into bitcoin:master from brunoerg:2022-02-check-localaddresses changing 1 files +13 −5
  1. brunoerg commented at 9:50 AM on February 4, 2022: member

    This PR adds test coverage for the field localaddresses for getnetworkinfo. In this case, it verifies if this field is empty for all nodes since they are using proxy.

    Reference: https://github.com/bitcoin/bitcoin/blob/515200298b555845696a07ae2bc0a84a5dd02ae4/src/init.cpp#L449

  2. fanquake added the label Tests on Feb 4, 2022
  3. shaavan commented at 11:46 AM on February 5, 2022: contributor

    @brunoerg

    It’s an interesting PR and deserves a concept ACK if the claim in the description is accurate. However, I could not find any credible source to verify that a node using proxy would not (or cannot) have local addresses. It would be pretty helpful to share some readings regarding this topic.

  4. brunoerg commented at 1:52 PM on February 5, 2022: member

    Hey, @shaavan. Thank you! I just updated the PR description with a reference. Basically, -discover is "false" by default if there is -proxy. Also, I just opened #24269 which adds test coverage for -discover and it can help to understand this one as well.

  5. 1000Instantsolution approved
  6. cheetooooo commented at 6:32 PM on March 19, 2022: none

    .

  7. aureleoules commented at 12:59 AM on March 20, 2022: member

    tACK 458edba68b872d528ece63c6835c8997e6f1fdbf.

    I verified that nodes do not have local addresses by default if using -proxy: you must explicitly specify -discover for this. To verify that, I compared the logs of bitcoind -discover -proxy=127.0.0.1:10080 and bitcoind -proxy=127.0.0.1:10080.
    Also stated here as brunoerg mentioned: https://github.com/bitcoin/bitcoin/blob/515200298b555845696a07ae2bc0a84a5dd02ae4/src/init.cpp#L449

    Thus, adding -discover to a node using a proxy makes the test fail.

  8. in test/functional/feature_proxy.py:240 in 458edba68b outdated
     233 | @@ -234,7 +234,13 @@ def networks_dict(d):
     234 |              return r
     235 |  
     236 |          self.log.info("Test RPC getnetworkinfo")
     237 | -        n0 = networks_dict(self.nodes[0].getnetworkinfo())
     238 | +        nodes_network_info = []
     239 | +        for node in self.nodes:
    


    jonatack commented at 12:21 PM on March 21, 2022:

    I think adding documentation as follows would be helpful for future readers of this test.

             self.log.info("Test RPC getnetworkinfo")
             nodes_network_info = []
    +
    +        self.log.debug("Test that setting -proxy disables local address discovery, i.e. -discover=0")
             for node in self.nodes:
                 network_info = node.getnetworkinfo()
                 assert_equal(network_info["localaddresses"], [])
    

    brunoerg commented at 12:53 PM on March 21, 2022:

    I agree, going to add it!


    brunoerg commented at 12:31 PM on March 22, 2022:

    done!

  9. jonatack commented at 12:25 PM on March 21, 2022: member

    Thus, adding -discover to a node using a proxy makes the test fail.

    Perhaps worth adding a test case for this.

  10. brunoerg force-pushed on Mar 22, 2022
  11. brunoerg commented at 12:33 PM on March 22, 2022: member

    Thus, adding -discover to a node using a proxy makes the test fail.

    Perhaps worth adding a test case for this.

    I am not sure if it fails, are you? I didn't find anything pointing it should fail.

  12. brunoerg commented at 12:33 PM on March 22, 2022: member

    Force-pushed addressing #24258 (review)

  13. aureleoules commented at 1:38 PM on March 22, 2022: member

    Thus, adding -discover to a node using a proxy makes the test fail.

    Perhaps worth adding a test case for this.

    I am not sure if it fails, are you? I didn't find anything pointing it should fail.

    Yes adding -discover to the following args makes the test fail because the field localaddresses of the node now gets filled, at least on my machine. https://github.com/bitcoin/bitcoin/blob/94039022de2fe47e418b2819eed48c43f4fb205b/test/functional/feature_proxy.py#L103

  14. brunoerg commented at 2:06 PM on March 22, 2022: member

    Yes adding -discover to the following args makes the test fail because the field localaddresses of the node now gets filled, at least on my machine.

    Make sense, but I don't think we should cover it in this PR because we can't ensure localaddresses is filled even if we set -discover (and it could cause intermittent failures), I can only 100% ensure that not setting -discover and setting a proxy, it must be empty.

  15. aureleoules commented at 3:33 PM on March 22, 2022: member

    Yes adding -discover to the following args makes the test fail because the field localaddresses of the node now gets filled, at least on my machine.

    Make sense, but I don't think we should cover it in this PR because we can't ensure localaddresses is filled even if we set -discover (and it could cause intermittent failures), I can only 100% ensure that not setting -discover and setting a proxy, it must be empty.

    Yes I agree this was my thought as well.

  16. in test/functional/feature_proxy.py:272 in 94039022de outdated
     268 | @@ -261,7 +269,7 @@ def networks_dict(d):
     269 |          assert_equal(n1['i2p']['proxy_randomize_credentials'], False)
     270 |          assert_equal(n1['i2p']['reachable'], True)
     271 |  
     272 | -        n2 = networks_dict(self.nodes[2].getnetworkinfo())
     273 | +        n2 = networks_dict(nodes_network_info[2])
    


    jonatack commented at 5:46 PM on March 22, 2022:

    Approach ACK, is there a reason to not use nodes_network_info for n3 and n4?

    @ -285,7 +285,7 @@ class ProxyTest(BitcoinTestFramework):
             assert_equal(n2['cjdns']['reachable'], False)
     
             if self.have_ipv6:
    -            n3 = networks_dict(self.nodes[3].getnetworkinfo())
    +            n3 = networks_dict(nodes_network_info[3])
                 assert_equal(NETWORKS, n3.keys())
                 for net in NETWORKS:
                     if net == NET_I2P or net == NET_ONION:
    @@ -298,7 +298,7 @@ class ProxyTest(BitcoinTestFramework):
                 assert_equal(n3['i2p']['reachable'], False)
                 assert_equal(n3['cjdns']['reachable'], False)
     
    -        n4 = networks_dict(self.nodes[4].getnetworkinfo())
    +        n4 = networks_dict(nodes_network_info[4])
             assert_equal(NETWORKS, n4.keys())
             for net in NETWORKS:
                 if net == NET_I2P:
    

    brunoerg commented at 7:08 PM on March 22, 2022:

    No, I forgot to change them. Force-pushed addressing it. Thank you so much!

  17. jonatack commented at 5:51 PM on March 22, 2022: member

    If you're interested to add test coverage of -discover in another PR, it might be useful to look at test/functional/feature_bind_port_discover.py.

  18. test: check localaddresses in getnetworkinfo for nodes with proxy 89bb25d22a
  19. brunoerg force-pushed on Mar 22, 2022
  20. brunoerg commented at 7:13 PM on March 22, 2022: member

    If you're interested to add test coverage of -discover in another PR, it might be useful to look at test/functional/feature_bind_port_discover.py.

    I opened a PR that covers it. See #24269. I didn't know about feature_bind_port_discover.py, I will take a look. Thanks

  21. jonatack commented at 1:55 PM on March 23, 2022: member

    ACK 89bb25d22a0e1c700dba4e3b754984c9b2b14836

  22. MarcoFalke merged this on Mar 28, 2022
  23. MarcoFalke closed this on Mar 28, 2022

  24. sidhujag referenced this in commit 1c6b5cbcd8 on Apr 2, 2022
  25. achow101 referenced this in commit 5ff3d1e5ce on Oct 13, 2022
  26. sidhujag referenced this in commit d3f8ff42ee on Oct 23, 2022
  27. DrahtBot locked this on Mar 28, 2023

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-02 03:13 UTC

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