|
| 1 | +VERSION 0.7 |
| 2 | + |
| 3 | +FROM ubuntu:22.04 |
| 4 | +WORKDIR /app |
| 5 | + |
| 6 | +deps: |
| 7 | + RUN apt-get update && apt-get install -y \ |
| 8 | + curl \ |
| 9 | + git \ |
| 10 | + make \ |
| 11 | + nodejs \ |
| 12 | + npm \ |
| 13 | + unzip |
| 14 | + |
| 15 | +test-setup: |
| 16 | + FROM +deps |
| 17 | + COPY aztec-spartan.sh . |
| 18 | + RUN chmod +x aztec-spartan.sh |
| 19 | + # Mock docker and docker compose commands for testing |
| 20 | + RUN mkdir -p /usr/local/bin && \ |
| 21 | + echo '#!/bin/bash\necho "Docker command: $@"' > /usr/local/bin/docker && \ |
| 22 | + echo '#!/bin/bash\necho "Docker compose command: $@"' > /usr/local/bin/docker-compose && \ |
| 23 | + chmod +x /usr/local/bin/docker /usr/local/bin/docker-compose |
| 24 | + |
| 25 | +test-help: |
| 26 | + FROM +test-setup |
| 27 | + RUN ./aztec-spartan.sh | grep -q "Commands:" && \ |
| 28 | + echo "✅ Help command test passed" || \ |
| 29 | + (echo "❌ Help command test failed" && exit 1) |
| 30 | + |
| 31 | +test-no-config: |
| 32 | + FROM +test-setup |
| 33 | + RUN if ./aztec-spartan.sh start 2>&1 | grep -q "Configuration not found"; then \ |
| 34 | + echo "✅ No config test passed"; \ |
| 35 | + else \ |
| 36 | + echo "❌ No config test failed" && exit 1; \ |
| 37 | + fi |
| 38 | + |
| 39 | +test-install: |
| 40 | + FROM +test-setup |
| 41 | + # Test installation with CLI arguments |
| 42 | + RUN echo -e "\n\n" | ./aztec-spartan.sh config \ |
| 43 | + -p 8080 \ |
| 44 | + -p2p 40400 \ |
| 45 | + -ip 1.2.3.4 \ |
| 46 | + -k 0x00 \ |
| 47 | + -n test-validator |
| 48 | + # Verify docker-compose.yml was created and contains correct values |
| 49 | + RUN test -f docker-compose.yml && \ |
| 50 | + grep -q "name: test-validator" docker-compose.yml && \ |
| 51 | + grep -q "P2P_UDP_ANNOUNCE_ADDR=1.2.3.4:40400" docker-compose.yml && \ |
| 52 | + grep -q "AZTEC_PORT=8080" docker-compose.yml && \ |
| 53 | + grep -q "VALIDATOR_PRIVATE_KEY=0x00" docker-compose.yml && \ |
| 54 | + echo "✅ Config test passed" || \ |
| 55 | + (echo "❌ Config test failed" && exit 1) |
| 56 | + |
| 57 | +test-docker-check: |
| 58 | + FROM +deps |
| 59 | + COPY aztec-spartan.sh . |
| 60 | + RUN chmod +x aztec-spartan.sh |
| 61 | + # Remove docker to test docker installation check |
| 62 | + RUN rm -f /usr/local/bin/docker /usr/local/bin/docker-compose |
| 63 | + # Test docker check (should fail since docker is not installed) |
| 64 | + RUN if ./aztec-spartan.sh config 2>&1 | grep -q "Docker or Docker Compose not found"; then \ |
| 65 | + echo "✅ Docker check test passed"; \ |
| 66 | + else \ |
| 67 | + echo "❌ Docker check test failed" && exit 1; \ |
| 68 | + fi |
| 69 | + |
| 70 | +test-start-stop: |
| 71 | + FROM +test-setup |
| 72 | + # First install with test configuration |
| 73 | + RUN echo -e "\n\n" | ./aztec-spartan.sh config \ |
| 74 | + -p 8080 \ |
| 75 | + -p2p 40400 \ |
| 76 | + -ip 1.2.3.4 \ |
| 77 | + -k 0x00 \ |
| 78 | + -n test-validator |
| 79 | + # Test start command |
| 80 | + RUN ./aztec-spartan.sh start 2>&1 | grep -q "Starting containers" && \ |
| 81 | + echo "✅ Start command test passed" || \ |
| 82 | + (echo "❌ Start command test failed" && exit 1) |
| 83 | + # Test stop command |
| 84 | + RUN ./aztec-spartan.sh stop 2>&1 | grep -q "Stopping containers" && \ |
| 85 | + echo "✅ Stop command test passed" || \ |
| 86 | + (echo "❌ Stop command test failed" && exit 1) |
| 87 | + |
| 88 | +test-update: |
| 89 | + FROM +test-setup |
| 90 | + RUN ./aztec-spartan.sh update 2>&1 | grep -q "Pulling latest images" && \ |
| 91 | + echo "✅ Update command test passed" || \ |
| 92 | + (echo "❌ Update command test failed" && exit 1) |
| 93 | + |
| 94 | +test-all: |
| 95 | + BUILD +test-help |
| 96 | + BUILD +test-no-config |
| 97 | + BUILD +test-install |
| 98 | + BUILD +test-docker-check |
| 99 | + BUILD +test-start-stop |
| 100 | + BUILD +test-update |
| 101 | + |
0 commit comments