Skip to content

Commit

Permalink
fixing test
Browse files Browse the repository at this point in the history
  • Loading branch information
signorecello committed Feb 12, 2024
1 parent d228e20 commit 65d82aa
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions vite-hardhat/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ReadableStream<Uint8Array>> {
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<Uint8Array>;
}

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');
Expand All @@ -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 () => {
Expand Down

0 comments on commit 65d82aa

Please sign in to comment.