Skip to content

Commit

Permalink
fix: specify timeout in avm_proving.test.ts (#6689)
Browse files Browse the repository at this point in the history
  • Loading branch information
fcarreiro authored May 24, 2024
1 parent 73708ee commit fbe9fc1
Showing 1 changed file with 32 additions and 20 deletions.
52 changes: 32 additions & 20 deletions yarn-project/bb-prover/src/avm_proving.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,40 @@ import path from 'path';

import { type BBSuccess, BB_RESULT, generateAvmProof, verifyAvmProof } from './bb/execute.js';

const TIMEOUT = 30_000;

describe('AVM WitGen, proof generation and verification', () => {
it('Should prove valid execution contract function that performs addition', async () => {
const calldata: Fr[] = [new Fr(1), new Fr(2)];
const context = initContext({ env: initExecutionEnvironment({ calldata }) });
const internalLogger = createDebugLogger('aztec:avm-proving-test');
const logger = (msg: string, _data?: any) => internalLogger.verbose(msg);
const bytecode = getAvmTestContractBytecode('add_args_return');
// The paths for the barretenberg binary and the write path are hardcoded for now.
const bbPath = path.resolve('../../barretenberg/cpp/build/bin/bb');
const bbWorkingDirectory = await fs.mkdtemp(path.join(tmpdir(), 'bb-'));
it(
'Should prove valid execution contract function that performs addition',
async () => {
const calldata: Fr[] = [new Fr(1), new Fr(2)];
const context = initContext({ env: initExecutionEnvironment({ calldata }) });
const internalLogger = createDebugLogger('aztec:avm-proving-test');
const logger = (msg: string, _data?: any) => internalLogger.verbose(msg);
const bytecode = getAvmTestContractBytecode('add_args_return');
// The paths for the barretenberg binary and the write path are hardcoded for now.
const bbPath = path.resolve('../../barretenberg/cpp/build/bin/bb');
const bbWorkingDirectory = await fs.mkdtemp(path.join(tmpdir(), 'bb-'));

// First we simulate (though it's not needed in this simple case).
const results = await new AvmSimulator(context).executeBytecode(bytecode);
expect(results.reverted).toBe(false);
// First we simulate (though it's not needed in this simple case).
const results = await new AvmSimulator(context).executeBytecode(bytecode);
expect(results.reverted).toBe(false);

// Then we prove.
const proofRes = await generateAvmProof(bbPath, bbWorkingDirectory, bytecode, context.environment.calldata, logger);
expect(proofRes.status).toEqual(BB_RESULT.SUCCESS);
// Then we prove.
const proofRes = await generateAvmProof(
bbPath,
bbWorkingDirectory,
bytecode,
context.environment.calldata,
logger,
);
expect(proofRes.status).toEqual(BB_RESULT.SUCCESS);

// Then we verify.
const succeededRes = proofRes as BBSuccess;
const verificationRes = await verifyAvmProof(bbPath, succeededRes.proofPath!, succeededRes.vkPath!, logger);
expect(verificationRes.status).toBe(BB_RESULT.SUCCESS);
});
// Then we verify.
const succeededRes = proofRes as BBSuccess;
const verificationRes = await verifyAvmProof(bbPath, succeededRes.proofPath!, succeededRes.vkPath!, logger);
expect(verificationRes.status).toBe(BB_RESULT.SUCCESS);
},
TIMEOUT,
);
});

0 comments on commit fbe9fc1

Please sign in to comment.