testing/cross_backend/peer_ping_ws.ts

Cross-process server-initiated peer/ping suite — the machinery proof for ActionPeer (a backend initiating a JSON-RPC request to a connected client and awaiting its typed reply). The sibling of the one-way notification suite (role_grant_offer_notification_ws.ts), extended from server→client *notifications* to server→client *request/response*.

peer/ping is initiator: both: the client→server direction already exists as heartbeat; the new server→client direction is what this exercises. The observable trigger is the client invoking the peer/ping action over its own socket — the handler turns around and *initiates* a peer/ping request back to that socket, awaits the client's echo, validates it against PingResponse, and returns the validated shape. So one client RPC drives the whole round-trip, and every outcome (success / Timeout / wrong-shape / client-error) surfaces as that RPC's wire response — directly assertable.

The client side attaches an on_request responder at construction (via create_ws_transport's seam) so the server-initiated request is answered as soon as it arrives. Security negatives use the raw WsClient.send to inject unsolicited / cross-connection frames.

Per-spec auth. peer/ping is auth: public (a liveness echo is non-sensitive — see the design doc); the WS upgrade itself still authenticates, so the suite drives it over the keeper's session.

Gated on capabilities.peer_requesttrue only for the Rust spine (server-initiated requests landed Rust-first canonical); the TS family skips until its server transport's request path lands (deferred twin-impl convergence). Cross-process only: create_ws_transport needs a real bound socket, so wire it from a *.cross.test.ts.

view source

Declarations
#

2 declarations

describe_peer_ping_ws_tests
#

testing/cross_backend/peer_ping_ws.ts view source

(options: PeerPingWsTestOptions): void import {describe_peer_ping_ws_tests} from '@fuzdev/fuz_app/testing/cross_backend/peer_ping_ws.js';

Register the server-initiated peer/ping suite — a positive round-trip plus the security negatives the design doc's §Security surface mandates (unsolicited-response rejection, per-connection id isolation, never-reply Timeout, wrong-shape reply rejection, plus client-error forwarding and the HTTP no-transport path). Gated on capabilities.peer_request.

options

returns

void

PeerPingWsTestOptions
#

testing/cross_backend/peer_ping_ws.ts view source

PeerPingWsTestOptions import type {PeerPingWsTestOptions} from '@fuzdev/fuz_app/testing/cross_backend/peer_ping_ws.js';

Configuration for .

setup_test

Per-test fixture producer (default_cross_process_setup(handle, ...)).

type SetupTest

readonly

capabilities

Backend capability flags; every case gates on capabilities.peer_request.

type BackendCapabilities

readonly

base_url

Base URL the backend is reachable at (e.g. http://localhost:1177).

type string

readonly

ws_path

WebSocket endpoint path on the backend (e.g. /api/ws).

type string

readonly

Depends on
#