From 1b307e5955bb93a4fafa6da42caa3bd19a8c35ee Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 25 Apr 2026 15:58:15 +0000 Subject: [PATCH] fix(cli/tests): bind marmot harness relay to 127.0.0.2 (avoid localhost strip) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quartz's RelayUrlNormalizer.isLocalHost strips literal 127.0.0.1 / localhost / 192.168.* / .local / umbrel out of NIP-17 inbox (kind:10050) and KeyPackage (kind:10051) relay-list events as a privacy guard. The marmot harness was binding the loopback relay to ws://127.0.0.1:8080, so when amy added that URL to its kind:10050 / kind:10051 events the parser silently dropped it on read — leaving the harness publishing to Amethyst's PUBLIC default relays (nos.lol, nostr.mom, …) instead of the local one. Whitenoise (which only listens on the local socket) never saw amy's KeyPackage, breaking every Test 01–16 scenario at the first hop. The DM harness already worked around this by using 127.0.0.2 (still pure loopback, not on the strip list — see dm-interop-headless.sh:34). This commit applies the same workaround to the marmot harness: - Default RELAY_HOST=127.0.0.2 (overridable via env or --host). - RELAY_URL is now derived from RELAY_HOST + RELAY_PORT. - New --host flag for parity with the DM harness. setup.sh's relay config already reads RELAY_HOST when binding nostr-rs-relay (line 173, address = "${RELAY_HOST:-127.0.0.1}"), so no other change is needed — the relay binds where amy is trying to reach it. --- cli/tests/marmot/marmot-interop-headless.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cli/tests/marmot/marmot-interop-headless.sh b/cli/tests/marmot/marmot-interop-headless.sh index 32794ea67..04b833451 100755 --- a/cli/tests/marmot/marmot-interop-headless.sh +++ b/cli/tests/marmot/marmot-interop-headless.sh @@ -39,11 +39,19 @@ AMY_BIN="$REPO_ROOT/cli/build/install/amy/bin/amy" # Local relay wiring — cloned + built during preflight, started on # $RELAY_PORT. The harness never touches the public internet for test # traffic; wn/wnd/amy all point at this one loopback endpoint. +# +# Bind to 127.0.0.2 rather than 127.0.0.1: Quartz's RelayUrlNormalizer +# strips literal 127.0.0.1 / localhost / 192.168.* out of NIP-17 inbox +# (kind:10050) and KeyPackage (kind:10051) relay-list events as a +# privacy guard, which would silently leave the harness publishing to +# Amethyst's public defaults instead of the loopback. 127.0.0.2 is +# still pure loopback (no network traffic) but isn't on the strip list. +RELAY_HOST="${RELAY_HOST:-127.0.0.2}" RELAY_REPO="${RELAY_REPO:-$STATE_DIR/nostr-rs-relay}" RELAY_BIN="$RELAY_REPO/target/release/nostr-rs-relay" RELAY_DATA="$STATE_DIR/relay" RELAY_PORT="${RELAY_PORT:-8080}" -RELAY_URL="ws://127.0.0.1:$RELAY_PORT" +RELAY_URL="ws://$RELAY_HOST:$RELAY_PORT" NO_BUILD=0 A_NPUB="" @@ -55,7 +63,8 @@ C_HEX="" while [[ $# -gt 0 ]]; do case "$1" in - --port) RELAY_PORT="$2"; RELAY_URL="ws://127.0.0.1:$RELAY_PORT"; shift ;; + --port) RELAY_PORT="$2"; RELAY_URL="ws://$RELAY_HOST:$RELAY_PORT"; shift ;; + --host) RELAY_HOST="$2"; RELAY_URL="ws://$RELAY_HOST:$RELAY_PORT"; shift ;; --no-build) NO_BUILD=1 ;; -h|--help) sed -n '3,14p' "${BASH_SOURCE[0]}" | sed 's/^# \?//'