Skip to content

Commit

Permalink
chore: fix acvm_js linting and tests (#2834)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench authored Sep 26, 2023
1 parent a8f18c5 commit 76ab555
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 97 deletions.
14 changes: 2 additions & 12 deletions .github/workflows/acvm-test-acvm-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
run: yarn workspace @noir-lang/acvm_js test:browser
18 changes: 1 addition & 17 deletions acvm-repo/acvm_js/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -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"],
};
22 changes: 11 additions & 11 deletions acvm-repo/acvm_js/test/browser/execute_circuit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -124,7 +124,7 @@ it("successfully executes a Pedersen opcode", async function () {
initialWitnessMap,
() => {
throw Error("unexpected oracle");
}
},
);

expect(solvedWitness).to.be.deep.eq(expectedWitnessMap);
Expand All @@ -140,7 +140,7 @@ it("successfully executes a FixedBaseScalarMul opcode", async () => {
initialWitnessMap,
() => {
throw Error("unexpected oracle");
}
},
);

expect(solvedWitness).to.be.deep.eq(expectedWitnessMap);
Expand All @@ -156,7 +156,7 @@ it("successfully executes a SchnorrVerify opcode", async () => {
initialWitnessMap,
() => {
throw Error("unexpected oracle");
}
},
);

expect(solvedWitness).to.be.deep.eq(expectedWitnessMap);
Expand All @@ -172,7 +172,7 @@ it("successfully executes a MemoryOp opcode", async () => {
initialWitnessMap,
() => {
throw Error("unexpected oracle");
}
},
);

expect(solvedWitness).to.be.deep.eq(expectedWitnessMap);
Expand All @@ -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);
Expand All @@ -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);
});
24 changes: 12 additions & 12 deletions acvm-repo/acvm_js/test/node/execute_circuit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -118,7 +118,7 @@ it("successfully executes a Pedersen opcode", async function () {
initialWitnessMap,
() => {
throw Error("unexpected oracle");
}
},
);

expect(solvedWitness).to.be.deep.eq(expectedWitnessMap);
Expand All @@ -134,7 +134,7 @@ it("successfully executes a FixedBaseScalarMul opcode", async () => {
initialWitnessMap,
() => {
throw Error("unexpected oracle");
}
},
);

expect(solvedWitness).to.be.deep.eq(expectedWitnessMap);
Expand All @@ -150,7 +150,7 @@ it("successfully executes a SchnorrVerify opcode", async () => {
initialWitnessMap,
() => {
throw Error("unexpected oracle");
}
},
);

expect(solvedWitness).to.be.deep.eq(expectedWitnessMap);
Expand All @@ -166,7 +166,7 @@ it("successfully executes a MemoryOp opcode", async () => {
initialWitnessMap,
() => {
throw Error("unexpected oracle");
}
},
);

expect(solvedWitness).to.be.deep.eq(expectedWitnessMap);
Expand All @@ -190,7 +190,7 @@ it("successfully executes two circuits with same backend", async function () {
initialWitnessMap,
() => {
throw Error("unexpected oracle");
}
},
);

const solvedWitness1 = await executeCircuitWithBlackBoxSolver(
Expand All @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/acvm_js/test/shared/schnorr_verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,5 @@ export const initialWitnessMap = new Map([

export const expectedWitnessMap = new Map(initialWitnessMap).set(
77,
"0x0000000000000000000000000000000000000000000000000000000000000001"
"0x0000000000000000000000000000000000000000000000000000000000000001",
);
44 changes: 0 additions & 44 deletions acvm/acvm_js/Cargo.toml

This file was deleted.

0 comments on commit 76ab555

Please sign in to comment.