duly / scripts/reproduce.sh · raw
#!/usr/bin/env bash# Everything a reviewer needs to check Duly, from a clean clone, in one command:#   npm run reproduce            all five steps (needs Node 22+, Rust via rustup, internet)#   npm run reproduce -- --quick skip the Rust build and the testnet run (Node only, ~1 minute)# Steps: JS unit tests, contract unit tests, positive controls, the mainnet evidence# re-checked from public RPCs, and a full paid-invoice loop on NEAR testnet.# Exits 0 only if every step that ran passed and nothing was skipped without --quick.set -uo pipefailcd "$(dirname "$0")/.."QUICK=0[ "${1:-}" = "--quick" ] && QUICK=1declare -a NAMES RESULTSfails=0run() { # NAME COMMAND...  local name=$1; shift  echo; echo "=== $name"; echo "    \$ $*"  local t0=$SECONDS  if "$@"; then RESULTS+=("PASS  $name ($((SECONDS - t0)) s)")  else RESULTS+=("FAIL  $name ($((SECONDS - t0)) s)"); fails=$((fails + 1)); fi}skip() { RESULTS+=("SKIP  $1: $2"); }node_major=$(node -p 'process.versions.node.split(".")[0]' 2>/dev/null || echo 0)if [ "$node_major" -lt 22 ]; then echo "Node 22 or later is needed (found ${node_major}). See https://nodejs.org"; exit 2; firun "JS unit tests: relayer allowlist, fingerprint, quotes, money, CSV, pages" node --test test/*.test.mjsif [ "$QUICK" = 1 ]; then  skip "Contract unit tests" "--quick"elif command -v cargo >/dev/null 2>&1; then  run "Contract unit tests (Rust, near-sdk unit-testing; first build takes a few minutes)" cargo test -p duly-contract --lockedelse  RESULTS+=("FAIL  Contract unit tests: cargo not found. Install Rust with https://rustup.rs; rust-toolchain.toml picks the version")  fails=$((fails + 1))firun "Positive controls: each guard broken on purpose must make its test fail" scripts/positive-controls.shrun "Mainnet evidence re-checked from public NEAR and Base RPCs (no keys)" node scripts/verify-mainnet.mjsif [ "$QUICK" = 1 ]; then  skip "Testnet loop" "--quick"else  run "Testnet loop: wallet-free merchant, invoice, part payment, split, refund, CSV" node scripts/demo-testnet.mjsfiecho; echo "=== Summary"printf '  %s\n' "${RESULTS[@]}"if [ "$fails" -gt 0 ]; then echo "  $fails step(s) failed."; exit 1; fiecho "  Every step that ran passed."