testing/rpc_round_trip.ts

Schema-driven round-trip validation for RPC endpoints.

For every RPC method, generates valid params and fires JSON-RPC requests (POST for all methods, GET for reads), validating that responses are well-formed JSON-RPC. Successful responses are validated against the method's declared output schema. DB-backed via the suite's setup_test fixture-producing callback.

Cadence: per-describe setup_test() call (see round_trip.ts module docstring). RPC round-trip tests fire one JSON-RPC envelope per method-direction and don't mutate state in a way that contaminates the next case.

Declarations
#

2 declarations

view source

describe_rpc_round_trip_tests
#

testing/rpc_round_trip.ts view source

(options: RpcRoundTripTestOptions): void

Run schema-driven round-trip validation for RPC endpoints.

For each method: 1. Generate valid params from the action's input schema 2. Fire a POST request with JSON-RPC envelope 3. For side_effects: false methods, also fire a GET request 4. Validate response is well-formed JSON-RPC; successful responses are also validated against the method's declared output schema

Error responses (from missing DB state, etc.) are expected and validated as well-formed JSON-RPC errors. Successful responses are validated against action.spec.output.

options

returns

void

RpcRoundTripTestOptions
#

testing/rpc_round_trip.ts view source

RpcRoundTripTestOptions

setup_test

Per-test fixture-producing function (per-describe cadence).

surface_source

App surface (with route + RPC endpoint specs) for RPC endpoint enumeration. Constructed in TS by the consumer; same shape for in-process and cross-process tests.

capabilities

Backend capability declarations.

session_options

Session config — only needed to resolve factory-form rpc_endpoints against a stub AppServerContext at setup time (the actions' input schemas drive params generation; auth/dispatch run against the real backend through fixture.transport).

type SessionOptions<string>

rpc_endpoints

RPC endpoint specs — eager array or factory. The factory must return the same endpoint path + spec.method list regardless of ctx (invoked once at setup with a stub ctx; the real per-test live dispatch goes through whatever the backend was started with).

skip_methods

Methods to skip, by name (e.g., 'zap_plan').

type Array<string>

input_overrides

Override generated params for specific methods (method name → params).

type Map<string, Record<string, unknown>>

Depends on
#

Imported by
#