Fault-injection fixture server
ota-ns serve runs a local server implementing the full @getcortexlabs/ota-protocol HTTP contract with nine built-in response and fault modes so you can test every client failure path without deploying a backend.
Usage
sh
ota-ns serve \
--bundle ./dist-ota/ota-105 \
--private-key ~/.ota-keys/dev.private.pem \
--key-id dev \
--host 127.0.0.1 \
--port 18787 \
--mode update \
--directive-seq 1Pass --tls-cert <cert.pem> --tls-key <key.pem> to serve over HTTPS (TLS) when testing with allowInsecureHttp: false.
Exposed endpoints
| Endpoint | Behavior |
|---|---|
GET /health | Returns { ok: true, mode, directiveSeq, releaseId }. |
POST /check | Validates UpdateCheckRequest and returns a signed UpdateCheckResponse according to --mode. |
GET /manifest.json | Serves the packed SignedManifest (or a corrupted signature in bad-manifest-sig mode). |
GET /files/<path> | Streams exact bundle bytes with path-traversal protection (400 on unsafe paths). |
POST /events | Accepts OtaLifecycleEvent JSON payloads, logs them, and returns 204. |
All 9 server modes
| Mode | Behavior | Expected SDK result |
|---|---|---|
update | Signs and serves an update directive pointing at --bundle | Downloads, verifies and stages release (status: "staged") |
none | Returns { protocolVersion: 1, status: "none" } | No-op (status: "none") |
rollback-embedded | Signs a rollback_to_embedded directive with --directive-seq | Stages clean rollback to embedded bundle (status: "rollback_staged") |
bad-directive-sig | Flips bytes in the directive's Ed25519 signature | Rejects before download with OtaError(SIGNATURE_INVALID) |
bad-manifest-sig | Serves valid directive, flips bytes in manifest.json signature | Rejects before file download with OtaError(SIGNATURE_INVALID) |
tampered-file | Flips the first byte of the bundle entry file during download | Rejects on streaming SHA-256 with OtaError(HASH_MISMATCH) |
wrong-contract | Signs directive with <runtimeContract>-mismatch | Rejects before download with OtaError(RUNTIME_CONTRACT_MISMATCH) |
wrong-build | Signs directive with <targetBuild>-mismatch | Rejects before download with OtaError(TARGET_BUILD_MISMATCH) |
drop-mid-download | Writes half of the entry file and forcefully destroys the TCP socket | Rejects with OtaError(DOWNLOAD_FAILED), leaves active bundle intact |