Skip to content

Commit

Permalink
better test
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Oct 20, 2023
1 parent 1d5ef68 commit 4b8b1b2
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions yarn-project/end-to-end/src/e2e_non_contract_account.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { SignerlessWallet, Wallet } from '@aztec/aztec.js';
import { CircuitsWasm, Fr } from '@aztec/circuits.js';
import { siloNullifier } from '@aztec/circuits.js/abis';
import { DebugLogger } from '@aztec/foundation/log';
import { TestContract } from '@aztec/noir-contracts/types';
import { PXE, TxStatus } from '@aztec/types';
import { AztecNode, PXE, TxStatus } from '@aztec/types';

import { setup } from './fixtures/utils.js';

describe('e2e_non_contract_account', () => {
let aztecNode: AztecNode | undefined;
let pxe: PXE;
let nonContractAccountWallet: Wallet;
let teardown: () => Promise<void>;
Expand All @@ -16,7 +19,7 @@ describe('e2e_non_contract_account', () => {

beforeEach(async () => {
let wallet: Wallet;
({ teardown, pxe, wallet, logger } = await setup(1));
({ teardown, aztecNode, pxe, wallet, logger } = await setup(1));
nonContractAccountWallet = new SignerlessWallet(pxe);

logger(`Deploying L2 contract...`);
Expand All @@ -30,7 +33,14 @@ describe('e2e_non_contract_account', () => {
const contractWithNoContractWallet = await TestContract.at(contract.address, nonContractAccountWallet);

// Send transaction as arbitrary non-contract account
const receipt = await contractWithNoContractWallet.methods.getThisAddress().send().wait({ interval: 0.1 });
const nullifier = new Fr(940);
const receipt = await contractWithNoContractWallet.methods.emit_nullifier(nullifier).send().wait({ interval: 0.1 });
expect(receipt.status).toBe(TxStatus.MINED);

const tx = await aztecNode!.getTx(receipt.txHash);
const expectedSiloedNullifier = siloNullifier(await CircuitsWasm.get(), contract.address, nullifier);
const siloedNullifier = tx!.newNullifiers[1];

expect(siloedNullifier.equals(expectedSiloedNullifier)).toBeTruthy();
}, 120_000);
});

0 comments on commit 4b8b1b2

Please sign in to comment.