test: Fix port collisions caused by p2p_getaddr_caching.py #25312

pull dergoegge wants to merge 2 commits into bitcoin:master from dergoegge:2022-06-addr-cache-test-fix changing 2 files +6 −8
  1. dergoegge commented at 4:41 PM on June 8, 2022: member

    This PR fixes the issue mentioned here, to avoid port collisions between nodes spun up by the test framework.

  2. fanquake added the label Tests on Jun 8, 2022
  3. in test/functional/p2p_getaddr_caching.py:47 in 7670a11f37 outdated
      42 | @@ -44,13 +43,15 @@ def addr_received(self):
      43 |  class AddrTest(BitcoinTestFramework):
      44 |      def set_test_params(self):
      45 |          self.num_nodes = 1
      46 | -        # Start onion ports after p2p and rpc ports.
      47 | -        port = PORT_MIN + 2 * PORT_RANGE
      48 | -        self.onion_port1 = port
      49 | -        self.onion_port2 = port + 1
      50 | +
      51 | +    def setup_network(self):
    


    MarcoFalke commented at 5:31 PM on June 8, 2022:

    any need to overwrite this method? PortSeed.n should be possible to set right after parsing the options:

    diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py
    index a39ee003ef..3f02d21d42 100755
    --- a/test/functional/test_framework/test_framework.py
    +++ b/test/functional/test_framework/test_framework.py
    @@ -223,11 +223,11 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
                     # It still needs to exist and be None in order for tests to work however.
                     self.options.descriptors = None
     
    +        PortSeed.n = self.options.port_seed
    +
         def setup(self):
             """Call this method to start up the test framework object with options set."""
     
    -        PortSeed.n = self.options.port_seed
    -
             check_json_precision()
     
             self.options.cachedir = os.path.abspath(self.options.cachedir)
    
  4. MarcoFalke commented at 6:02 PM on June 8, 2022: member

    The other tests could be fixed as well (in a follow-up)

  5. [test_framework] Set PortSeed.n directly after initialising params
    This allows us to use `p2p_port()` with `set_test_params()`.
    f9682e75ac
  6. [test] Fix port collisions caused by p2p_getaddr_caching.py ea54ba2f42
  7. dergoegge force-pushed on Jun 8, 2022
  8. MarcoFalke merged this on Jun 10, 2022
  9. MarcoFalke closed this on Jun 10, 2022

  10. MarcoFalke referenced this in commit b71d37da2c on Jun 10, 2022
  11. sidhujag referenced this in commit 7baafa5dc4 on Jun 13, 2022
  12. Fabcien referenced this in commit 1efb53c8e3 on Apr 27, 2023
  13. DrahtBot locked this on Jun 10, 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-04-17 09:13 UTC

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