steelbot/scripts/smoke-test.sh
caelum0x 4b2262e406 feat: Steelbot — autonomous AI agent with USDC wallet on Base
Synthesis Hackathon submission. Built on IronClaw fork.

26 tools: Locus payments (6), Uniswap DeFi (3), onchain reads (3),
security scanning (2), wallet analytics (3), OpenRouter LLM (2),
self-hosted scraping (3), portfolio (2), synthesis (2).

3 defense hooks: spending limits ($5/tx, $25/session), contract guard
(SCONE-bench vulnerability patterns), credential guard (blocks private
key/seed phrase leaks).

Payment system (Polar.sh), landing page, license key gating (Free/Pro/
Unlimited tiers), brand rename from IronClaw to Steelbot.

9,669 lines of code. 3,665 tests passing. Zero clippy warnings.
Real USDC transactions on Base chain.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 01:53:00 +03:00

142 lines
4.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# ──────────────────────────────────────────────────────────────────────────────
# Steelbot / IronClaw — Quick smoke test
#
# Usage: ./scripts/smoke-test.sh
#
# Verifies the basics in under 30 seconds:
# 1. cargo check passes
# 2. Server starts and /api/health responds
# 3. Landing page loads and contains "Steelbot"
#
# No external services required.
# ──────────────────────────────────────────────────────────────────────────────
set -euo pipefail
RED='\033[0;31m'
GREEN='\033[0;32m'
CYAN='\033[0;36m'
BOLD='\033[1m'
RESET='\033[0m'
PASS=0
FAIL=0
TOTAL=0
PORT=$((RANDOM % 50000 + 10000))
BASE_URL="http://127.0.0.1:${PORT}"
AUTH_TOKEN="smoke-test-token-$$"
SERVER_PID=""
PROJECT_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
LOG_FILE="${PROJECT_ROOT}/target/smoke-test-server.log"
TIMEOUT=30
log_test() {
TOTAL=$((TOTAL + 1))
echo -ne " ${BOLD}[$TOTAL]${RESET} $1 ... "
}
pass() {
PASS=$((PASS + 1))
echo -e "${GREEN}PASS${RESET}"
}
fail() {
FAIL=$((FAIL + 1))
echo -e "${RED}FAIL${RESET}"
[ -n "${1:-}" ] && echo -e " ${RED}-> $1${RESET}"
}
cleanup() {
if [ -n "$SERVER_PID" ] && kill -0 "$SERVER_PID" 2>/dev/null; then
kill "$SERVER_PID" 2>/dev/null || true
wait "$SERVER_PID" 2>/dev/null || true
fi
}
trap cleanup EXIT INT TERM
echo -e "${CYAN}${BOLD}Steelbot Smoke Test${RESET}"
echo -e "${CYAN}────────────────────${RESET}"
# ── 1. Build check ───────────────────────────────────────────────────────────
log_test "cargo check"
if cargo check --manifest-path "${PROJECT_ROOT}/Cargo.toml" 2>&1; then
pass
else
fail "cargo check failed"
exit 1
fi
# ── 2. Start server & wait for health ────────────────────────────────────────
echo -e "\n Starting server on port ${PORT}..."
mkdir -p "$(dirname "$LOG_FILE")"
# Use debug build if release is not available — faster for smoke tests.
BINARY="${PROJECT_ROOT}/target/debug/ironclaw"
if [ ! -x "$BINARY" ]; then
BINARY="${PROJECT_ROOT}/target/release/ironclaw"
fi
if [ ! -x "$BINARY" ]; then
# cargo check succeeded but no binary yet — build debug quickly
echo -e " Building debug binary..."
cargo build --manifest-path "${PROJECT_ROOT}/Cargo.toml" 2>&1
BINARY="${PROJECT_ROOT}/target/debug/ironclaw"
fi
env \
GATEWAY_HOST="127.0.0.1" \
GATEWAY_PORT="$PORT" \
GATEWAY_AUTH_TOKEN="$AUTH_TOKEN" \
HEARTBEAT_ENABLED="false" \
TELEMETRY_ENABLED="false" \
SANDBOX_ENABLED="false" \
RUST_LOG="ironclaw=warn" \
"$BINARY" run \
> "$LOG_FILE" 2>&1 &
SERVER_PID=$!
log_test "Server healthy within ${TIMEOUT}s"
elapsed=0
healthy=false
while [ $elapsed -lt $TIMEOUT ]; do
if curl -sf "${BASE_URL}/api/health" > /dev/null 2>&1; then
healthy=true
break
fi
if ! kill -0 "$SERVER_PID" 2>/dev/null; then
fail "Server exited prematurely"
tail -10 "$LOG_FILE" 2>/dev/null || true
exit 1
fi
sleep 1
elapsed=$((elapsed + 1))
done
if $healthy; then
pass
else
fail "Timed out after ${TIMEOUT}s"
tail -10 "$LOG_FILE" 2>/dev/null || true
exit 1
fi
# ── 3. Landing page ──────────────────────────────────────────────────────────
log_test "GET / → 200, contains 'Steelbot'"
status=$(curl -s -o /dev/null -w "%{http_code}" "${BASE_URL}/" 2>/dev/null) || true
body=$(curl -s "${BASE_URL}/" 2>/dev/null) || true
if [ "$status" = "200" ] && echo "$body" | grep -qi "Steelbot"; then
pass
else
fail "status=$status"
fi
# ── Report ────────────────────────────────────────────────────────────────────
echo ""
if [ "$FAIL" -gt 0 ]; then
echo -e "${RED}${BOLD}SMOKE TEST FAILED${RESET} ($FAIL/$TOTAL)"
exit 1
else
echo -e "${GREEN}${BOLD}SMOKE TEST PASSED${RESET} ($PASS/$TOTAL)"
exit 0
fi