Skip to content

Commit

Permalink
using debugInfo more
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Feb 29, 2024
1 parent 0a6399b commit 396286f
Showing 1 changed file with 15 additions and 28 deletions.
43 changes: 15 additions & 28 deletions yarn-project/end-to-end/src/e2e_non_contract_account.test.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
import {
AztecNode,
DebugLogger,
ExtendedNote,
Fr,
Note,
PXE,
SignerlessWallet,
TxStatus,
Wallet,
toBigInt,
} from '@aztec/aztec.js';
import { DebugLogger, ExtendedNote, Fr, Note, PXE, SignerlessWallet, Wallet, toBigInt } from '@aztec/aztec.js';
import { siloNullifier } from '@aztec/circuits.js/hash';
import { TestContract } from '@aztec/noir-contracts.js/Test';

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 @@ -27,7 +15,7 @@ describe('e2e_non_contract_account', () => {
let wallet: Wallet;

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

logger(`Deploying L2 contract...`);
Expand All @@ -42,12 +30,13 @@ describe('e2e_non_contract_account', () => {

// Send transaction as arbitrary non-contract account
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 { debugInfo } = await contractWithNoContractWallet.methods
.emit_nullifier(nullifier)
.send()
.wait({ interval: 0.1, debug: true });

const tx = await aztecNode!.getTxEffect(receipt.txHash);
const expectedSiloedNullifier = siloNullifier(contract.address, nullifier);
const siloedNullifier = tx!.nullifiers[1];
const siloedNullifier = debugInfo!.nullifiers[1];

expect(siloedNullifier.equals(expectedSiloedNullifier)).toBeTruthy();
}, 120_000);
Expand All @@ -56,14 +45,14 @@ describe('e2e_non_contract_account', () => {
const contractWithNoContractWallet = await TestContract.at(contract.address, nonContractAccountWallet);

// Send transaction as arbitrary non-contract account
const tx = contractWithNoContractWallet.methods.emit_msg_sender().send();
const receipt = await tx.wait({ interval: 0.1 });
expect(receipt.status).toBe(TxStatus.MINED);
const { debugInfo } = await contractWithNoContractWallet.methods
.emit_msg_sender()
.send()
.wait({ interval: 0.1, debug: true });

const logs = (await tx.getUnencryptedLogs()).logs;
const logs = debugInfo!.unencryptedLogs;
expect(logs.length).toBe(1);

const msgSender = toBigInt(logs[0].log.data);
const msgSender = toBigInt(logs[0]);
expect(msgSender).toBe(0n);
}, 120_000);

Expand All @@ -73,12 +62,10 @@ describe('e2e_non_contract_account', () => {
it('can set and get a constant', async () => {
const value = 123n;

const receipt = await contract.methods.set_constant(value).send().wait({ interval: 0.1 });
const receipt = await contract.methods.set_constant(value).send().wait({ interval: 0.1, debug: true });

// check that 1 note hash was created
const tx = await pxe.getTxEffect(receipt.txHash);
const nonZeroNoteHashes = tx?.noteHashes.filter(c => c.value > 0);
expect(nonZeroNoteHashes?.length).toBe(1);
expect(receipt.debugInfo!.noteHashes.length).toBe(1);

// Add the note
const note = new Note([new Fr(value)]);
Expand Down

0 comments on commit 396286f

Please sign in to comment.