-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: e2e two txs interacting with same contract
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
yarn-project/end-to-end/src/e2e_call_contract_same_block.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |