|
| 1 | +#!/usr/bin/env bash |
| 2 | +set -euo pipefail |
| 3 | + |
| 4 | +# Tests that the default scaffold generated by `aztec new` compiles and passes its tests without any modifications. |
| 5 | +# Also tests that a second contract can be added to the workspace with `aztec new`. |
| 6 | + |
| 7 | +export LOG_LEVEL=silent |
| 8 | + |
| 9 | +aztec new my_workspace |
| 10 | + |
| 11 | +# Verify workspace structure with named crate directories. |
| 12 | +if [ ! -f my_workspace/Nargo.toml ]; then |
| 13 | + echo "Failed to create workspace Nargo.toml." |
| 14 | + exit 1 |
| 15 | +fi |
| 16 | +if [ ! -f my_workspace/my_workspace_contract/Nargo.toml ] || [ ! -f my_workspace/my_workspace_contract/src/main.nr ]; then |
| 17 | + echo "Failed to create contract crate." |
| 18 | + exit 1 |
| 19 | +fi |
| 20 | +if [ ! -f my_workspace/my_workspace_test/Nargo.toml ] || [ ! -f my_workspace/my_workspace_test/src/lib.nr ]; then |
| 21 | + echo "Failed to create test crate." |
| 22 | + exit 1 |
| 23 | +fi |
| 24 | + |
| 25 | +cd my_workspace |
| 26 | + |
| 27 | +# This is unfortunate as it makes the test worse but in CI setting the aztec version is 0.0.1 which doesn't exist as |
| 28 | +# a remote git tag, so we need to rewrite dependencies to use local aztec-nr. |
| 29 | +sed -i 's|aztec = .*git.*AztecProtocol/aztec-nr.*|aztec = { path="/home/ubuntu/aztec-packages/noir-projects/aztec-nr/aztec" }|' \ |
| 30 | + my_workspace_contract/Nargo.toml my_workspace_test/Nargo.toml |
| 31 | + |
| 32 | +# Compile the default scaffold contract. |
| 33 | +aztec compile |
| 34 | + |
| 35 | +# Run the default scaffold tests. |
| 36 | +aztec test |
| 37 | + |
| 38 | +# --- Test adding a second contract to the workspace --- |
| 39 | +aztec new token |
| 40 | + |
| 41 | +# Verify token crates were created. |
| 42 | +if [ ! -f token_contract/Nargo.toml ] || [ ! -f token_contract/src/main.nr ]; then |
| 43 | + echo "Failed to create token contract crate." |
| 44 | + exit 1 |
| 45 | +fi |
| 46 | +if [ ! -f token_test/Nargo.toml ] || [ ! -f token_test/src/lib.nr ]; then |
| 47 | + echo "Failed to create token test crate." |
| 48 | + exit 1 |
| 49 | +fi |
| 50 | + |
| 51 | +# Verify workspace Nargo.toml contains all four members. |
| 52 | +if ! grep -q '"my_workspace_contract"' Nargo.toml || \ |
| 53 | + ! grep -q '"my_workspace_test"' Nargo.toml || \ |
| 54 | + ! grep -q '"token_contract"' Nargo.toml || \ |
| 55 | + ! grep -q '"token_test"' Nargo.toml; then |
| 56 | + echo "Workspace Nargo.toml does not contain all expected members." |
| 57 | + exit 1 |
| 58 | +fi |
| 59 | + |
| 60 | +# Rewrite aztec deps for token crates too. |
| 61 | +sed -i 's|aztec = .*git.*AztecProtocol/aztec-nr.*|aztec = { path="/home/ubuntu/aztec-packages/noir-projects/aztec-nr/aztec" }|' \ |
| 62 | + token_contract/Nargo.toml token_test/Nargo.toml |
| 63 | + |
| 64 | +# Compile and test the full workspace (both contracts). |
| 65 | +aztec compile |
| 66 | +aztec test |
0 commit comments