Skip to content

Commit

Permalink
test: e2e two txs interacting with same contract
Browse files Browse the repository at this point in the history
  • Loading branch information
alexghr committed Sep 28, 2023
1 parent e235e4a commit 6992824
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions yarn-project/end-to-end/src/e2e_call_contract_same_block.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { ContractFunctionInteraction, Wallet } from '@aztec/aztec.js';
import { TokenContract } from '@aztec/noir-contracts/types';
import { TxStatus } from '@aztec/types';

import times from 'lodash.times';

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

describe('e2e_call_contract_same_block', () => {
let owner: Wallet;
let minter: Wallet;
let teardown: () => Promise<void>;

describe('multi-txs block', () => {
beforeAll(async () => {
({
teardown,
wallets: [owner, minter],
} = await setup(2));
}, 100_000);

afterAll(() => teardown());

it('can call public function from different tx in same block', async () => {
// Deploy a contract in the first transaction
// In the same block, call a public method on the contract
const deployer = TokenContract.deploy(owner, owner.getCompleteAddress());
await deployer.create();

const callInteraction = new ContractFunctionInteraction(
owner,
deployer.completeAddress!.address,
TokenContract.abi.functions.find(x => x.name === 'set_minter')!,
[minter.getCompleteAddress(), true],
);

const receipts = await Promise.all([
deployer.send().wait(),
callInteraction.send({ skipPublicSimulation: true }).wait(),
]);
expect(receipts.map(x => x.status)).toEqual(times(2, () => TxStatus.MINED));

expect(true).toBeDefined();
}, 60_000);
});
});

0 comments on commit 6992824

Please sign in to comment.