|
1 | 1 | import type { AztecAddress } from '@aztec/aztec.js/addresses'; |
| 2 | +import { BatchCall } from '@aztec/aztec.js/contracts'; |
2 | 3 | import { Fr } from '@aztec/aztec.js/fields'; |
3 | 4 | import { createLogger } from '@aztec/aztec.js/log'; |
4 | 5 | import type { AztecNode } from '@aztec/aztec.js/node'; |
@@ -408,16 +409,24 @@ export class FeesTest extends SingleNodeTestContext { |
408 | 409 | public async applyFundAliceWithBananas() { |
409 | 410 | this.logger.info('Applying fund Alice with bananas setup'); |
410 | 411 |
|
411 | | - // The private and public mints touch disjoint balances, so they are sent concurrently to share a |
412 | | - // slot instead of paying one slot each. |
413 | | - await Promise.all([ |
414 | | - this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress), |
415 | | - testSpan('tx:mint', () => |
416 | | - this.bananaCoin.methods.mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS).send({ |
417 | | - from: this.aliceAddress, |
418 | | - }), |
419 | | - ), |
420 | | - ]); |
| 412 | + // Both mints are alice sends on BananaCoin touching disjoint balances, so they ride a single |
| 413 | + // BatchCall tx (one proof, one slot) rather than two concurrent txs. The PXE serializes proving, |
| 414 | + // so two concurrent sends would still be proven back-to-back and land in consecutive slots. |
| 415 | + const { result: privateBalanceBefore } = await this.bananaCoin.methods |
| 416 | + .balance_of_private(this.aliceAddress) |
| 417 | + .simulate({ from: this.aliceAddress }); |
| 418 | + |
| 419 | + await testSpan('tx:mint', () => |
| 420 | + new BatchCall(this.wallet, [ |
| 421 | + this.bananaCoin.methods.mint_to_private(this.aliceAddress, this.ALICE_INITIAL_BANANAS), |
| 422 | + this.bananaCoin.methods.mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS), |
| 423 | + ]).send({ from: this.aliceAddress }), |
| 424 | + ); |
| 425 | + |
| 426 | + const { result: privateBalanceAfter } = await this.bananaCoin.methods |
| 427 | + .balance_of_private(this.aliceAddress) |
| 428 | + .simulate({ from: this.aliceAddress }); |
| 429 | + expect(privateBalanceAfter).toEqual(privateBalanceBefore + this.ALICE_INITIAL_BANANAS); |
421 | 430 | } |
422 | 431 |
|
423 | 432 | public async applyFundAliceWithPrivateBananas() { |
|
0 commit comments