README.md raw

morly integration suite

The layer above make test-unit. Those tests run package code through the compiler's own harness; these start a real relay process and drive it over HTTP and WebSocket. No browser, no frontend build, no selenium.

make test-integration            # builds the relay, then runs this directory
./test/run.sh --build            # same thing, without make
./test/run.sh -k policy -v       # one slice, verbose

Prerequisites: python3 with pytest and websocket-client.

What is here

filewhat it covers
test_relay_policy.pythe ORLY_* env contract: connection and subscription limits, auth gating, the HTTP guard, CORS, health, free-write limits. Each class starts its own relay with the env it needs. Raw sockets, so it has no client dependency.
test_relay_ingest_workers.pythe Stage-A ingest worker pool (ORLY_INGEST_WORKERS > 0): every verdict a worker can return, driven through dispatchToWorker / pollIngestWorkers / completeIngestResponse. Imports its helpers from test_relay_policy.
test_relay_roundtrip.pyevents published to the relay come back to a client: publish → store → filter → deliver, both for a stored query and for a live subscription.
stress_metrics.pya load driver (not a pytest module): N parallel WebSocket clients publishing M events each, reporting latency percentiles and the relay's /metrics counters. Run it directly against a running relay.
conftest.pythe session relay fixture, the port checks that keep a stale relay from answering for the one under test, and the relay binary resolution.
nostr_helpers.pypure-python Schnorr signing, so the tests can build real signed events with no dependency on a signer.

The relay under test

MORLY_RELAY_BIN picks the binary; make test-integration sets it to the morly in the repo root after building it. Unset, it prefers ./morly, then ./morly-test (the instrumented build). A missing binary is a skip, so a run that built nothing says so rather than reporting a pass.

The fixture binds 127.0.0.1:23335 and writes its store under /tmp/morly-test-data; it wipes the store first, because the fixture's readiness wait compares against a relay replaying the whole WAL. Before binding it kills any relay process group started from this same binary path, and it fails if something else holds the port — a leftover relay would answer the readiness probe and every request in the session.

ORLY_STATIC_DIR optionally points the relay at a frontend build. Unset, the static-file checks simply are not in play; nothing here requires a frontend.

Where the app's browser tests live

The other half of this suite — does the app render, does the signer unlock, does an event show up in the feed — needs a browser and a built app. It lives with the app, in ../smesh/test, and drives a relay built from this repo through SMESH_RELAY_BIN / ORLY_STATIC_DIR.

nostr_helpers.py exists in both trees because both need to sign events. The key seed is deliberately identical (smesh-test-key-do-not-use), so TEST_PUBKEY is the same value on both sides and an event signed by one suite verifies in the other.