Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/open-humanity/blob/main/scripts/e2e-local.sh # open-humanity Privacy-first peer assistance network for sovereign autonomous agents Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `open-humanity / scripts / e2e-local.sh` 90 lines ยท 5807 bytes Raw Blame History 1 #!/usr/bin/env bash 2 # One relay, one helper and one asker as three separate processes on the loopback 3 # interface, using the built binaries. Run from anywhere: scripts/e2e-local.sh 4 # Then a second relay linked with the first, a helper with a lasting key at that relay, and 5 # an answer that is checked before it is kept. 6 # OH_E2E_PORT picks the first UDP port (default 18198; the next one is used too). 7 # Exit 0 and "RESULT e2e pass" on success. 8 set -u 9 cd "$(dirname "$0")/.." 10 T=$(mktemp -d /tmp/oh-e2e.XXXXXX) 11 RELAY=; HELPER=; RELAY2= 12 trap 'kill $RELAY $HELPER $RELAY2 2>/dev/null; rm -rf "$T"' EXIT 13 pass=0; fail=0 14 ok() { pass=$((pass+1)); echo "PASS $*"; } 15 bad() { fail=$((fail+1)); echo "FAIL $*"; } 16 cargo build --offline --workspace -q || { echo "FAIL build"; exit 1; } 17 BIN=${CARGO_TARGET_DIR:-target}/debug 18 PORT=${OH_E2E_PORT:-18198} 19 OH="$BIN/open-humanity" 20 PORT2=$((PORT+1)) 21 BEACON_BIND=127.0.0.1 BEACON_PORT=$PORT BEACON_LINKS=127.0.0.1:$PORT2 "$BIN/beacon" > "$T/relay.log" 2>&1 & 22 RELAY=$! 23 sleep 0.5 24 kill -0 "$RELAY" 2>/dev/null && ok "relay runs on 127.0.0.1:$PORT" || { bad "relay did not start: $(cat "$T/relay.log")"; exit 1; } 25 26 "$OH" teach --db "$T/helper.sqlite" --topic rust-compilation \ 27 --error 'error[E0425]: cannot find value `foo` in /home/alice/app/src/main.rs' \ 28 --solution 'declare foo with let before the first use' > "$T/teach.log" 2>&1 \ 29 && ok "helper stored a solution" || bad "teach: $(cat "$T/teach.log")" 30 "$OH" listen --db "$T/helper.sqlite" --relay "127.0.0.1:$PORT" --topics rust-compilation --for 8 > "$T/helper.log" 2>&1 & 31 HELPER=$! 32 sleep 1 33 34 ask() { "$OH" ask --db "$T/asker.sqlite" --relay "127.0.0.1:$PORT" --topic rust-compilation --title 'Undefined identifier' "$@"; } 35 SAME='error[E0425]: cannot find value `foo` in /home/bob/app/src/main.rs' 36 37 ask --error "$SAME" --summary 'foo is used before it exists' > "$T/dry.log" 2>&1; rc=$? 38 [ "$rc" = 3 ] && grep -q 'Nothing was sent' "$T/dry.log" && ok "without --approve nothing is sent (exit 3)" || bad "dry run: rc=$rc" 39 40 out=$(ask --error "$SAME" --summary 'foo is used before it exists' --wait 5 --approve 2>&1); rc=$? 41 [ "$rc" = 0 ] && echo "$out" | grep -q 'declare foo with let before the first use' \ 42 && ok "the asker got the helper's solution through the relay" || bad "ask: rc=$rc: $out" 43 echo "$out" | grep -q '/home/' && bad "a home folder left the node" || ok "no home folder in what was sent or shown" 44 45 out=$(ask --error 'an error nobody has seen' --summary 'unknown' --wait 2 --approve 2>&1); rc=$? 46 [ "$rc" = 4 ] && ok "an error nobody knows gets no answer (exit 4)" || bad "unknown error: rc=$rc: $out" 47 48 KEY="AKIA$(printf 'IOSFODNN7EXAMPLE')" 49 out=$(ask --error "$SAME" --summary "my key is $KEY" --wait 2 --approve 2>&1); rc=$? 50 [ "$rc" != 0 ] && echo "$out" | grep -q 'Personal Data Firewall' && ok "a secret in the summary is refused before sending" || bad "secret: rc=$rc: $out" 51 52 wait "$HELPER"; HELPER= 53 grep -q 'answered: 1' "$T/helper.log" && ok "helper report: $(tail -1 "$T/helper.log")" || bad "helper log: $(cat "$T/helper.log")" 54 grep -c 'carried' "$T/relay.log" > /dev/null && ok "relay log shows the request and the answer carried" || bad "relay log: $(cat "$T/relay.log")" 55 grep -q 'declare foo' "$T/relay.log" && bad "the relay log holds the solution text" || ok "the relay never saw the solution text" 56 57 58 # --- a second relay linked with the first, a lasting helper key, a checked answer --- 59 BEACON_BIND=127.0.0.1 BEACON_PORT=$PORT2 BEACON_LINKS=127.0.0.1:$PORT "$BIN/beacon" > "$T/relay2.log" 2>&1 & 60 RELAY2=$! 61 BEACON_BIND=127.0.0.1 BEACON_PORT=$PORT2 BEACON_LINKS=not-an-address "$BIN/beacon" > "$T/badlink.log" 2>&1; rc=$? 62 [ "$rc" = 2 ] && grep -q BEACON_LINKS "$T/badlink.log" && ok "a bad BEACON_LINKS stops a relay (exit 2)" || bad "bad link: rc=$rc" 63 64 SEED=$("$OH" identity new | sed -n 's/^seed: *//p') 65 pub() { "$OH" identity show --identity-cmd "echo $SEED" | sed -n 's/^public key: *//p'; } 66 PUB=$(pub) 67 [ ${#SEED} = 64 ] && [ ${#PUB} = 64 ] && [ "$PUB" = "$(pub)" ] && ok "a seed gives the same public key on every run" || bad "identity: seed ${#SEED} chars, key ${#PUB} chars" 68 "$OH" identity show | grep -q 'No lasting identity' && ok "without a seed no lasting identity is claimed" || bad "identity show without a seed" 69 70 OTHER='error[E0599]: no method named `bar` found' 71 "$OH" teach --db "$T/helper2.sqlite" --topic rust-compilation --error "$OTHER" --solution 'call baz instead of bar' > /dev/null 2>&1 72 "$OH" listen --db "$T/helper2.sqlite" --relay "127.0.0.1:$PORT2" --topics rust-compilation --for 9 --identity-cmd "echo $SEED" > "$T/helper2.log" 2>&1 & 73 HELPER=$! 74 sleep 1.5 75 76 out=$(ask --error "$OTHER" --summary 'bar does not exist' --wait 5 --check 'grep -q baz solution.txt' --approve 2>&1); rc=$? 77 [ "$rc" = 0 ] && echo "$out" | grep -q 'call baz instead of bar' \ 78 && ok "asked at one relay, answered by a helper at the linked relay" || bad "linked ask: rc=$rc: $out" 79 echo "$out" | grep -q "Answer from helper ${PUB:0:16}" && ok "the answer is signed with the helper's lasting key" || bad "helper key: $out" 80 echo "$out" | grep -q 'check passed' && "$OH" peers --db "$T/asker.sqlite" | grep -q "^$PUB passed 1 failed 0" \ 81 && ok "the check passed and counts for that helper" || bad "check: $out / $("$OH" peers --db "$T/asker.sqlite")" 82 83 out=$(ask --error "$OTHER" --summary 'bar does not exist' --wait 5 --check 'false' --approve 2>&1) 84 echo "$out" | grep -q 'check FAILED' && "$OH" peers --db "$T/asker.sqlite" | grep -q "^$PUB passed 1 failed 1" \ 85 && ok "a failed check is not kept and counts against the helper" || bad "failed check: $out" 86 wait "$HELPER"; HELPER= 87 grep -q 'answered: 2' "$T/helper2.log" && ok "second helper report: $(tail -1 "$T/helper2.log")" || bad "second helper log: $(cat "$T/helper2.log")" 88 89 echo "RESULT e2e pass=$pass fail=$fail" 90 [ "$fail" = 0 ]