Skip to content

Commit

Permalink
chore: add recursive integration test (noir-lang#2763)
Browse files Browse the repository at this point in the history
  • Loading branch information
kobyhallx authored and Sakapoi committed Oct 19, 2023
1 parent 0355eb2 commit a0ebd05
Show file tree
Hide file tree
Showing 19 changed files with 331 additions and 45 deletions.
23 changes: 0 additions & 23 deletions .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
- ./compiler/integration-tests/**
schedule:
- cron: "0 2 * * *" # Run nightly at 2 AM UTC

jobs:
wasm-packages-build-test:
runs-on: ubuntu-latest
Expand All @@ -18,12 +17,6 @@ jobs:
- name: Checkout noir sources
uses: actions/checkout@v4

- name: Checkout acvm sources
uses: actions/checkout@v3 # v3 is needed here otherwise this fails in local execution
with:
repository: noir-lang/acvm
path: acvm

- name: Setup Nix
uses: cachix/install-nix-action@v22
with:
Expand All @@ -35,22 +28,6 @@ jobs:
name: barretenberg
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"

- name: Restore nix store cache
uses: actions/cache/restore@v3
id: cache
with:
path: ${{ env.CACHED_PATH }}
key: ${{ runner.os }}-flake-wasm-${{ hashFiles('*.lock') }}

# Based on https://github.com/marigold-dev/deku/blob/b5016f0cf4bf6ac48db9111b70dd7fb49b969dfd/.github/workflows/build.yml#L26
- name: Copy cache into nix store
if: steps.cache.outputs.cache-hit == 'true'
# We don't check the signature because we're the one that created the cache
run: |
for narinfo in ${{ env.CACHED_PATH }}/*.narinfo; do
path=$(head -n 1 "$narinfo" | awk '{print $2}')
nix copy --no-check-sigs --from "file://${{ env.CACHED_PATH }}" "$path"
done

- name: Build noir_wasm package
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ compiler/wasm/nodejs
compiler/wasm/web
tooling/noirc_abi_wasm/nodejs
tooling/noirc_abi_wasm/web
tooling/noir_js/lib
5 changes: 3 additions & 2 deletions compiler/integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
"lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0"
},
"dependencies": {
"@aztec/bb.js": "^0.6.7",
"@aztec/bb.js": "0.7.2",
"@noir-lang/noir_js": "workspace:*",
"@noir-lang/noir_wasm": "workspace:*",
"@noir-lang/source-resolver": "workspace:*",
"@web/dev-server-esbuild": "^0.3.6",
"@web/test-runner": "^0.15.3",
"@web/test-runner-webdriver": "^0.7.0",
"fflate": "^0.8.0",
"smol-toml": "^1.1.2"
"smol-toml": "^1.1.2",
"tslog": "^4.9.2"
}
}
7 changes: 7 additions & 0 deletions compiler/integration-tests/test/circuits/main/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "main"
type = "bin"
authors = [""]
compiler_version = "0.9.0"

[dependencies]
2 changes: 2 additions & 0 deletions compiler/integration-tests/test/circuits/main/Prover.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x = 1
y = 2
3 changes: 3 additions & 0 deletions compiler/integration-tests/test/circuits/main/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main(x : Field, y : pub Field) {
assert(x != y);
}
7 changes: 7 additions & 0 deletions compiler/integration-tests/test/circuits/recursion/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "recursion"
type = "bin"
authors = [""]
compiler_version = "0.9.0"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
input_aggregation_object = ["0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"]
20 changes: 20 additions & 0 deletions compiler/integration-tests/test/circuits/recursion/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use dep::std;

fn main(
verification_key : [Field; 114],
proof : [Field; 94],
public_inputs : [Field; 1],
key_hash : Field,
input_aggregation_object : [Field; 16],
) -> pub [Field;16]{
let vk : [Field] = verification_key;
let p : [Field] = proof;
let pi : [Field] = public_inputs;
std::verify_proof(
vk,
p,
pi,
key_hash,
input_aggregation_object
)
}
1 change: 1 addition & 0 deletions compiler/integration-tests/test/environment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const TEST_LOG_LEVEL = 5; // 0: silly, 1: trace, 2: debug, 3: info, 4: warn, 5: error, 6: fatal
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import { expect } from "@esm-bundle/chai";
import { TEST_LOG_LEVEL } from "../../environment.js";
import { Logger } from "tslog";
import { initializeResolver } from "@noir-lang/source-resolver";
import newCompiler, {
compile,
init_log_level as compilerLogLevel,
} from "@noir-lang/noir_wasm";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
import { Barretenberg, RawBuffer, Crs } from "@aztec/bb.js";
import { acvm, abi } from "@noir-lang/noir_js";
import { decompressSync as gunzip } from "fflate";

import * as TOML from "smol-toml";

const logger = new Logger({ name: "test", minLevel: TEST_LOG_LEVEL });

const { default: initACVM, executeCircuit, compressWitness } = acvm;
const { default: newABICoder, abiEncode } = abi;

Expand All @@ -19,7 +25,7 @@ await newCompiler();
await newABICoder();
await initACVM();

compilerLogLevel("DEBUG");
compilerLogLevel("INFO");

async function getFile(url: URL): Promise<string> {
const response = await fetch(url);
Expand Down Expand Up @@ -48,6 +54,9 @@ suite.timeout(60 * 20e3); //20mins

test_cases.forEach((testInfo) => {
const test_name = testInfo.case.split("/").pop();
const caseLogger = logger.getSubLogger({
prefix: [test_name],
});
const mochaTest = new Mocha.Test(
`${test_name} (Compile, Execute, Prove, Verify)`,
async () => {
Expand All @@ -69,7 +78,7 @@ test_cases.forEach((testInfo) => {
expect(noir_source).to.be.a.string;

initializeResolver((id: string) => {
console.log("Resolving:", id);
caseLogger.debug("source-resolver: resolving:", id);
return noir_source;
});

Expand Down
Loading

0 comments on commit a0ebd05

Please sign in to comment.