mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-10-05 19:28:25 +00:00
Every test that used to open a socket to something outside the repo now talks to geode, the relay this project ships, either in-process or as the embedded `amy serve`. - amethyst: the Android instrumented EventSyncTest dialed vitor.nostr1.com, pyramid.fiatjaf.com and the nos.lol / nostr.mom defaults and asserted nothing. Replaced by a JVM unit test on geode's InProcessRelays that preloads a source relay and asserts what lands on the outbox, inbox and DM relays, plus a NIP-42 variant with the source behind FullAuthPolicy to cover the RelayAuthenticator wiring. Wires :geode, its testFixtures and the JVM SQLite driver into amethyst's unit-test classpath, the same way quartz's jvmAndroidTest already does. - cli/tests: the cache, dm and marmot headless harnesses cloned and cargo-built nostr-rs-relay on first run. They now boot `amy serve` (geode) from the amy binary they already build, via a shared start_local_relay / stop_local_relay in headless/helpers.sh. Rust is no longer needed for the cache and dm suites at all. - cli/tests/marmot/marmot-interop.sh: the interactive harness defaulted to relay.damus.io / nos.lol / primal / bitcoiner.social / nostr.mom, with `--local-relays` pointing at MDK's docker stack. It now boots the embedded relay on 0.0.0.0 by default (the phone reaches it over the LAN) and keeps the public set behind an explicit `--public-relays`. - docs: cli/tests/README.md, CONTRIBUTING.md, cli/DEVELOPMENT.md and cli/ROADMAP.md no longer describe a loopback nostr-rs-relay. The quartz prodbench probes (NegentropyStallRepro, CursorTerminationProbe, NegentropyMultiRelayLiveTest, ProductionReceiverBenchmark, ...) are left as they are: they are opt-in diagnostics of production relay behaviour, gated behind PROD_RELAY_BENCH / NEG_MULTI / NEG_STALL_REPRO, and would measure nothing against a local relay. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PguqnDbP2v11dtANs9xdxc
98 lines
3.9 KiB
Bash
98 lines
3.9 KiB
Bash
# shellcheck shell=bash
|
|
#
|
|
# setup.sh — amy-only preflight + identity bootstrap for the
|
|
# NIP-17 DM interop harness. Much slimmer than the Marmot setup:
|
|
#
|
|
# - Builds `amy` (same retry-on-503 logic as setup.sh). The loopback
|
|
# relay is `amy serve` (geode), so amy is the only binary needed.
|
|
# - Bootstraps two fresh amy identities (A and D), each with its own
|
|
# `--data-dir`, both pointed at the loopback relay.
|
|
# - Publishes kind:10050 (plus NIP-65) for both so NIP-17's strict
|
|
# recipient-inbox routing has something to resolve to.
|
|
#
|
|
# The `start_local_relay` / `stop_local_relay` helpers (embedded
|
|
# `amy serve`) live in ../headless/helpers.sh and are sourced by the
|
|
# top-level harness.
|
|
|
|
# --- preflight (amy only, no wn / Marmot patches, no Rust) -------------------
|
|
preflight_dm() {
|
|
banner "Preflight (DM harness)"
|
|
for cmd in jq git curl; do
|
|
if ! command -v "$cmd" >/dev/null 2>&1; then
|
|
fail_msg "missing required tool: $cmd"
|
|
exit 1
|
|
fi
|
|
info "$cmd: $(command -v "$cmd")"
|
|
done
|
|
|
|
if [[ ! -x "$AMY_BIN" ]]; then
|
|
if [[ "$NO_BUILD" -eq 1 ]]; then
|
|
fail_msg "amy not found at $AMY_BIN and --no-build set"; exit 1
|
|
fi
|
|
# Gradle + jitpack/dl.google.com occasionally return transient 503s;
|
|
# retry so a single bad roll doesn't tank the whole harness.
|
|
local attempt max=4
|
|
for attempt in $(seq 1 $max); do
|
|
step "building :cli:installDist (attempt $attempt/$max)"
|
|
if ( cd "$REPO_ROOT" && ./gradlew :cli:installDist ) 2>&1 | tee -a "$LOG_FILE" \
|
|
&& [[ -x "$AMY_BIN" ]]; then
|
|
break
|
|
fi
|
|
[[ "$attempt" -lt "$max" ]] && warn "gradle build failed — retrying"
|
|
done
|
|
fi
|
|
[[ -x "$AMY_BIN" ]] || { fail_msg "amy still missing after build"; exit 1; }
|
|
info "amy: $AMY_BIN"
|
|
|
|
}
|
|
|
|
# --- amy identity wrappers ---------------------------------------------------
|
|
# Two identities: A (sender) and D (recipient), both inside the same
|
|
# $STATE_DIR/.amy tree. They share $STATE_DIR/.amy/shared/events-store/
|
|
# — the same code path real users hit with multiple accounts. The
|
|
# enclosing harness sets STATE_DIR to a fresh tempdir per run, so amy
|
|
# sees a virgin home each time.
|
|
#
|
|
# `--secret-backend=plaintext` keeps these throwaway interop runs headless —
|
|
# the default `auto` would try the OS keychain (not available in CI) and then
|
|
# ask for a NIP-49 passphrase. Plaintext still writes 0600-owner-only.
|
|
amy_a() { HOME="$STATE_DIR" "$AMY_BIN" --account A --secret-backend plaintext --json "$@"; }
|
|
amy_d() { HOME="$STATE_DIR" "$AMY_BIN" --account D --secret-backend plaintext --json "$@"; }
|
|
|
|
# --- identity bootstrap ------------------------------------------------------
|
|
ensure_identity_for() {
|
|
local who="$1"
|
|
step "initialising Identity $who (amy at \$HOME=$STATE_DIR --account $who)"
|
|
local out
|
|
out=$(HOME="$STATE_DIR" "$AMY_BIN" --account "$who" --secret-backend plaintext --json init) || {
|
|
fail_msg "amy init failed for $who: $out"; exit 1
|
|
}
|
|
local npub hex
|
|
npub=$(printf '%s' "$out" | jq -r '.npub')
|
|
hex=$(printf '%s' "$out" | jq -r '.hex')
|
|
case "$who" in
|
|
A) A_NPUB="$npub"; A_HEX="$hex" ;;
|
|
D) D_NPUB="$npub"; D_HEX="$hex" ;;
|
|
esac
|
|
info "$who npub: $npub"
|
|
info "$who hex: $hex"
|
|
}
|
|
|
|
# --- relay wiring ------------------------------------------------------------
|
|
# Point both identities at the loopback relay (all three buckets:
|
|
# nip65 / inbox / key_package), then publish each identity's kind:10050
|
|
# so the DM strict-relay routing has something to resolve to.
|
|
configure_relays_dm() {
|
|
banner "Configuring relays → $RELAY_URL"
|
|
amy_a relay add "$RELAY_URL" >/dev/null
|
|
amy_d relay add "$RELAY_URL" >/dev/null
|
|
|
|
step "publishing A's NIP-65 + kind:10050 lists"
|
|
amy_a relay publish-lists >>"$LOG_FILE" 2>&1 \
|
|
|| warn "amy_a relay publish-lists failed"
|
|
|
|
step "publishing D's NIP-65 + kind:10050 lists"
|
|
amy_d relay publish-lists >>"$LOG_FILE" 2>&1 \
|
|
|| warn "amy_d relay publish-lists failed"
|
|
}
|