-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·73 lines (62 loc) · 2.04 KB
/
test.sh
File metadata and controls
executable file
·73 lines (62 loc) · 2.04 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
73
#!/bin/bash
# Configuration
AT_ROOT="Anchor.toml"
LOG_MB="/dev/null"
LOG_EV="/dev/null"
# Setup Logging Redirection
if [[ "$LOG" == "ON" ]]; then
if [[ ! -f "$AT_ROOT" ]]; then
echo "Error: Anchor.toml not found. Execute from project root."
exit 1
fi
echo "✅ Logging enabled. Writing to .log files."
OUT_MB="mb-validator.log"
OUT_EV="ephemeral-validator.log"
else
# We use /dev/null for both output AND errors to ensure total silence
OUT_MB="/dev/null"
OUT_EV="/dev/null"
fi
# Cleanup any old ledger data or hanging processes
echo "Cleaning up old ledger and processes..."
# mb-test-validator spawns a solana-test-validator
pkill -f solana-test-validator 2>/dev/null
pkill -f ephemeral-validator 2>/dev/null
rm -rf test-ledger/
sleep 1
# Start the validators in the background
# & wait for them to start
echo "Starting magicblock test validator..."
nohup mb-test-validator --reset > "$OUT_MB" 2>&1 < /dev/null &
until curl -s http://127.0.0.1:8899 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"getHealth"}' \
| grep -q "ok"; do
sleep 1
done
echo "Starting ephemeral validator..."
RUST_LOG=info nohup ephemeral-validator \
--remotes "http://127.0.0.1:8899" \
--remotes "ws://127.0.0.1:8900" \
-l "127.0.0.1:7799" \
> "$OUT_EV" 2>&1 < /dev/null &
VALIDATOR="mAGicPQYBMvcYveUZA5F5UNNwyHvfYh5xkLS2Fr1mev"
until curl -s --request POST \
--url http://127.0.0.1:7799 \
--header "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","id":1,"method":"getIdentity"}' \
| grep -q "$VALIDATOR"; do
sleep 1
done
echo "All validators are healthy!"
# 4. Run Anchor tests
echo "Running Anchor tests..."
EPHEMERAL_PROVIDER_ENDPOINT=http://127.0.0.1:7799 \
EPHEMERAL_WS_ENDPOINT=ws://127.0.0.1:7800 \
PROVIDER_ENDPOINT=http://127.0.0.1:8899 \
WS_ENDPOINT=ws://127.0.0.1:8900 \
anchor test --skip-local-validator
# 5. Cleanup on exit
# This ensures the validators don't stay running in the background forever
pkill -f solana-test-validator
pkill -f ephemeral-validator