Merge bitcoin/bitcoin#33362: Run feature_bind_port_(discover|externalip).py in CI

75cf9708a0 ci: add one more routable address to the VMs (docker containers) (Vasil Dimov)
1b93983bf5 test: make feature_bind_port_(discover|externalip).py auto-detect the skip condition (Vasil Dimov)

Pull request description:

  `feature_bind_port_discover.py` and `feature_bind_port_externalip.py` require a routable address on the machine to run. Since that was not predictably available on CI, those tests required a manual setting up of IP addresses (e.g. using `ifconfig`) and then running the tests with a command line option telling them that the addresses are set up. The tests were not run in CI and [got rot](https://github.com/bitcoin/bitcoin/issues/31293#issuecomment-2497792487).

  Change that to auto-detect, from the tests, whether the needed IP addresses are present and if yes, run the test, otherwise skip it. Also change the CI to configure the needed addresses when running the functional tests. This way the tests will be run regularly on CI.

  Fixes: https://github.com/bitcoin/bitcoin/issues/31336

ACKs for top commit:
  willcl-ark:
    ACK 75cf9708a0
  frankomosh:
    Tested ACK 75cf9708a0. Built from source.
  ryanofsky:
    Code review ACK 75cf9708a0. Tested locally with and without the special addresses, and the detection seems to work well.

Tree-SHA512: 252911a37a06764f644a1a83c808f5255ac3bc74919426afa5d082c59e1ea924196354735f229d381cb5aff2340e001c2240bbadc8b5f27e5321fb4cfaef0fdb
This commit is contained in:
Ryan Ofsky
2026-05-19 13:05:17 -04:00
4 changed files with 78 additions and 41 deletions

View File

@@ -535,6 +535,27 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
# Wait for nodes to stop
node.wait_until_stopped()
def cleanup_partially_started_nodes(self):
"""Tear down nodes left running after a failed start_nodes().
After start_nodes() raises (e.g. FailedToStartError), some nodes may be
RPC-connected, some may have a live process without RPC, and some may
already have exited. Stop the connected ones cleanly and force-kill the
rest so the framework's teardown can proceed.
"""
for node in self.nodes:
if not node.running:
continue
if node.rpc_connected:
node.stop_node(wait=node.rpc_timeout)
else:
node.process.kill()
node.process.wait(timeout=node.rpc_timeout)
node.process = None
node.stdout.close()
node.stderr.close()
node.running = False
def restart_node(self, i, extra_args=None, clear_addrman=False, *, expected_stderr=''):
"""Stop and start a test node"""
self.stop_node(i, expected_stderr=expected_stderr)