diff --git a/vite-hardhat/test/index.ts b/vite-hardhat/test/index.ts index 2c6ff2a..a89a4c4 100644 --- a/vite-hardhat/test/index.ts +++ b/vite-hardhat/test/index.ts @@ -5,23 +5,12 @@ import { Noir } from '@noir-lang/noir_js'; import { BarretenbergBackend } from '@noir-lang/backend_barretenberg'; import { compile, createFileManager } from '@noir-lang/noir_wasm'; -import { join } from 'path'; import { CompiledCircuit, ProofData } from '@noir-lang/types'; -import { readFileSync } from 'fs'; +import { join, resolve } from 'path'; -export async function getFile(file_path: string): Promise> { - const file_url = new URL(file_path, import.meta.url); - const response = await fetch(file_url); - - if (!response.ok) throw new Error('Network response was not OK'); - - return response.body as ReadableStream; -} - -async function getCircuit(name: string) { - const fm = createFileManager('/'); - fm.writeFile('./src/main.nr', await getFile(`../circuits/src/main.nr`)); - fm.writeFile('./Nargo.toml', await getFile(`../circuits/Nargo.toml`)); +async function getCircuit() { + const basePath = resolve(join('./circuits')); + const fm = createFileManager(basePath); const result = await compile(fm); if (!('program' in result)) { throw new Error('Compilation failed'); @@ -34,16 +23,16 @@ describe('It compiles noir program code, receiving circuit bytes and abi object. let correctProof: ProofData; before(async () => { - const compiled = await getCircuit('main'); + const compiled = await getCircuit(); const verifierContract = await hre.viem.deployContract('UltraVerifier'); const verifierAddr = verifierContract.address; console.log(`Verifier deployed to ${verifierAddr}`); // @ts-ignore - const backend = new BarretenbergBackend(compiled.program); + const backend = new BarretenbergBackend(compiled); // @ts-ignore - noir = new Noir(compiled.program, backend); + noir = new Noir(compiled, backend); }); it('Should generate valid proof for correct input', async () => {