Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move e2e-avm-initializer test to e2e-avm-simulator #5570

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions yarn-project/end-to-end/src/e2e_avm_initializer.test.ts

This file was deleted.

81 changes: 49 additions & 32 deletions yarn-project/end-to-end/src/e2e_avm_simulator.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AztecAddress, Fr, TxStatus, type Wallet } from '@aztec/aztec.js';
import { AvmTestContract } from '@aztec/noir-contracts.js';
import { AvmInitializerTestContract, AvmTestContract } from '@aztec/noir-contracts.js';

import { jest } from '@jest/globals';

Expand All @@ -11,7 +11,6 @@ describe('e2e_avm_simulator', () => {
jest.setTimeout(TIMEOUT);

let wallet: Wallet;
let avmContact: AvmTestContract;
let teardown: () => Promise<void>;

beforeAll(async () => {
Expand All @@ -20,46 +19,64 @@ describe('e2e_avm_simulator', () => {

afterAll(() => teardown());

beforeEach(async () => {
avmContact = await AvmTestContract.deploy(wallet).send().deployed();
}, 50_000);
describe('AvmTestContract', () => {
let avmContract: AvmTestContract;

describe('Storage', () => {
it('Modifies storage (Field)', async () => {
await avmContact.methods.set_storage_single(20n).send().wait();
expect(await avmContact.methods.view_storage_single().simulate()).toEqual(20n);
beforeEach(async () => {
avmContract = await AvmTestContract.deploy(wallet).send().deployed();
}, 50_000);

describe('Storage', () => {
it('Modifies storage (Field)', async () => {
await avmContract.methods.set_storage_single(20n).send().wait();
expect(await avmContract.methods.view_storage_single().simulate()).toEqual(20n);
});

it('Modifies storage (Map)', async () => {
const address = AztecAddress.fromBigInt(9090n);
await avmContract.methods.set_storage_map(address, 100).send().wait();
await avmContract.methods.add_storage_map(address, 100).send().wait();
expect(await avmContract.methods.view_storage_map(address).simulate()).toEqual(200n);
});
});

it('Modifies storage (Map)', async () => {
const address = AztecAddress.fromBigInt(9090n);
await avmContact.methods.set_storage_map(address, 100).send().wait();
await avmContact.methods.add_storage_map(address, 100).send().wait();
expect(await avmContact.methods.view_storage_map(address).simulate()).toEqual(200n);
describe('Contract instance', () => {
it('Works', async () => {
const tx = await avmContract.methods.test_get_contract_instance().send().wait();
expect(tx.status).toEqual(TxStatus.MINED);
});
});
});

describe('Contract instance', () => {
it('Works', async () => {
const tx = await avmContact.methods.test_get_contract_instance().send().wait();
expect(tx.status).toEqual(TxStatus.MINED);
describe('Nullifiers', () => {
// Nullifier will not yet be siloed by the kernel.
it('Emit and check in the same tx', async () => {
const tx = await avmContract.methods.emit_nullifier_and_check(123456).send().wait();
expect(tx.status).toEqual(TxStatus.MINED);
});

// Nullifier will have been siloed by the kernel, but we check against the unsiloed one.
it('Emit and check in separate tx', async () => {
const nullifier = new Fr(123456);
let tx = await avmContract.methods.new_nullifier(nullifier).send().wait();
expect(tx.status).toEqual(TxStatus.MINED);

tx = await avmContract.methods.assert_nullifier_exists(nullifier).send().wait();
expect(tx.status).toEqual(TxStatus.MINED);
});
});
});

describe('Nullifiers', () => {
// Nullifier will not yet be siloed by the kernel.
it('Emit and check in the same tx', async () => {
const tx = await avmContact.methods.emit_nullifier_and_check(123456).send().wait();
expect(tx.status).toEqual(TxStatus.MINED);
});
describe('AvmInitializerTestContract', () => {
let avmContract: AvmInitializerTestContract;

// Nullifier will have been siloed by the kernel, but we check against the unsiloed one.
it('Emit and check in separate tx', async () => {
const nullifier = new Fr(123456);
let tx = await avmContact.methods.new_nullifier(nullifier).send().wait();
expect(tx.status).toEqual(TxStatus.MINED);
beforeEach(async () => {
avmContract = await AvmInitializerTestContract.deploy(wallet).send().deployed();
}, 50_000);

tx = await avmContact.methods.assert_nullifier_exists(nullifier).send().wait();
expect(tx.status).toEqual(TxStatus.MINED);
describe('Storage', () => {
it('Read immutable (initialized) storage (Field)', async () => {
expect(await avmContract.methods.view_storage_immutable().simulate()).toEqual(42n);
});
});
});
});
Loading