forked from kellymusk/Aframp-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_wallet_balance.sh
More file actions
executable file
·72 lines (65 loc) · 2.63 KB
/
test_wallet_balance.sh
File metadata and controls
executable file
·72 lines (65 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
# Wallet Balance Endpoint Test Script
BASE_URL="http://localhost:8000"
TESTNET_ADDRESS="GAIH3ULLFQ4DGSECF2AR555KZ4KNDGEKN4AFI4SU2M7B43MGK3QJZNSR"
INVALID_ADDRESS="INVALID123"
NONEXISTENT_ADDRESS="GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
echo "========================================="
echo "Wallet Balance Endpoint Tests"
echo "========================================="
echo ""
# Test 1: Invalid Address Format (400)
echo "Test 1: Invalid Address Format"
echo "Expected: 400 Bad Request"
echo "Request: GET /api/wallet/balance?address=$INVALID_ADDRESS"
echo ""
curl -s -w "HTTP Status: %{http_code}\n" \
"$BASE_URL/api/wallet/balance?address=$INVALID_ADDRESS" | jq . 2>/dev/null || echo "Error or server not running"
echo ""
echo "-----------------------------------------"
echo ""
# Test 2: Non-existent Wallet (404)
echo "Test 2: Non-existent Wallet Address"
echo "Expected: 404 Not Found"
echo "Request: GET /api/wallet/balance?address=$NONEXISTENT_ADDRESS"
echo ""
curl -s -w "HTTP Status: %{http_code}\n" \
"$BASE_URL/api/wallet/balance?address=$NONEXISTENT_ADDRESS" | jq . 2>/dev/null || echo "Error or server not running"
echo ""
echo "-----------------------------------------"
echo ""
# Test 3: Valid Address (200)
echo "Test 3: Valid Stellar Testnet Address"
echo "Expected: 200 OK with balance data"
echo "Request: GET /api/wallet/balance?address=$TESTNET_ADDRESS"
echo ""
curl -s -w "HTTP Status: %{http_code}\n" \
"$BASE_URL/api/wallet/balance?address=$TESTNET_ADDRESS" | jq . 2>/dev/null || echo "Error or server not running"
echo ""
echo "-----------------------------------------"
echo ""
# Test 4: Force Refresh (200)
echo "Test 4: Force Refresh (bypass cache)"
echo "Expected: 200 OK with cached=false"
echo "Request: GET /api/wallet/balance?address=$TESTNET_ADDRESS&refresh=true"
echo ""
curl -s -w "HTTP Status: %{http_code}\n" \
"$BASE_URL/api/wallet/balance?address=$TESTNET_ADDRESS&refresh=true" | jq . 2>/dev/null || echo "Error or server not running"
echo ""
echo "-----------------------------------------"
echo ""
# Test 5: Cache Hit (200)
echo "Test 5: Cache Hit (should be fast)"
echo "Expected: 200 OK with cached=true (if called twice quickly)"
echo "Request: GET /api/wallet/balance?address=$TESTNET_ADDRESS"
echo ""
START=$(date +%s%N)
curl -s -w "HTTP Status: %{http_code}\n" \
"$BASE_URL/api/wallet/balance?address=$TESTNET_ADDRESS" | jq . 2>/dev/null || echo "Error or server not running"
END=$(date +%s%N)
DURATION=$((($END - $START) / 1000000))
echo "Response time: ${DURATION}ms"
echo ""
echo "========================================="
echo "Tests Complete"
echo "========================================="