proxy-io: Generalize ConnectStream / ServeStream for use in tests #365

pull ryanofsky wants to merge 4 commits into bitcoin-core:master from ryanofsky:pr/connserve changing 2 files +91 −59
  1. ryanofsky commented at 8:39 PM on September 11, 2026: collaborator

    Generalize ConnectStream and ServeStream functions to simplify test setup in libmultiprocess and bitcoin core code (in followup https://github.com/ryanofsky/bitcoin/commit/990f259a9dd60473d247218bf579c57893319ced). Also add an incomingConnections accessor so Bitcoin Core code does not need to directly access the incoming connections list to disconnect clients.

    These changes help with #336 by getting rid of external code that would need to change with its changes to the Connection representation.

  2. proxy-io: add EventLoop::incomingConnections()
    Add an accessor and a Connections type alias for the EventLoop's
    list of incoming connections, so future code can be simplified to
    locate a specific connection without directly accessing the private
    list or embedding a Connection object itself.
    
    Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
    37e19f8ff2
  3. proxy-io: let ServeStream take ownership of init object
    Add a _Serve/ServeStream overload accepting the init object as a
    shared_ptr, so callers can transfer ownership instead of always
    passing a reference to an object they keep alive themselves. Existing
    reference-taking callers keep working through a thin overload that
    wraps the reference in a shared_ptr with an empty deleter.
    
    Also return the constructed ProxyServer along with an iterator to its
    Connection in loop.m_incoming_connections, so callers can look up or
    erase the connection later without embedding a Connection object
    themselves.
    
    Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
    57c7e3040e
  4. proxy-io: add destroy_connection parameter to ServeStream and ConnectStream
    Give ServeStream and ConnectStream a destroy_connection parameter,
    defaulting to true, so callers can opt out of automatic connection
    teardown and manage the Connection's lifetime themselves instead.
    ServeStream gates the internal disconnect handler's list erase on the
    parameter; ConnectStream just forwards it to the existing
    ProxyClientBase parameter of the same name.
    
    This lets callers that need to keep a connection alive past a
    disconnect notification (e.g. to let in-flight server calls finish)
    use these helpers instead of constructing a Connection manually.
    
    Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
    42e246bbec
  5. test: simplify TestSetup using ServeStream/ConnectStream
    Replace TestSetup's manual Connection construction with
    ServeStream/ConnectStream, following the same pattern already used in
    Bitcoin Core's own IPC test and fuzz code. This drops server_on_disconnect
    entirely: ServeStream's destroy_connection parameter now controls whether
    a remote disconnect erases the server Connection, so the only test that
    needed to suppress that (the mp#348 getResults race test) just constructs
    TestSetup with server_owns_connection=false instead of overriding a
    callback afterward.
    
    Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
    cb925202d2
  6. DrahtBot commented at 8:39 PM on September 11, 2026: none

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK xyzconstant

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #361 (proxy-io: Fix theoretical disconnect bugs by ryanofsky)
    • #335 (proxy-io.h: Add Connection disconnect and waitDrained methods by ryanofsky)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  7. ryanofsky force-pushed on Sep 14, 2026
  8. ryanofsky commented at 8:26 PM on September 14, 2026: collaborator

    <!-- begin push-2 -->

    Updated fb9b74245d943e2df3ac9559f325c8774fc50d6a -> cb925202d26b6660211096b3377cce7e11cef9fe (pr/connserve.1 -> pr/connserve.2, compare)<!-- end --> fixing CI IWYU errors and test lambda capture bug https://github.com/bitcoin-core/libmultiprocess/actions/runs/34645399495/job/103414855439?pr=365

  9. xyzconstant commented at 9:00 PM on September 15, 2026: contributor

    LGTM. ACK cb925202d26b6660211096b3377cce7e11cef9fe.

    By the way, the llvm job failed with IWYU.


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/libmultiprocess. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-09-16 09:30 UTC

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