#!/bin/sh # Test stand-in for dumbpipe (javascript/src/iroh tests, rust/iroh/conformance.test.mjs): no network. # connect --custom-alpn utf8:echo/1 : prints ready, echoes one stdin line, exits 0 # connect --custom-alpn utf8:fail/1 : nothing on stdout, exits 1 # connect --custom-alpn utf8:secret/1 : as real dumbpipe, "using secret key" on stderr unless # IROH_SECRET is set; then ok on stdout, exits 0 # connect --custom-alpn utf8:noisy/1 : 200 KiB on stderr, nothing on stdout, exits 1 # connect --custom-alpn utf8:flood/1 : 3 MB of x on stdout, then waits (a one-shot call is cut at its cap) case "$3" in utf8:echo/1) printf 'ready\n'; read -r line; printf 'got %s\n' "$line"; exit 0 ;; utf8:fail/1) printf 'no route to endpoint\n' >&2; exit 1 ;; utf8:secret/1) [ -n "$IROH_SECRET" ] || printf 'using secret key deadbeef\n' >&2; printf 'ok\n'; exit 0 ;; utf8:noisy/1) head -c 204800 /dev/zero | tr '\0' x >&2; printf '\nlast line\n' >&2; exit 1 ;; utf8:flood/1) head -c 3000000 /dev/zero | tr '\0' x; exec sleep 30 ;; esac exit 2