From 519cbc93737dd95dfd1e4ef004dd7d1847fe4c68 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 18 Feb 2025 16:05:10 +0100 Subject: [PATCH] fix linting --- .../multiplierNoir/tests/multiplier.test.ts | 49 +++++------ .../stealthdropNoir/tests/stealthdrop.test.ts | 81 ++++++++++--------- 2 files changed, 66 insertions(+), 64 deletions(-) diff --git a/libs/remix-ws-templates/src/templates/multiplierNoir/tests/multiplier.test.ts b/libs/remix-ws-templates/src/templates/multiplierNoir/tests/multiplier.test.ts index 23c3e00dc5..2921c1b8f8 100644 --- a/libs/remix-ws-templates/src/templates/multiplierNoir/tests/multiplier.test.ts +++ b/libs/remix-ws-templates/src/templates/multiplierNoir/tests/multiplier.test.ts @@ -1,41 +1,42 @@ +// eslint-disable-next-line @typescript-eslint/no-var-requires const { expect } = require('chai') import { compile, createFileManager } from '@noir-lang/noir_wasm' import { Noir } from '@noir-lang/noir_js' import { UltraPlonkBackend } from '@aztec/bb.js' async function getCircuit() { - const fm = createFileManager('/') + const fm = createFileManager('/') - const circuit = await remix.call('fileManager', 'readFile', 'src/main.nr') - const nargoToml = await remix.call('fileManager', 'readFile', 'Nargo.toml') - const tomlBytes = new TextEncoder().encode(nargoToml) - const mainBytes = new TextEncoder().encode(circuit) - await fm.writeFile('./src/main.nr', new Blob([mainBytes]).stream()) - await fm.writeFile('Nargo.toml', new Blob([tomlBytes]).stream()) + const circuit = await remix.call('fileManager', 'readFile', 'src/main.nr') + const nargoToml = await remix.call('fileManager', 'readFile', 'Nargo.toml') + const tomlBytes = new TextEncoder().encode(nargoToml) + const mainBytes = new TextEncoder().encode(circuit) + await fm.writeFile('./src/main.nr', new Blob([mainBytes]).stream()) + await fm.writeFile('Nargo.toml', new Blob([tomlBytes]).stream()) - const result = await compile(fm) - if (!('program' in result)) { - throw new Error('Compilation failed') - } + const result = await compile(fm) + if (!('program' in result)) { + throw new Error('Compilation failed') + } - return result.program + return result.program } describe('Noir Program Test', () => { - it('should compile, execute, prove, and verify', async () => { - const noir_program = await getCircuit() + it('should compile, execute, prove, and verify', async () => { + const noir_program = await getCircuit() - const inputs = { a: 20, b: 40 } + const inputs = { a: 20, b: 40 } - // JS Proving - const program = new Noir(noir_program) - const { witness } = await program.execute(inputs) + // JS Proving + const program = new Noir(noir_program) + const { witness } = await program.execute(inputs) - const backend = new UltraPlonkBackend(noir_program.bytecode) - const proof = await backend.generateProof(witness) + const backend = new UltraPlonkBackend(noir_program.bytecode) + const proof = await backend.generateProof(witness) - // JS verification - const verified = await backend.verifyProof(proof) - expect(verified, 'Proof fails verification in JS').to.be.true - }) + // JS verification + const verified = await backend.verifyProof(proof) + expect(verified, 'Proof fails verification in JS').to.be.true + }) }) \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/stealthdropNoir/tests/stealthdrop.test.ts b/libs/remix-ws-templates/src/templates/stealthdropNoir/tests/stealthdrop.test.ts index 59e0b111d1..b16dc4e93b 100644 --- a/libs/remix-ws-templates/src/templates/stealthdropNoir/tests/stealthdrop.test.ts +++ b/libs/remix-ws-templates/src/templates/stealthdropNoir/tests/stealthdrop.test.ts @@ -1,51 +1,52 @@ +// eslint-disable-next-line @typescript-eslint/no-var-requires const { expect } = require('chai') import { compile, createFileManager } from '@noir-lang/noir_wasm' import { Noir } from '@noir-lang/noir_js' import { UltraPlonkBackend } from '@aztec/bb.js' async function getCircuit() { - const fm = createFileManager('/') - - const circuit = await remix.call('fileManager', 'readFile', 'src/main.nr') - const nargoToml = await remix.call('fileManager', 'readFile', 'Nargo.toml') - const tomlBytes = new TextEncoder().encode(nargoToml) - const mainBytes = new TextEncoder().encode(circuit) - await fm.writeFile('./src/main.nr', new Blob([mainBytes]).stream()) - await fm.writeFile('Nargo.toml', new Blob([tomlBytes]).stream()) - - const result = await compile(fm) - if (!('program' in result)) { - throw new Error('Compilation failed') - } + const fm = createFileManager('/') + + const circuit = await remix.call('fileManager', 'readFile', 'src/main.nr') + const nargoToml = await remix.call('fileManager', 'readFile', 'Nargo.toml') + const tomlBytes = new TextEncoder().encode(nargoToml) + const mainBytes = new TextEncoder().encode(circuit) + await fm.writeFile('./src/main.nr', new Blob([mainBytes]).stream()) + await fm.writeFile('Nargo.toml', new Blob([tomlBytes]).stream()) - return result.program + const result = await compile(fm) + if (!('program' in result)) { + throw new Error('Compilation failed') + } + + return result.program } describe('Noir Program Test', () => { - it('should compile, execute, prove, and verify', async () => { - const noir_program = await getCircuit() - - const inputs = { - pub_key: '', - signature: '', - hashed_message: '', - nullifier: '', - merkle_path: '', - index: '', - merkle_root: '', - claimer_priv: '', - claimer_pub: '' - } - - // JS Proving - const program = new Noir(noir_program) - const { witness } = await program.execute(inputs) - - const backend = new UltraPlonkBackend(noir_program.bytecode) - const proof = await backend.generateProof(witness) - - // JS verification - const verified = await backend.verifyProof(proof) - expect(verified, 'Proof fails verification in JS').to.be.true - }) + it('should compile, execute, prove, and verify', async () => { + const noir_program = await getCircuit() + + const inputs = { + pub_key: '', + signature: '', + hashed_message: '', + nullifier: '', + merkle_path: '', + index: '', + merkle_root: '', + claimer_priv: '', + claimer_pub: '' + } + + // JS Proving + const program = new Noir(noir_program) + const { witness } = await program.execute(inputs) + + const backend = new UltraPlonkBackend(noir_program.bytecode) + const proof = await backend.generateProof(witness) + + // JS verification + const verified = await backend.verifyProof(proof) + expect(verified, 'Proof fails verification in JS').to.be.true + }) }) \ No newline at end of file