#!/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!"