73 lines
1.7 KiB
Bash
Executable File
73 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
# Run all MEV bot tests
|
|
|
|
set -e
|
|
|
|
echo "🧪 Starting MEV Bot Test Suite"
|
|
|
|
# Configuration
|
|
ARBITRUM_RPC_URL="https://arb1.arbitrum.io/rpc"
|
|
FORK_BLOCK_NUMBER="latest"
|
|
ANVIL_PORT="8545"
|
|
ANVIL_CHAIN_ID="31337"
|
|
|
|
# Start Anvil in background
|
|
echo "🔄 Starting Anvil fork..."
|
|
anvil \
|
|
--fork-url "$ARBITRUM_RPC_URL" \
|
|
--fork-block-number "$FORK_BLOCK_NUMBER" \
|
|
--port "$ANVIL_PORT" \
|
|
--chain-id "$ANVIL_CHAIN_ID" \
|
|
--accounts 10 \
|
|
--balance 1000 \
|
|
--gas-limit 30000000 \
|
|
--code-size-limit 50000 \
|
|
--silent \
|
|
> ../logs/anvil.log 2>&1 &
|
|
|
|
ANVIL_PID=$!
|
|
echo "📡 Anvil started with PID: $ANVIL_PID"
|
|
|
|
# Wait for Anvil to be ready
|
|
sleep 3
|
|
|
|
# Function to cleanup
|
|
cleanup() {
|
|
echo "🧹 Cleaning up..."
|
|
kill $ANVIL_PID 2>/dev/null || true
|
|
exit
|
|
}
|
|
|
|
# Set trap for cleanup
|
|
trap cleanup EXIT INT TERM
|
|
|
|
# Check if Anvil is responding
|
|
echo "🔍 Checking Anvil connection..."
|
|
if ! curl -s -X POST --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' http://localhost:$ANVIL_PORT > /dev/null; then
|
|
echo "❌ Anvil is not responding"
|
|
exit 1
|
|
fi
|
|
|
|
echo "✅ Anvil is ready"
|
|
|
|
# Set environment variables for tests
|
|
export ARBITRUM_RPC_URL="$ARBITRUM_RPC_URL"
|
|
export ARBITRUM_RPC_ENDPOINT="http://localhost:$ANVIL_PORT"
|
|
export TEST_MODE="true"
|
|
|
|
# Run Solidity tests
|
|
echo "🔍 Running Solidity tests..."
|
|
cd ..
|
|
if command -v forge &> /dev/null; then
|
|
forge test -vv --fork-url "http://localhost:$ANVIL_PORT"
|
|
else
|
|
echo "⚠️ Foundry not found, skipping Solidity tests"
|
|
fi
|
|
|
|
# Run Go tests against forked environment
|
|
echo "🐹 Running Go integration tests..."
|
|
|
|
cd ..
|
|
go test ./tests/integration/... -v -timeout 300s
|
|
|
|
echo "✅ All tests completed successfully!" |