|
| 1 | +#!/bin/bash |
| 2 | +set -e |
| 3 | + |
| 4 | +# Configuration |
| 5 | +API_URL=${1:-"http://localhost:3000"} |
| 6 | +MAX_RETRIES=30 |
| 7 | +RETRY_INTERVAL=2 |
| 8 | + |
| 9 | +echo "Starting StreamPay Smoke Test against $API_URL..." |
| 10 | + |
| 11 | +# 1. Wait for Health Check |
| 12 | +echo "Waiting for API to be healthy..." |
| 13 | +count=0 |
| 14 | +until $(curl -sf "$API_URL/health" | grep -q "ok"); do |
| 15 | + if [ $count -eq $MAX_RETRIES ]; then |
| 16 | + echo "Error: API failed to become healthy in time." |
| 17 | + exit 1 |
| 18 | + fi |
| 19 | + printf '.' |
| 20 | + sleep $RETRY_INTERVAL |
| 21 | + ((count++)) |
| 22 | +done |
| 23 | +echo -e "\n API is healthy!" |
| 24 | + |
| 25 | +# 2. Test: List Streams (Happy Path) |
| 26 | +echo "Testing: List Streams..." |
| 27 | +LIST_RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" "$API_URL/api/v1/streams") |
| 28 | +if [ "$LIST_RESPONSE" -ne 200 ]; then |
| 29 | + echo "Error: List Streams failed with status $LIST_RESPONSE" |
| 30 | + exit 1 |
| 31 | +fi |
| 32 | +echo "List Streams success (200 OK)" |
| 33 | + |
| 34 | +# 3. Test: Create Stream (Happy Path) |
| 35 | +echo "Testing: Create Stream..." |
| 36 | +# Note: Using dummy data - adjust keys based on your schema |
| 37 | +CREATE_RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -X POST "$API_URL/api/v1/streams" \ |
| 38 | + -H "Content-Type: application/json" \ |
| 39 | + -d '{"sender": "test_user", "receiver": "dest_user", "amount": "100", "asset": "XLM"}') |
| 40 | + |
| 41 | +if [ "$CREATE_RESPONSE" -ne 201 ] && [ "$CREATE_RESPONSE" -ne 200 ]; then |
| 42 | + echo "Error: Create Stream failed with status $CREATE_RESPONSE" |
| 43 | + exit 1 |
| 44 | +fi |
| 45 | +echo "Create Stream success ($CREATE_RESPONSE)" |
| 46 | + |
| 47 | +echo "Smoke Test Passed Successfully!" |
| 48 | +exit 0 |
0 commit comments