Files
rippled/.github
Bart 562e75a2cb test: Share peer test doubles across the overlay and app suites
Five peer doubles existed across seven suites. Two of them, reduce_relay_test's
PeerPartial and LedgerReplay_test's TestPeer, independently stubbed the same 22 of
Peer's 24 pure virtuals in two different directories, so every method added to Peer
broke both files identically. The other three wrapped PeerImp to capture what it would
have sent: src/test/overlay/PeerTest, a same-named copy nested in tx_reduce_relay_test,
and TMGetObjectByHash_test's own overlay wiring.

Both duplications collapse into two headers. CapturePeer, in src/test/overlay, is a real
PeerImp that captures the messages it would have sent, built by CapturePeerBuilder.
PeerStub, in src/test/jtx, is a null Peer whose methods all return defaults; PeerPartial
and TestPeer derive from it and override only what they exercise.

CapturePeer replaces PeerTest rather than the reverse on four counts: it hands out a
distinct remote address per peer, so the peer finder's per-address limit is never
reached; it holds the connection id counter per builder instead of in a static that
every suite has to reset; it takes the handshake request as a parameter, so a suite
negotiates a feature instead of overriding the negotiated result; and it declares its
two sinks by value, which is what lets a suite write `using CapturePeer::CapturePeer;`
and reach a protected PeerImp member. It also asks for the newest supported protocol
version instead of the unsupported 1.7 that makePeerTest wrote down, which had silently
turned off every feature PeerImp gates on the version, so TMGetLedger_test now reaches
the LedgerNodeDepth reply shape rather than only the legacy one. That version cannot be
derived from outside ProtocolVersion.cpp, whose list is file-local, so this adds a
newestSupportedProtocolVersion() accessor beside the existing
supportedProtocolVersions() and isProtocolSupported(). PeerStub goes in src/test/jtx
because both the overlay and the app suites need it, and test.jtx already sits below
every suite; levelization records the resulting "test.jtx > xrpld.overlay" edge, and
there is no cycle.
2026-09-18 10:03:57 +02:00
..