#!/usr/bin/env bash # Smoke test for multi-chain execution API. Run after: npm run build && npm start (in another terminal). set -e BASE="${BASE_URL:-http://localhost:3001}" echo "Health..." curl -sSf "$BASE/v1/health" | jq . echo "Create intent..." INTENT=$(curl -sS -X POST "$BASE/v1/intents" -H "Content-Type: application/json" -d '{ "type": "cross_chain", "chain_from": 138, "chain_to": 651940, "asset_in": "native", "asset_out": "native", "amount": "1000000", "idempotency_key": "smoke-'$(date +%s)'" }') echo "$INTENT" | jq . INTENT_ID=$(echo "$INTENT" | jq -r '.intent_id') if [ -z "$INTENT_ID" ] || [ "$INTENT_ID" = "null" ]; then echo "No intent_id"; exit 1; fi echo "Execute intent..." EXEC=$(curl -sS -X POST "$BASE/v1/intents/$INTENT_ID/execute") echo "$EXEC" | jq . EXEC_ID=$(echo "$EXEC" | jq -r '.execution_id') if [ -z "$EXEC_ID" ] || [ "$EXEC_ID" = "null" ]; then echo "No execution_id"; exit 1; fi echo "Get execution..." curl -sSf "$BASE/v1/executions/$EXEC_ID" | jq . echo "Mirror commit (minimal)..." COMMIT=$(curl -sS -X POST "$BASE/v1/mirror/commit" -H "Content-Type: application/json" -d '{ "chain_id": 138, "leaves": [{ "chainId": 138, "txHash": "0x0000000000000000000000000000000000000000000000000000000000000001", "blockNumber": "100", "receiptRootOrLogsBloom": "0x00", "normalizedEventPayloadHash": "0x00", "salJournalEntryHash": null }], "uri": "https://example.com/leaves" }') echo "$COMMIT" | jq . COMMIT_ID=$(echo "$COMMIT" | jq -r '.commit_id') if [ -n "$COMMIT_ID" ] && [ "$COMMIT_ID" != "null" ]; then echo "Get commit..." curl -sSf "$BASE/v1/mirror/commits/$COMMIT_ID" | jq . fi echo "Admin circuit-breaker off..." curl -sS -X POST "$BASE/v1/admin/circuit-breaker/off" | jq . echo "Metrics..." curl -sSf "$BASE/v1/metrics" | head -5 echo "Smoke test OK."