Skip to content

Commit

Permalink
chore: format (#5728)
Browse files Browse the repository at this point in the history
Please read [contributing guidelines](CONTRIBUTING.md) and remove this
line.
  • Loading branch information
IlyasRidhuan authored Apr 12, 2024
1 parent 0666fc7 commit 937bd7c
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions yarn-project/simulator/src/public/avm_executor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,30 @@ describe('AVM WitGen and Proof Generation', () => {
header = makeHeader(randomInt(1000000));
}, 10000);

it('Should prove valid execution contract function that performs addition', async () => {
const addArtifact = AvmTestContractArtifact.functions.find(f => f.name === 'add_args_return')!;
const bytecode = addArtifact.bytecode;
publicContracts.getBytecode.mockResolvedValue(bytecode);
it(
'Should prove valid execution contract function that performs addition',
async () => {
const addArtifact = AvmTestContractArtifact.functions.find(f => f.name === 'add_args_return')!;
const bytecode = addArtifact.bytecode;
publicContracts.getBytecode.mockResolvedValue(bytecode);

const functionData = FunctionData.fromAbi(addArtifact);
const args: Fr[] = [new Fr(99), new Fr(12)];
// We call initContext here to load up a AvmExecutionEnvironment that prepends the calldata with the function selector
// and the args hash. In reality, we should simulate here and get this from the output of the simulation call.
// For now, the interfaces for the PublicExecutor don't quite line up, so we are doing this.
const context = initContext({ env: initExecutionEnvironment({ calldata: args }) });
const execution: PublicExecution = {
contractAddress,
functionData,
args: context.environment.calldata,
callContext,
};
const executor = new PublicExecutor(publicState, publicContracts, commitmentsDb, header);
const [proof, vk] = await executor.getAvmProof(execution);
const valid = await executor.verifyAvmProof(vk, proof);
expect(valid).toBe(true);
}, 60 * 1000); // 60 seconds should be enough to generate the proof with 16-bit range checks
const functionData = FunctionData.fromAbi(addArtifact);
const args: Fr[] = [new Fr(99), new Fr(12)];
// We call initContext here to load up a AvmExecutionEnvironment that prepends the calldata with the function selector
// and the args hash. In reality, we should simulate here and get this from the output of the simulation call.
// For now, the interfaces for the PublicExecutor don't quite line up, so we are doing this.
const context = initContext({ env: initExecutionEnvironment({ calldata: args }) });
const execution: PublicExecution = {
contractAddress,
functionData,
args: context.environment.calldata,
callContext,
};
const executor = new PublicExecutor(publicState, publicContracts, commitmentsDb, header);
const [proof, vk] = await executor.getAvmProof(execution);
const valid = await executor.verifyAvmProof(vk, proof);
expect(valid).toBe(true);
},
60 * 1000,
); // 60 seconds should be enough to generate the proof with 16-bit range checks
});

0 comments on commit 937bd7c

Please sign in to comment.