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/interplane-forge/blob/main/social/tests/lib.sh # interplane-forge INTERPLANE Forge 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 `interplane-forge / social / tests / lib.sh` 105 lines ยท 5942 bytes Raw Blame History 1 # ForgeSocial test library, sourced by run.sh and lockout.sh (from ~/work/forge/web). 2 # Builds a TEST copy of forged with $SOCIAL_SRC/*.om (default social/) composed in, on a private port 3 # and a private data dir (main.om's port and util.om's tfdata are rewritten in the test copy only), 4 # makes two throwaway `ed25519` keys (never a real signing key) and starts the server. 5 set -u 6 cd "$(dirname "$0")/../.." 7 OMV=$HOME/work/flux/omega-mv 8 OMC=$OMV/seed/out/omc 9 PORT=${SOCIAL_TEST_PORT:-18489} 10 CORES=${SOCIAL_TEST_CORES:-2} 11 SRC=${SOCIAL_SRC:-social} 12 T=$(mktemp -d /tmp/forgesocial.XXXXXX) 13 mkdir -p "$T/data" "$T/social" 14 PASS=0; FAIL=0 15 ok() { PASS=$((PASS+1)); echo "PASS $*"; } 16 bad() { FAIL=$((FAIL+1)); echo "FAIL $*"; } 17 check() { if [ "$1" = "$2" ]; then ok "$3 ($1)"; else bad "$3: want $2, got $1"; fi; } 18 19 # ---- build the test binary from the build's own unit list (social/tests/units.sh), after the alarm 20 # social/tests/units-check.sh has passed; omc reads exactly the units social_units wrote to units.txt 21 # The Radicle source reads FORGE_TEST_RSTORE (default ~/radicle-storage-frozen/storage, the read-only 22 # copy kept after the Radicle removal of 2026-11-14); the site chrome comes from its interplane.io. 23 # STORE_VARIANT=1: the store-reading source instead (the store's catalog, ~/interplane-store-owner by 24 # default, read only; every public line less the deny list), every other unit the same: FORGE_STORE 25 # is exported, so run.sh's own list names the store source. Without STORE_VARIANT a FORGE_STORE of 26 # the caller is dropped: the list is the Radicle-reading one. 27 RSTORE=${FORGE_TEST_RSTORE:-$HOME/radicle-storage-frozen/storage} 28 export FORGE_SITE_STORE=${FORGE_SITE_STORE:-$RSTORE/`z399yKvnXcBQNkKoq86iBDgTvQ5QV`} 29 if [ "${STORE_VARIANT:-0}" = 1 ]; then 30 export FORGE_STORE=${FORGE_STORE:-$HOME/interplane-store-owner} 31 echo "STORE_VARIANT: store-reading source $FORGE_STORE" 32 else 33 unset FORGE_STORE 34 fi 35 buildfail() { echo "BUILD FAILED: $*"; [ -n "${KEEP:-}" ] || rm -rf "$T"; exit 1; } 36 ./run.sh chrome > /dev/null || buildfail "./run.sh chrome" 37 sh social/tests/units-check.sh > "$T/units-check.out" 2>&1 || { cat "$T/units-check.out"; buildfail social/tests/units-check.sh; } 38 . social/tests/units.sh 39 social_units "$SRC" > "$T/units.txt" || buildfail "no unit list (reason above)" 40 { printf 'om2\n'; cat $(cat "$T/units.txt"); } \ 41 | sed -e "s|^text tfdata \".*\"|text tfdata \"$T/data/\"|" -e "s/18480/$PORT/g" -e "s|/home/drakestapleton/.radicle/storage/|$RSTORE/|g" > "$T/all.om" 42 if ! taskset -c "$CORES" nice -n 10 "$OMC" < "$T/all.om" > "$T/forged" 2> "$T/omc.err"; then 43 buildfail "$(cat "$T/omc.err")" 44 fi 45 chmod +x "$T/forged" 46 echo "built $(sha256sum < "$T/forged" | cut -c1-16) from $SRC in $T" 47 48 start() { 49 FORGE_SOCIAL_DIR="$T/social/" taskset -c "$CORES" nice -n 10 "$T/forged" 2>> "$T/forged.err" & 50 PID=$! 51 for i in $(seq 50); do curl -s -o /dev/null "http://127.0.0.1:$PORT/" && return 0; sleep 0.1; done 52 echo "server did not start"; cat "$T/forged.err"; exit 1 53 } 54 stop() { kill "$PID" 2>/dev/null; wait "$PID" 2>/dev/null; } 55 trap 'stop; [ -n "${KEEP:-}" ] || rm -rf "$T"' EXIT 56 B="http://127.0.0.1:$PORT" 57 REPO=$(awk -F'|' '/^\| *[a-z0-9-]+ *\| *(rad:)?z[0-9A-Za-z]+/ {gsub(/ /,"",$2); print $2; exit}' "$HOME/handoffs/radicle/RIDS.md") 58 [ -n "$REPO" ] || REPO=cuda-crack 59 R=/drakestapleton/$REPO 60 61 # status of a request: code(method path [curl args...]) 62 # code: an HTML body is read without the send-time translation hints of server/tr.om (translate="no" 63 # attributes and around hashes and ids; server/tests/translate_check.py strip) 64 code() { 65 m=$1; p=$2; local c; shift 2 66 c=$(curl -s -o "$T/body" -D "$T/hdr" -X "$m" "$@" "$B$p" -w '%{http_code}') 67 if grep -qi '^content-type: text/html' "$T/hdr"; then python3 server/tests/translate_check.py strip "$T/body" "$T/body.s" && mv "$T/body.s" "$T/body"; fi 68 printf '%s' "$c" 69 } 70 hdr() { grep -i "^$1:" "$T/hdr" | head -1 | cut -d' ' -f2- | tr -d '\r'; } 71 field() { grep -o "name=\"$1\" value=\"[^\"]*\"" "$T/body" | head -1 | sed 's/.*value="//; s/"$//'; } 72 stars() { code GET "$R/stargazers" >/dev/null; grep -o 'stargazers">[0-9][0-9]*' "$T/body" | head -1 | grep -o '[0-9]*$'; } 73 # the same count from the JSON form (forge/stargazers/1), and the length of its users list 74 jstars() { code GET "$R/stargazers" -H 'Accept: application/json' >/dev/null 75 python3 -c 'import json,sys; d=json.load(open(sys.argv[1])); print(d["schema"], d["count"], len(d["users"]))' "$T/body"; } 76 77 # ---- throwaway keys + DID oracle (did:key = z + base58btc(0xed 0x01 || pk)) 78 ssh-keygen -q -t `ed25519` -N '' -C t1 -f "$T/k1" 79 ssh-keygen -q -t `ed25519` -N '' -C t2 -f "$T/k2" 80 did() { python3 - "$1" <<'EOF' 81 import sys, base64 82 blob = base64.b64decode(open(sys.argv[1]).read().split()[1]) 83 raw = b'\xed\x01' + blob[-32:] 84 A = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' 85 n = int.from_bytes(raw, 'big'); s = '' 86 while n: n, r = divmod(n, 58); s = A[r] + s 87 print('did:key:z' + '1' * (len(raw) - len(raw.lstrip(b'\0'))) + s) 88 EOF 89 } 90 D1=$(did "$T/k1.pub"); D2=$(did "$T/k2.pub") 91 92 # ---- sign-in helpers. The cookie names are read from Set-Cookie, so the old code (forge_pre / 93 # forge_session) and the new (__Host-forge_pre / __Host-forge_session) both run under lockout.sh. 94 login_get() { # [extra curl args] 95 c=$(code GET /login "$@"); check "$c" 200 "GET /login" 96 PREN=$(hdr set-cookie | sed -n 's/^\([A-Za-z_-]*forge_pre\)=.*/\1/p') 97 PRE=$(hdr set-cookie | sed -n 's/^[A-Za-z_-]*forge_pre=\([0-9a-f]*\);.*/\1/p') 98 CSRF=$(field csrf); NONCE=$(field nonce); TS=$(field ts) 99 } 100 sign() { printf '%s' "interplane-forge-login:$NONCE:$TS" | ssh-keygen -Y sign -f "$1" -n interplane-forge > "$T/sig" 2>/dev/null; } 101 login_post() { # did [extra curl args] 102 d=$1; shift 103 code POST /login -H "Cookie: ${PREN:-__Host-forge_pre}=$PRE" --data-urlencode "csrf=$CSRF" --data-urlencode "nonce=$NONCE" \ 104 --data-urlencode "ts=$TS" ${d:+--data-urlencode "did=$d"} --data-urlencode "sig@$T/sig" "$@" 105 }