|
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'; |
@@ -401,16 +402,24 @@ export class FeesTest extends SingleNodeTestContext { |
401 | 402 | public async applyFundAliceWithBananas() { |
402 | 403 | this.logger.info('Applying fund Alice with bananas setup'); |
403 | 404 |
|
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); |
414 | 423 | } |
415 | 424 |
|
416 | 425 | public async applyFundAliceWithPrivateBananas() { |
|
0 commit comments