Skip to content

Commit

Permalink
chore: add scripts for testing (#2890)
Browse files Browse the repository at this point in the history
Co-authored-by: Tom French <tom@tomfren.ch>
Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 29, 2023
1 parent 6a2cd78 commit 5e43bb6
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 30 deletions.
36 changes: 6 additions & 30 deletions .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
schedule:
- cron: "0 2 * * *" # Run nightly at 2 AM UTC

env:
CI: true

jobs:
build-nargo:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -211,36 +214,9 @@ jobs:
with:
version: nightly

- name: Run Anvil
run: |
anvil > /dev/null 2>&1 &
sleep 10
- name: Create new Foundry project
run: forge init --no-git --no-commit --force foundry-project

- name: Run codegen-verifier for 1_mul
working-directory: tooling/nargo_cli/tests/execution_success/1_mul
run: nargo codegen-verifier

- name: Run codegen-verifier for main
working-directory: compiler/integration-tests/test/circuits/main
run: nargo codegen-verifier

- name: Copy compiled contracts
run: |
cp tooling/nargo_cli/tests/execution_success/1_mul/contract/1_mul/plonk_vk.sol foundry-project/src/1_mul.sol
cp compiler/integration-tests/test/circuits/main/contract/main/plonk_vk.sol foundry-project/src/main.sol
- name: Forge build
working-directory: foundry-project
run: forge build

- name: Forge deploy
working-directory: foundry-project
run: |
forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/1_mul.sol:UltraVerifier --json > mul_output.json
forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/main.sol:UltraVerifier --json > main_output.json
- name: Deploy verifier contracts to Anvil
working-directory: compiler/integration-tests
run: bash ./scripts/setup-project.sh

- name: Setup `integration-tests`
run: |
Expand Down
1 change: 1 addition & 0 deletions compiler/integration-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foundry-project
18 changes: 18 additions & 0 deletions compiler/integration-tests/scripts/codegen-verifiers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

self_path=$(dirname "$(readlink -f "$0")")

repo_root=$self_path/../../..

# Run codegen-verifier for 1_mul
mul_dir=$repo_root/tooling/nargo_cli/tests/execution_success/1_mul
nargo --program-dir $mul_dir codegen-verifier

# Run codegen-verifier for main
main_dir=$repo_root/compiler/integration-tests/test/circuits/main
nargo --program-dir $main_dir codegen-verifier

# Copy compiled contracts from the root of compiler/integration-tests
src_dir=$self_path/../foundry-project/src
cp $mul_dir/contract/1_mul/plonk_vk.sol $src_dir/1_mul.sol
cp $main_dir/contract/main/plonk_vk.sol $src_dir/main.sol
23 changes: 23 additions & 0 deletions compiler/integration-tests/scripts/deploy-verifiers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

self_path=$(dirname "$(readlink -f "$0")")
cd $self_path/../foundry-project

forge build

CI=${CI:-false}
if [[ $CI = true ]]; then
anvil > /dev/null 2>&1 &
else
anvil &
pid=$!
fi

sleep 10

forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/1_mul.sol:UltraVerifier --json > mul_output.json
forge create --rpc-url http://127.0.0.1:8545 --mnemonic "test test test test test test test test test test test junk" src/main.sol:UltraVerifier --json > main_output.json

if [[ $CI = false ]]; then
wait $pid
fi
13 changes: 13 additions & 0 deletions compiler/integration-tests/scripts/forge-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

self_path=$(dirname "$(readlink -f "$0")")

project_path=$self_path/../foundry-project

# Create forge project
forge init --no-git --no-commit --no-deps --force $project_path

# Remove unwanted files
rm -rf $project_path/script
rm -rf $project_path/src/*.sol
rm -rf $project_path/test
7 changes: 7 additions & 0 deletions compiler/integration-tests/scripts/setup-project.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

self_path=$(dirname "$(readlink -f "$0")")

bash $self_path/forge-init.sh
bash $self_path/codegen-verifiers.sh
bash $self_path/deploy-verifiers.sh

0 comments on commit 5e43bb6

Please sign in to comment.