From 76ab555c7cec0d469844a5214086887a0a59530b Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Tue, 26 Sep 2023 11:43:10 +0100 Subject: [PATCH] chore: fix `acvm_js` linting and tests (#2834) --- .github/workflows/acvm-test-acvm-js.yml | 14 +----- acvm-repo/acvm_js/.eslintrc.js | 18 +------- .../test/browser/execute_circuit.test.ts | 22 +++++----- .../acvm_js/test/node/execute_circuit.test.ts | 24 +++++----- .../acvm_js/test/shared/schnorr_verify.ts | 2 +- acvm/acvm_js/Cargo.toml | 44 ------------------- 6 files changed, 27 insertions(+), 97 deletions(-) delete mode 100644 acvm/acvm_js/Cargo.toml diff --git a/.github/workflows/acvm-test-acvm-js.yml b/.github/workflows/acvm-test-acvm-js.yml index 1ba2369f780..d5a9dc07239 100644 --- a/.github/workflows/acvm-test-acvm-js.yml +++ b/.github/workflows/acvm-test-acvm-js.yml @@ -55,14 +55,9 @@ jobs: - name: Set up test environment uses: ./.github/actions/setup - with: - working-directory: ./acvm-repo/acvm_js - name: Run node tests - working-directory: ./acvm-repo/acvm_js - run: | - yarn - yarn test + run: yarn workspace @noir-lang/acvm_js test test-acvm_js-browser: needs: [build-acvm-js-package] @@ -81,17 +76,12 @@ jobs: - name: Set up test environment uses: ./.github/actions/setup - with: - working-directory: ./acvm-repo/acvm_js - name: Install playwright deps - working-directory: ./acvm-repo/acvm_js run: | npx playwright install npx playwright install-deps - name: Run browser tests working-directory: ./acvm-repo/acvm_js - run: | - yarn - yarn test:browser \ No newline at end of file + run: yarn workspace @noir-lang/acvm_js test:browser diff --git a/acvm-repo/acvm_js/.eslintrc.js b/acvm-repo/acvm_js/.eslintrc.js index b1346a8792f..33335c2a877 100644 --- a/acvm-repo/acvm_js/.eslintrc.js +++ b/acvm-repo/acvm_js/.eslintrc.js @@ -1,19 +1,3 @@ module.exports = { - root: true, - parser: "@typescript-eslint/parser", - plugins: ["@typescript-eslint", "prettier"], - extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"], - rules: { - "comma-spacing": ["error", { before: false, after: true }], - "no-unused-vars": "off", - "@typescript-eslint/no-unused-vars": [ - "warn", // or "error" - { - argsIgnorePattern: "^_", - varsIgnorePattern: "^_", - caughtErrorsIgnorePattern: "^_", - }, - ], - "prettier/prettier": "error", - }, + extends: ["../../.eslintrc.js"], }; diff --git a/acvm-repo/acvm_js/test/browser/execute_circuit.test.ts b/acvm-repo/acvm_js/test/browser/execute_circuit.test.ts index 407aa830c65..280b08abed3 100644 --- a/acvm-repo/acvm_js/test/browser/execute_circuit.test.ts +++ b/acvm-repo/acvm_js/test/browser/execute_circuit.test.ts @@ -24,7 +24,7 @@ it("successfully executes circuit and extracts return value", async () => { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); // Solved witness should be consistent with initial witness @@ -50,7 +50,7 @@ it("successfully processes simple brillig foreign call opcodes", async () => { let observedInputs: string[][] = []; const foreignCallHandler: ForeignCallHandler = async ( name: string, - inputs: string[][] + inputs: string[][], ) => { // Throwing inside the oracle callback causes a timeout so we log the observed values // and defer the check against expected values until after the execution is complete. @@ -63,7 +63,7 @@ it("successfully processes simple brillig foreign call opcodes", async () => { const solved_witness: WitnessMap = await executeCircuit( bytecode, initialWitnessMap, - foreignCallHandler + foreignCallHandler, ); // Check that expected values were passed to oracle callback. @@ -89,7 +89,7 @@ it("successfully processes complex brillig foreign call opcodes", async () => { let observedInputs: string[][] = []; const foreignCallHandler: ForeignCallHandler = async ( name: string, - inputs: string[][] + inputs: string[][], ) => { // Throwing inside the oracle callback causes a timeout so we log the observed values // and defer the check against expected values until after the execution is complete. @@ -102,7 +102,7 @@ it("successfully processes complex brillig foreign call opcodes", async () => { const solved_witness: WitnessMap = await executeCircuit( bytecode, initialWitnessMap, - foreignCallHandler + foreignCallHandler, ); // Check that expected values were passed to oracle callback. @@ -124,7 +124,7 @@ it("successfully executes a Pedersen opcode", async function () { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); expect(solvedWitness).to.be.deep.eq(expectedWitnessMap); @@ -140,7 +140,7 @@ it("successfully executes a FixedBaseScalarMul opcode", async () => { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); expect(solvedWitness).to.be.deep.eq(expectedWitnessMap); @@ -156,7 +156,7 @@ it("successfully executes a SchnorrVerify opcode", async () => { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); expect(solvedWitness).to.be.deep.eq(expectedWitnessMap); @@ -172,7 +172,7 @@ it("successfully executes a MemoryOp opcode", async () => { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); expect(solvedWitness).to.be.deep.eq(expectedWitnessMap); @@ -194,7 +194,7 @@ it("successfully executes two circuits with same backend", async function () { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); expect(solvedWitness0).to.be.deep.eq(expectedWitnessMap); @@ -205,7 +205,7 @@ it("successfully executes two circuits with same backend", async function () { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); expect(solvedWitness1).to.be.deep.eq(expectedWitnessMap); }); diff --git a/acvm-repo/acvm_js/test/node/execute_circuit.test.ts b/acvm-repo/acvm_js/test/node/execute_circuit.test.ts index dac93b9f10c..0523d01b9ca 100644 --- a/acvm-repo/acvm_js/test/node/execute_circuit.test.ts +++ b/acvm-repo/acvm_js/test/node/execute_circuit.test.ts @@ -17,7 +17,7 @@ it("successfully executes circuit and extracts return value", async () => { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); // Solved witness should be consistent with initial witness @@ -43,7 +43,7 @@ it("successfully processes simple brillig foreign call opcodes", async () => { let observedInputs: string[][] = []; const foreignCallHandler: ForeignCallHandler = async ( name: string, - inputs: string[][] + inputs: string[][], ) => { // Throwing inside the oracle callback causes a timeout so we log the observed values // and defer the check against expected values until after the execution is complete. @@ -56,7 +56,7 @@ it("successfully processes simple brillig foreign call opcodes", async () => { const solved_witness: WitnessMap = await executeCircuit( bytecode, initialWitnessMap, - foreignCallHandler + foreignCallHandler, ); // Check that expected values were passed to oracle callback. @@ -82,7 +82,7 @@ it("successfully processes complex brillig foreign call opcodes", async () => { let observedInputs: string[][] = []; const foreignCallHandler: ForeignCallHandler = async ( name: string, - inputs: string[][] + inputs: string[][], ) => { // Throwing inside the oracle callback causes a timeout so we log the observed values // and defer the check against expected values until after the execution is complete. @@ -95,7 +95,7 @@ it("successfully processes complex brillig foreign call opcodes", async () => { const solved_witness: WitnessMap = await executeCircuit( bytecode, initialWitnessMap, - foreignCallHandler + foreignCallHandler, ); // Check that expected values were passed to oracle callback. @@ -118,7 +118,7 @@ it("successfully executes a Pedersen opcode", async function () { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); expect(solvedWitness).to.be.deep.eq(expectedWitnessMap); @@ -134,7 +134,7 @@ it("successfully executes a FixedBaseScalarMul opcode", async () => { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); expect(solvedWitness).to.be.deep.eq(expectedWitnessMap); @@ -150,7 +150,7 @@ it("successfully executes a SchnorrVerify opcode", async () => { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); expect(solvedWitness).to.be.deep.eq(expectedWitnessMap); @@ -166,7 +166,7 @@ it("successfully executes a MemoryOp opcode", async () => { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); expect(solvedWitness).to.be.deep.eq(expectedWitnessMap); @@ -190,7 +190,7 @@ it("successfully executes two circuits with same backend", async function () { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); const solvedWitness1 = await executeCircuitWithBlackBoxSolver( @@ -199,7 +199,7 @@ it("successfully executes two circuits with same backend", async function () { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); expect(solvedWitness0).to.be.deep.eq(expectedWitnessMap); @@ -225,7 +225,7 @@ it("successfully executes 500 circuits with same backend", async function () { initialWitnessMap, () => { throw Error("unexpected oracle"); - } + }, ); expect(solvedWitness).to.be.deep.eq(expectedWitnessMap); diff --git a/acvm-repo/acvm_js/test/shared/schnorr_verify.ts b/acvm-repo/acvm_js/test/shared/schnorr_verify.ts index fa91713474e..de9e61e757c 100644 --- a/acvm-repo/acvm_js/test/shared/schnorr_verify.ts +++ b/acvm-repo/acvm_js/test/shared/schnorr_verify.ts @@ -101,5 +101,5 @@ export const initialWitnessMap = new Map([ export const expectedWitnessMap = new Map(initialWitnessMap).set( 77, - "0x0000000000000000000000000000000000000000000000000000000000000001" + "0x0000000000000000000000000000000000000000000000000000000000000001", ); diff --git a/acvm/acvm_js/Cargo.toml b/acvm/acvm_js/Cargo.toml deleted file mode 100644 index 09f47b18edb..00000000000 --- a/acvm/acvm_js/Cargo.toml +++ /dev/null @@ -1,44 +0,0 @@ -[package] -name = "acvm_js" -description = "Typescript wrapper around the ACVM allowing execution of ACIR code" -# x-release-please-start-version -version = "0.27.0" -# x-release-please-end -authors.workspace = true -edition.workspace = true -license.workspace = true -rust-version.workspace = true -repository.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[lib] -crate-type = ["cdylib"] - -[dependencies] -cfg-if = "1.0.0" - -[target.'cfg(target_arch = "wasm32")'.dependencies] -acvm = { path = "../acvm", default-features = false } -barretenberg_blackbox_solver = { path = "../barretenberg_blackbox_solver", default-features = false } -wasm-bindgen = { version = "0.2.86", features = ["serde-serialize"] } -wasm-bindgen-futures = "0.4.36" -serde = { version = "1.0.136", features = ["derive"] } -log = "0.4.17" -wasm-logger = "0.2.0" -console_error_panic_hook = "0.1.7" -gloo-utils = { version = "0.1", features = ["serde"] } -js-sys = "0.3.62" -const-str = "0.5.5" - -[build-dependencies] -build-data = "0.1.3" -pkg-config = "0.3" - -[dev-dependencies] -wasm-bindgen-test = "0.3.36" - -[features] -default = ["bn254"] -bn254 = ["acvm/bn254", "barretenberg_blackbox_solver/bn254"] -bls12_381 = ["acvm/bls12_381", "barretenberg_blackbox_solver/bls12_381"]