#!/bin/bash # MEV Bot Comprehensive Analysis Script echo "Running comprehensive analysis of the MEV bot system..." # Ensure local Go cache directories are available for sandboxed environments PROJECT_ROOT="$(pwd)" export GOCACHE="${GOCACHE:-${PROJECT_ROOT}/.gocache}" export GOMODCACHE="${GOMODCACHE:-${PROJECT_ROOT}/.gomodcache}" export GOPATH="${GOPATH:-${PROJECT_ROOT}/.gopath}" export GOFLAGS="${GOFLAGS:--mod=vendor}" export GOLANGCI_LINT_CACHE="${GOLANGCI_LINT_CACHE:-${PROJECT_ROOT}/.golangci-cache}" mkdir -p "$GOCACHE" "$GOMODCACHE" "${GOPATH}/pkg/mod" "$GOLANGCI_LINT_CACHE" # Ensure imports are correct echo "Checking Go imports" goimports -w . # Check go.mod for dependencies without modifying files echo "Checking Go module dependencies..." if ! go list ./cmd/... ./internal/... ./pkg/... > /dev/null; then echo "Dependency graph check failed; please review module configuration." fi # Ensure log directory exists for tests that expect it mkdir -p logs # Run all tests echo "Running all tests..." go test ./pkg/... -v # Run benchmarks if available echo "Running benchmarks..." go test -bench=. -benchmem ./pkg/uniswap/ # Check for any race conditions echo "Checking for race conditions..." go test -race ./pkg/... # Check code coverage echo "Checking code coverage..." go test -coverprofile=coverage.out ./pkg/... go tool cover -func=coverage.out # Run static analysis echo "Running static analysis..." golangci-lint run ./cmd/... ./internal/... ./pkg/... echo "Analysis complete. Review the output for any errors or warnings."