Skip to content

Commit 7b9cd12

Browse files
committed
perf(e2e): batch same-sender setup txs into single txs
1 parent 287ed68 commit 7b9cd12

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

yarn-project/end-to-end/src/single-node/fees/fees_test.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { AztecAddress } from '@aztec/aztec.js/addresses';
2+
import { BatchCall } from '@aztec/aztec.js/contracts';
23
import { Fr } from '@aztec/aztec.js/fields';
34
import { createLogger } from '@aztec/aztec.js/log';
45
import type { AztecNode } from '@aztec/aztec.js/node';
@@ -401,16 +402,24 @@ export class FeesTest extends SingleNodeTestContext {
401402
public async applyFundAliceWithBananas() {
402403
this.logger.info('Applying fund Alice with bananas setup');
403404

404-
// The private and public mints touch disjoint balances, so they are sent concurrently to share a
405-
// slot instead of paying one slot each.
406-
await Promise.all([
407-
this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress),
408-
testSpan('tx:mint', () =>
409-
this.bananaCoin.methods.mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS).send({
410-
from: this.aliceAddress,
411-
}),
412-
),
413-
]);
405+
// Both mints are alice sends on BananaCoin touching disjoint balances, so they ride a single
406+
// BatchCall tx (one proof, one slot) rather than two concurrent txs. The PXE serializes proving,
407+
// so two concurrent sends would still be proven back-to-back and land in consecutive slots.
408+
const { result: privateBalanceBefore } = await this.bananaCoin.methods
409+
.balance_of_private(this.aliceAddress)
410+
.simulate({ from: this.aliceAddress });
411+
412+
await testSpan('tx:mint', () =>
413+
new BatchCall(this.wallet, [
414+
this.bananaCoin.methods.mint_to_private(this.aliceAddress, this.ALICE_INITIAL_BANANAS),
415+
this.bananaCoin.methods.mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS),
416+
]).send({ from: this.aliceAddress }),
417+
);
418+
419+
const { result: privateBalanceAfter } = await this.bananaCoin.methods
420+
.balance_of_private(this.aliceAddress)
421+
.simulate({ from: this.aliceAddress });
422+
expect(privateBalanceAfter).toEqual(privateBalanceBefore + this.ALICE_INITIAL_BANANAS);
414423
}
415424

416425
public async applyFundAliceWithPrivateBananas() {

0 commit comments

Comments
 (0)