Files
mev-beta/scripts/test-runner.sh
Krypto Kajun 850223a953 fix(multicall): resolve critical multicall parsing corruption issues
- Added comprehensive bounds checking to prevent buffer overruns in multicall parsing
- Implemented graduated validation system (Strict/Moderate/Permissive) to reduce false positives
- Added LRU caching system for address validation with 10-minute TTL
- Enhanced ABI decoder with missing Universal Router and Arbitrum-specific DEX signatures
- Fixed duplicate function declarations and import conflicts across multiple files
- Added error recovery mechanisms with multiple fallback strategies
- Updated tests to handle new validation behavior for suspicious addresses
- Fixed parser test expectations for improved validation system
- Applied gofmt formatting fixes to ensure code style compliance
- Fixed mutex copying issues in monitoring package by introducing MetricsSnapshot
- Resolved critical security vulnerabilities in heuristic address extraction
- Progress: Updated TODO audit from 10% to 35% complete

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-17 00:12:55 -05:00

130 lines
4.6 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Reusable, agnostic test runner script
# Can be used in any Go project by adjusting configuration
# Configuration variables
TEST_LEVEL="${TEST_LEVEL:-basic}" # basic, unit, integration, comprehensive, audit
COVERAGE="${COVERAGE:-false}"
OUTPUT_DIR="${OUTPUT_DIR:-test-results}"
PACKAGE_FILTER="${PACKAGE_FILTER:-./...}"
TIMEOUT="${TIMEOUT:-10m}"
JUNIT_OUTPUT="${JUNIT_OUTPUT:-false}"
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
-l|--level)
TEST_LEVEL="$2"
shift 2
;;
-c|--coverage)
COVERAGE=true
shift
;;
-o|--output)
OUTPUT_DIR="$2"
shift 2
;;
-p|--package)
PACKAGE_FILTER="$2"
shift 2
;;
--junit)
JUNIT_OUTPUT=true
shift
;;
-t|--timeout)
TIMEOUT="$2"
shift 2
;;
-h|--help)
echo "Usage: $0 [OPTIONS]"
echo "Run tests with different levels of coverage"
echo ""
echo "Options:"
echo " -l, --level LEVEL Test level: basic, unit, integration, comprehensive, audit (default: basic)"
echo " -c, --coverage Generate coverage report"
echo " -o, --output DIR Output directory (default: test-results)"
echo " -p, --package PKG Package filter (default: ./...)"
echo " --junit Generate JUnit output"
echo " -t, --timeout DURATION Timeout duration (default: 10m)"
echo " -h, --help Show this help"
exit 0
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
echo "Starting test execution (level: $TEST_LEVEL, coverage: $COVERAGE)"
# Create output directory
mkdir -p "$OUTPUT_DIR"
# Run tests based on level
case $TEST_LEVEL in
"basic")
echo "Running basic tests..."
if [ "$COVERAGE" = "true" ]; then
go test -v -short -coverprofile="$OUTPUT_DIR/coverage.out" -covermode=atomic "$PACKAGE_FILTER"
go tool cover -html="$OUTPUT_DIR/coverage.out" -o "$OUTPUT_DIR/coverage.html"
else
go test -v -short "$PACKAGE_FILTER"
fi
;;
"unit")
echo "Running unit tests..."
if [ "$COVERAGE" = "true" ]; then
go test -v ./test/unit/... -coverprofile="$OUTPUT_DIR/coverage.out" -covermode=atomic
go tool cover -html="$OUTPUT_DIR/coverage.out" -o "$OUTPUT_DIR/coverage.html"
else
go test -v ./test/unit/...
fi
;;
"integration")
echo "Running integration tests..."
if [ "$COVERAGE" = "true" ]; then
go test -v ./test/integration/... -coverprofile="$OUTPUT_DIR/coverage.out" -covermode=atomic
go tool cover -html="$OUTPUT_DIR/coverage.out" -o "$OUTPUT_DIR/coverage.html"
else
go test -v ./test/integration/...
fi
;;
"comprehensive")
echo "Running comprehensive tests..."
if [ "$COVERAGE" = "true" ]; then
go test -v ./test/unit/... ./test/integration/... ./test/e2e/... -coverprofile="$OUTPUT_DIR/coverage.out" -covermode=atomic
go tool cover -html="$OUTPUT_DIR/coverage.out" -o "$OUTPUT_DIR/coverage.html"
else
go test -v ./test/unit/... ./test/integration/... ./test/e2e/...
fi
;;
"audit")
echo "Running audit tests..."
if [ "$COVERAGE" = "true" ]; then
go test -v ./test/unit/... ./test/integration/... ./test/e2e/... ./test/property/... ./test/fuzzing/... ./test/security/... -coverprofile="$OUTPUT_DIR/coverage.out" -covermode=atomic
go tool cover -html="$OUTPUT_DIR/coverage.out" -o "$OUTPUT_DIR/coverage.html"
else
go test -v ./test/unit/... ./test/integration/... ./test/e2e/... ./test/property/... ./test/fuzzing/... ./test/security/...
fi
;;
*)
echo "Invalid test level: $TEST_LEVEL. Use: basic, unit, integration, comprehensive, audit"
exit 1
;;
esac
# Generate JUnit output if requested
if [ "$JUNIT_OUTPUT" = "true" ]; then
if command -v go-junit-report &> /dev/null; then
go test -v "$PACKAGE_FILTER" 2>&1 | go-junit-report > "$OUTPUT_DIR/test-results.xml"
else
echo "go-junit-report not found. Install with: go install github.com/jstemmer/go-junit-report@latest"
fi
fi
echo "Test execution completed. Results in $OUTPUT_DIR"