diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..513aa90 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,67 @@ +name: Tests + +on: + push: + pull_request: + branches: [main] + +env: + CLI_VERSION: 0.16.9 + SANDBOX_VERSION: 0.16.9 + +jobs: + unit: + name: "Integration tests" + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Create docker network + run: docker network create aztec_network + + - name: Start ethereum service + run: | + docker run --rm -d --hostname ethereum --name ethereum \ + --network=aztec_network \ + -p 8545:8545 \ + --entrypoint anvil \ + ghcr.io/foundry-rs/foundry@sha256:29ba6e34379e79c342ec02d437beb7929c9e254261e8032b17e187be71a2609f \ + -p 8545 --host 0.0.0.0 --chain-id 31337 --silent + + - name: Start aztec service + run: | + docker run --rm -d --hostname aztec --name aztec \ + --network=aztec_network \ + -p 8079:8079 \ + -p 8080:8080 \ + -e DEBUG \ + -e HOST_WORKDIR=$PWD \ + -e ETHEREUM_HOST=http://ethereum:8545 \ + -e CHAIN_ID=31337 \ + -e ARCHIVER_POLLING_INTERVAL_MS=50 \ + -e P2P_BLOCK_CHECK_INTERVAL_MS=50 \ + -e SEQ_TX_POLLING_INTERVAL_MS=50 \ + -e WS_BLOCK_CHECK_INTERVAL_MS=50 \ + -e PXE_BLOCK_POLLING_INTERVAL_MS=50 \ + -e ARCHIVER_VIEM_POLLING_INTERVAL_MS=500 \ + aztecprotocol/aztec-sandbox:$SANDBOX_VERSION + + - name: Wait for services to start + id: wait_for_aztec_service + run: | + PXE_IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' aztec) + echo "Waiting for aztec service to start at $PXE_IP..." + while ! nc -z $PXE_IP 8080; do + sleep 1 + done + echo "PXE_URL=http://$PXE_IP:8080" >> "$GITHUB_ENV" + + - name: Install dependencies + run: npm install + + - name: Compile contracts + run: ./scripts/compile-ci.sh + + - name: Deploy contracts and run tests + run: SKIP_COMPILE=1 ./scripts/test.sh diff --git a/README.md b/README.md index c5a2014..ec1b655 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![Aztec Sandbox](https://img.shields.io/badge/Aztec_Sandbox-0.16.9-darkviolet)](https://github.com/AztecProtocol/aztec-packages) [![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-green)](https://opensource.org/license/apache-2-0) +[![Tests](https://github.com/michaelelliot/zkpassport-aztec-sandbox/actions/workflows/test.yml/badge.svg)](https://github.com/michaelelliot/zkpassport-aztec-sandbox/actions/workflows/test.yml) A prototype for private token transfers on Aztec Network featuring integrated compliance mechanisms like per transaction send limits, transaction send diff --git a/scripts/compile-ci.sh b/scripts/compile-ci.sh new file mode 100755 index 0000000..1ea32ef --- /dev/null +++ b/scripts/compile-ci.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -e + +function compile_contract() { + echo "Compiling $1..." + mkdir -p cache + mkdir -p "$HOME/.aztec/cache" + mkdir -p src/interfaces + docker run --rm --user 1001:127 \ + --network=aztec_network \ + --workdir $PWD \ + -e PXE_URL=$PXE_URL \ + -e XDG_CACHE_HOME=/cache \ + -v $PWD/src/contracts/$1:$PWD/src/contracts/$1 \ + -v $HOME/.aztec/cache:/cache \ + -v $PWD:$PWD aztecprotocol/cli:$CLI_VERSION \ + compile -ts target src/contracts/$1 --compiler wasm + mv src/contracts/$1/target/*.{json,ts} src/interfaces/ + rm -d src/contracts/$1/target +} + +compile_contract slow_tree +compile_contract zkpassport_token