Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes
Browse files Browse the repository at this point in the history
benesjan committed Oct 23, 2023
1 parent 4879039 commit 8a1f21a
Showing 4 changed files with 23 additions and 55 deletions.
26 changes: 7 additions & 19 deletions yarn-project/boxes/token/src/tests/token.contract.test.ts
Original file line number Diff line number Diff line change
@@ -273,9 +273,7 @@ describe('e2e_token_contract', () => {
.withWallet(wallets[1])
.methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce)
.send();
await txReplay.isMined();
const receiptReplay = await txReplay.getReceipt();
expect(receiptReplay.status).toBe(TxStatus.DROPPED);
await expect(txReplay.wait()).rejects.toThrowError("Transaction ");
});

describe('failure cases', () => {
@@ -427,9 +425,7 @@ describe('e2e_token_contract', () => {
.withWallet(wallets[1])
.methods.transfer(accounts[0].address, accounts[1].address, amount, nonce)
.send();
await txReplay.isMined();
const receiptReplay = await txReplay.getReceipt();
expect(receiptReplay.status).toBe(TxStatus.DROPPED);
await expect(txReplay.wait()).rejects.toThrowError("Transaction ");
});

describe('failure cases', () => {
@@ -570,9 +566,7 @@ describe('e2e_token_contract', () => {
.withWallet(wallets[1])
.methods.shield(accounts[0].address, amount, secretHash, nonce)
.send();
await txReplay.isMined();
const receiptReplay = await txReplay.getReceipt();
expect(receiptReplay.status).toBe(TxStatus.DROPPED);
await expect(txReplay.wait()).rejects.toThrowError("Transaction ");

// Redeem it
await addPendingShieldNoteToPXE(0, amount, secretHash, receipt.txHash);
@@ -686,9 +680,7 @@ describe('e2e_token_contract', () => {
.withWallet(wallets[1])
.methods.unshield(accounts[0].address, accounts[1].address, amount, nonce)
.send();
await txReplay.isMined();
const receiptReplay = await txReplay.getReceipt();
expect(receiptReplay.status).toBe(TxStatus.DROPPED);
await expect(txReplay.wait()).rejects.toThrowError("Transaction ");
});

describe('failure cases', () => {
@@ -789,11 +781,9 @@ describe('e2e_token_contract', () => {

tokenSim.burnPublic(accounts[0].address, amount);

const burnTx = asset.withWallet(wallets[1]).methods.burn_public(accounts[0].address, amount, nonce).send();
// Check that the message hash is no longer valid. Need to try to send since nullifiers are handled by sequencer.
const txReplay = asset.withWallet(wallets[1]).methods.burn_public(accounts[0].address, amount, nonce).send();
await txReplay.isMined();
const receiptReplay = await txReplay.getReceipt();
expect(receiptReplay.status).toBe(TxStatus.DROPPED);
await expect(burnTx.wait()).rejects.toThrowError("Transaction ");
});

describe('failure cases', () => {
@@ -891,9 +881,7 @@ describe('e2e_token_contract', () => {

// Perform the transfer again, should fail
const txReplay = asset.withWallet(wallets[1]).methods.burn(accounts[0].address, amount, nonce).send();
await txReplay.isMined();
const receiptReplay = await txReplay.getReceipt();
expect(receiptReplay.status).toBe(TxStatus.DROPPED);
await expect(txReplay.wait()).rejects.toThrowError("Transaction ");
});

describe('failure cases', () => {
5 changes: 2 additions & 3 deletions yarn-project/end-to-end/src/e2e_cheat_codes.test.ts
Original file line number Diff line number Diff line change
@@ -2,14 +2,13 @@ import { CheatCodes, Wallet } from '@aztec/aztec.js';
import { RollupAbi } from '@aztec/l1-artifacts';
import { TestContract } from '@aztec/noir-contracts/types';
import { EthAddress } from '@aztec/pxe';
import { PXE, TxStatus } from '@aztec/types';
import { TxStatus } from '@aztec/types';

import { Account, Chain, HttpTransport, PublicClient, WalletClient, getAddress, getContract, parseEther } from 'viem';

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

describe('e2e_cheat_codes', () => {
let pxe: PXE;
let wallet: Wallet;
let cc: CheatCodes;
let teardown: () => Promise<void>;
@@ -20,7 +19,7 @@ describe('e2e_cheat_codes', () => {

beforeAll(async () => {
let deployL1ContractsValues;
({ teardown, pxe, wallet, cheatCodes: cc, deployL1ContractsValues } = await setup());
({ teardown, wallet, cheatCodes: cc, deployL1ContractsValues } = await setup());

walletClient = deployL1ContractsValues.walletClient;
publicClient = deployL1ContractsValues.publicClient;
Original file line number Diff line number Diff line change
@@ -150,28 +150,24 @@ describe('e2e_pending_commitments_contract', () => {
const deployedContract = await deployContract();

// create persistent note
const tx0 = deployedContract.methods.insert_note(mintAmount, owner).send();

await tx0.isMined({ interval: 0.1 });
const receipt0 = await tx0.getReceipt();
const receipt0 = await deployedContract.methods.insert_note(mintAmount, owner).send().wait();
expect(receipt0.status).toBe(TxStatus.MINED);

await expectCommitmentsSquashedExcept(1); // first TX just creates 1 persistent note
await expectNullifiersSquashedExcept(0);

// create another note, and nullify it and AND nullify the above-created note in the same TX
const tx1 = deployedContract.methods
const receipt1 = await deployedContract.methods
.test_insert1_then_get2_then_nullify2_all_in_nested_calls(
mintAmount,
owner,
deployedContract.methods.insert_note.selector.toField(),
deployedContract.methods.get_then_nullify_note.selector.toField(),
deployedContract.methods.get_note_zero_balance.selector.toField(),
)
.send();
.send()
.wait();

await tx1.isMined({ interval: 0.1 });
const receipt1 = await tx1.getReceipt();
expect(receipt1.status).toBe(TxStatus.MINED);

// second TX creates 1 note, but it is squashed!
@@ -190,27 +186,24 @@ describe('e2e_pending_commitments_contract', () => {
const mintAmount = 65n;

const deployedContract = await deployContract();
const tx0 = deployedContract.methods.insert_note(mintAmount, owner).send();
const receipt = await deployedContract.methods.insert_note(mintAmount, owner).send().wait();

await tx0.isMined({ interval: 0.1 });
const receipt = await tx0.getReceipt();
expect(receipt.status).toBe(TxStatus.MINED);

// There is a single new commitment/note.
await expectCommitmentsSquashedExcept(1);

const tx1 = deployedContract.methods
const receipt2 = await deployedContract.methods
.test_insert_then_get_then_nullify_all_in_nested_calls(
mintAmount,
owner,
deployedContract.methods.dummy.selector.toField(),
deployedContract.methods.get_then_nullify_note.selector.toField(),
deployedContract.methods.get_note_zero_balance.selector.toField(),
)
.send();
.send()
.wait();

await tx1.isMined({ interval: 0.1 });
const receipt2 = await tx1.getReceipt();
expect(receipt2.status).toBe(TxStatus.MINED);

// There is a single new nullifier.
24 changes: 6 additions & 18 deletions yarn-project/end-to-end/src/e2e_token_contract.test.ts
Original file line number Diff line number Diff line change
@@ -266,9 +266,7 @@ describe('e2e_token_contract', () => {
.withWallet(wallets[1])
.methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce)
.send();
await txReplay.isMined();
const receiptReplay = await txReplay.getReceipt();
expect(receiptReplay.status).toBe(TxStatus.DROPPED);
await expect(txReplay.wait()).rejects.toThrowError('Transaction ');
});

describe('failure cases', () => {
@@ -427,9 +425,7 @@ describe('e2e_token_contract', () => {
.withWallet(wallets[1])
.methods.transfer(accounts[0].address, accounts[1].address, amount, nonce)
.send();
await txReplay.isMined();
const receiptReplay = await txReplay.getReceipt();
expect(receiptReplay.status).toBe(TxStatus.DROPPED);
await expect(txReplay.wait()).rejects.toThrowError('Transaction ');
});

describe('failure cases', () => {
@@ -577,9 +573,7 @@ describe('e2e_token_contract', () => {
.withWallet(wallets[1])
.methods.shield(accounts[0].address, amount, secretHash, nonce)
.send();
await txReplay.isMined();
const receiptReplay = await txReplay.getReceipt();
expect(receiptReplay.status).toBe(TxStatus.DROPPED);
await expect(txReplay.wait()).rejects.toThrowError('Transaction ');

// Redeem it
await addPendingShieldNoteToPXE(0, amount, secretHash, receipt.txHash);
@@ -693,9 +687,7 @@ describe('e2e_token_contract', () => {
.withWallet(wallets[1])
.methods.unshield(accounts[0].address, accounts[1].address, amount, nonce)
.send();
await txReplay.isMined();
const receiptReplay = await txReplay.getReceipt();
expect(receiptReplay.status).toBe(TxStatus.DROPPED);
await expect(txReplay.wait()).rejects.toThrowError('Transaction ');
});

describe('failure cases', () => {
@@ -798,9 +790,7 @@ describe('e2e_token_contract', () => {

// Check that the message hash is no longer valid. Need to try to send since nullifiers are handled by sequencer.
const txReplay = asset.withWallet(wallets[1]).methods.burn_public(accounts[0].address, amount, nonce).send();
await txReplay.isMined();
const receiptReplay = await txReplay.getReceipt();
expect(receiptReplay.status).toBe(TxStatus.DROPPED);
await expect(txReplay.wait()).rejects.toThrowError('Transaction ');
});

describe('failure cases', () => {
@@ -898,9 +888,7 @@ describe('e2e_token_contract', () => {

// Perform the transfer again, should fail
const txReplay = asset.withWallet(wallets[1]).methods.burn(accounts[0].address, amount, nonce).send();
await txReplay.isMined();
const receiptReplay = await txReplay.getReceipt();
expect(receiptReplay.status).toBe(TxStatus.DROPPED);
await expect(txReplay.wait()).rejects.toThrowError('Transaction ');
});

describe('failure cases', () => {

0 comments on commit 8a1f21a

Please sign in to comment.