#33954 test: add functional test for outbound connection management

full analysis

https://github.com/bitcoin/bitcoin/pull/33954 · mzumsande · +398/-102 in 4 files, 3 commits · labels: Tests, CI failed · draft

Goal

  • Make autonomous outbound peer connections straightforward to test in the functional framework
  • Help test writers cover peer discovery and connection logic without bespoke proxy hacks

This pull request adds an `auto_outbound_mode` feature to the functional test framework using a SOCKS5 proxy to intercept and redirect the node's natural outbound connections. It refactors `p2p_private_broadcast.py` to use this shared mechanism and introduces a new test `p2p_outbound_management.py` covering stale-tip extra connections, periodic block-relay-only connections, and peer network diversification.

Problem: Functional tests previously had to manually initiate outbound connections to test nodes or maintain bespoke proxy redirection logic, leaving the node's autonomous connection-initiation logic (from addrman) difficult to test thoroughly.

Category: P2P (#45 of 65)

P3 · test coverage

  • P3 because it exercises core peer-to-peer connection management logic without altering node behavior
  • Locks in regression test coverage for stale-tip connections and network diversification

P3 because it exercises core P2P connection management logic without changing node behavior. It locks in test coverage for stale-tip extra connections (#11560), periodic block-relay connections (#19858), and network diversification (#27213).

Membership: Adds functional tests verifying P2P automatic outbound connection behaviors including stale tip evictions, block-relay connections, and network diversity.

Factors: security/stability 0, bug 0, performance 0, user value 0, leverage 1

Category: Test infrastructure (#12 of 45)

P3 · test coverage

  • P3 because it adds reusable framework infrastructure to simplify future peer discovery tests
  • Eliminates duplicate connection redirection code across existing functional test suites

P3 because it provides a reusable test framework capability that removes duplicated proxy code from tests and facilitates writing future tests for addrman and peer discovery mechanisms.

Membership: Modifies test/functional/test_framework/test_framework.py to introduce auto_outbound_mode and shared proxy infrastructure.

Factors: security/stability 0, bug 0, performance 0, user value 0, leverage 2

Reviewability: Paused: Author reworking

  • Wait because the author is currently reworking the branch to address feedback
  • CI is currently failing

The author stated on 2026-08-28 after rebasing that the PR is 'not ready for review yet - still need to change some things / address feedback', and CI is failing.

Author status: reworking; author stated on 2026-08-28 that the PR is not ready for review yet

Open concerns:

  • Author noted post-rebase intermittent failures and stated work is needed to address remaining feedback

Resolved concerns:

  • Avoid static port conflicts across parallel tests by adopting dynamic port allocation (port=0)
  • Unify `auto_outbound_factory` callback interfaces in the test framework
  • Remove node argument boilerplate in outbound management test helpers

Agreement: Strong

  • Strong concept and approach support across reviewers
  • Concept approval with constructive interface suggestions (vasild)
  • Verified by testing locally on Ubuntu (Bortlesboat)

Strong concept and approach support from reviewers (vasild, Bortlesboat); author is currently reworking the branch.

Reviewers strongly support integrating autonomous outbound testing into the framework and adding outbound management coverage. Comments have been constructive suggestions on interface design and timing.

  • vasild Concept ACKed and approved earlier iterations with detailed suggestions
  • Bortlesboat ACKed c733d11 after verifying tests locally on Ubuntu 24.04
  • mzumsande rebased and noted on 2026-08-28 that changes are still needed before re-review

Review verdicts (DrahtBot): 0 (+2)

Files

File list not available for this run.

Card

This PR integrates auto_outbound_mode into the functional test framework by redirecting outbound connections through a local SOCKS5 proxy to mock listeners, and adds p2p_outbound_management.py to test automatic connection logic (stale tip connections, periodic block-relay connections, and network diversification). This allows developers to test autonomous connection establishment rather than manually creating inbound peers. The concept is well-supported with ACKs from vasild and Bortlesboat, but the author recently stated the PR is not ready for review while addressing rebase issues and test intermittency.

Data

dossier JSON · extract JSON · model openrouter/google/gemini-3.8-flash, generated 2026-09-17T15:50, confidence high, input hash 8355fbcf6167eea7