Skip to content

Commit 693702e

Browse files
committed
test: fix tests
1 parent f809bef commit 693702e

File tree

15 files changed

+65
-106
lines changed

15 files changed

+65
-106
lines changed

yarn-project/constants/src/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// Typescript-land-only constants
2-
export const FEE_FUNDING_FOR_TESTER_ACCOUNT = BigInt(1_000e18);
32
export const SPONSORED_FPC_SALT = BigInt(0);
43

54
// Autogenerated constants loaded from noir-land

yarn-project/end-to-end/src/bench/client_flows/amm.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { AccountWallet, AztecAddress, Fr, type SimulateMethodOptions } from '@aztec/aztec.js';
2-
import { FEE_FUNDING_FOR_TESTER_ACCOUNT } from '@aztec/constants';
32
import type { AMMContract } from '@aztec/noir-contracts.js/AMM';
43
import type { FPCContract } from '@aztec/noir-contracts.js/FPC';
54
import type { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
@@ -66,7 +65,7 @@ describe('AMM benchmark', () => {
6665
beforeAll(async () => {
6766
benchysWallet = await t.createAndFundBenchmarkingWallet(accountType);
6867
// Fund benchy with bananas, so they can pay for the amms using the private FPC
69-
await t.mintPrivateBananas(FEE_FUNDING_FOR_TESTER_ACCOUNT, benchysWallet.getAddress());
68+
await t.mintPrivateBananas(1000n * 10n ** 18n, benchysWallet.getAddress());
7069
// Register admin as sender in benchy's wallet, since we need it to discover the minted bananas
7170
await benchysWallet.registerSender(adminWallet.getAddress());
7271
// Register both FPC and BananCoin on the user's Wallet so we can simulate and prove

yarn-project/end-to-end/src/bench/client_flows/bridging.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { AccountWallet, type SimulateMethodOptions } from '@aztec/aztec.js';
2-
import { FEE_FUNDING_FOR_TESTER_ACCOUNT } from '@aztec/constants';
32
import type { FPCContract } from '@aztec/noir-contracts.js/FPC';
43
import type { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
54
import { TokenContract } from '@aztec/noir-contracts.js/Token';
@@ -54,7 +53,7 @@ describe('Bridging benchmark', () => {
5453
// the brigde has an owner, which is the only one that can claim
5554
crossChainTestHarness = await t.createCrossChainTestHarness(benchysWallet);
5655
// Fund benchy with bananas, so they can pay for the bridging using the private FPC
57-
await t.mintPrivateBananas(FEE_FUNDING_FOR_TESTER_ACCOUNT, benchysWallet.getAddress());
56+
await t.mintPrivateBananas(1000n * 10n ** 18n, benchysWallet.getAddress());
5857
// Register admin as sender in benchy's wallet, since we need it to discover the minted bananas
5958
await benchysWallet.registerSender(adminWallet.getAddress());
6059
// Register both FPC and BananCoin on the user's PXE so we can simulate and prove

yarn-project/end-to-end/src/bench/client_flows/client_flows_benchmark.ts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
createLogger,
1717
} from '@aztec/aztec.js';
1818
import { CheatCodes } from '@aztec/aztec/testing';
19-
import { FEE_FUNDING_FOR_TESTER_ACCOUNT } from '@aztec/constants';
2019
import { type DeployL1ContractsArgs, RollupContract, createExtendedL1Client, deployL1Contract } from '@aztec/ethereum';
2120
import { ChainMonitor } from '@aztec/ethereum/test';
2221
import { randomBytes } from '@aztec/foundation/crypto';
@@ -155,10 +154,13 @@ export class ClientFlowsBenchmark {
155154
await this.snapshotManager.teardown();
156155
}
157156

158-
async mintAndBridgeFeeJuice(address: AztecAddress, amount: bigint) {
159-
const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(amount, address);
157+
async mintAndBridgeFeeJuice(address: AztecAddress) {
158+
const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(address);
160159
const { claimSecret: secret, messageLeafIndex: index } = claim;
161-
await this.feeJuiceContract.methods.claim(address, amount, secret, index).send({ from: this.adminAddress }).wait();
160+
await this.feeJuiceContract.methods
161+
.claim(address, claim.claimAmount, secret, index)
162+
.send({ from: this.adminAddress })
163+
.wait();
162164
}
163165

164166
/** Admin mints bananaCoin tokens privately to the target address and redeems them. */
@@ -304,11 +306,7 @@ export class ClientFlowsBenchmark {
304306

305307
this.logger.info(`BananaPay deployed at ${bananaFPC.address}`);
306308

307-
await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(
308-
FEE_FUNDING_FOR_TESTER_ACCOUNT,
309-
bananaFPC.address,
310-
this.adminAddress,
311-
);
309+
await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(bananaFPC.address, this.adminAddress);
312310

313311
return { bananaFPCAddress: bananaFPC.address };
314312
},
@@ -361,10 +359,7 @@ export class ClientFlowsBenchmark {
361359
const benchysAccountManager = await this.createBenchmarkingAccountManager(this.pxe, accountType);
362360
const benchysWallet = await benchysAccountManager.getWallet();
363361
const benchysAddress = benchysAccountManager.getAddress();
364-
const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(
365-
FEE_FUNDING_FOR_TESTER_ACCOUNT,
366-
benchysAddress,
367-
);
362+
const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(benchysAddress);
368363
const paymentMethod = new FeeJuicePaymentMethodWithClaim(benchysWallet, claim);
369364
await benchysAccountManager.deploy({ fee: { paymentMethod } }).wait();
370365
// Register benchy on the user's PXE, where we're going to be interacting from
@@ -409,10 +404,7 @@ export class ClientFlowsBenchmark {
409404
}
410405

411406
public async getBridgedFeeJuicePaymentMethodForWallet(wallet: Wallet) {
412-
const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(
413-
FEE_FUNDING_FOR_TESTER_ACCOUNT,
414-
wallet.getAddress(),
415-
);
407+
const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(wallet.getAddress());
416408
return new FeeJuicePaymentMethodWithClaim(wallet, claim);
417409
}
418410

yarn-project/end-to-end/src/bench/client_flows/transfers.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { AccountWallet, AztecAddress, type AztecNode, Fr, type SimulateMethodOptions } from '@aztec/aztec.js';
2-
import { FEE_FUNDING_FOR_TESTER_ACCOUNT } from '@aztec/constants';
32
import type { FPCContract } from '@aztec/noir-contracts.js/FPC';
43
import type { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
54
import { TokenContract } from '@aztec/noir-contracts.js/Token';
@@ -68,7 +67,7 @@ describe('Transfer benchmark', () => {
6867
beforeAll(async () => {
6968
benchysWallet = await t.createAndFundBenchmarkingWallet(accountType);
7069
// Fund benchy with bananas, so they can pay for the transfers using the private FPC
71-
await t.mintPrivateBananas(FEE_FUNDING_FOR_TESTER_ACCOUNT, benchysWallet.getAddress());
70+
await t.mintPrivateBananas(1000n * 10n ** 18n, benchysWallet.getAddress());
7271
// Register admin as sender in benchy's wallet, since we need it to discover the minted bananas
7372
await benchysWallet.registerSender(adminWallet.getAddress());
7473
// Register both FPC and BananCoin on the user's Wallet so we can simulate and prove

yarn-project/end-to-end/src/e2e_fees/account_init.test.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
type Wallet,
1414
deriveKeys,
1515
} from '@aztec/aztec.js';
16-
import { FEE_FUNDING_FOR_TESTER_ACCOUNT } from '@aztec/constants';
1716
import { Fq } from '@aztec/foundation/fields';
1817
import type { FPCContract } from '@aztec/noir-contracts.js/FPC';
1918
import { SchnorrAccountContract } from '@aztec/noir-contracts.js/SchnorrAccount';
@@ -84,9 +83,10 @@ describe('e2e_fees account_init', () => {
8483

8584
describe('account pays its own fee', () => {
8685
it('pays natively in the Fee Juice after Alice bridges funds', async () => {
87-
await t.mintAndBridgeFeeJuice(aliceAddress, bobsAddress, FEE_FUNDING_FOR_TESTER_ACCOUNT);
86+
const mintAmount = await t.feeJuiceBridgeTestHarness.l1TokenManager.getMintAmount();
87+
await t.mintAndBridgeFeeJuice(aliceAddress, bobsAddress);
8888
const [bobsInitialGas] = await t.getGasBalanceFn(bobsAddress);
89-
expect(bobsInitialGas).toEqual(FEE_FUNDING_FOR_TESTER_ACCOUNT);
89+
expect(bobsInitialGas).toEqual(mintAmount);
9090

9191
// docs:start:pay_fee_juice_deploy
9292
const paymentMethod = new FeeJuicePaymentMethod(bobsAddress);
@@ -98,18 +98,16 @@ describe('e2e_fees account_init', () => {
9898
});
9999

100100
it('pays natively in the Fee Juice by bridging funds themselves', async () => {
101-
const claim = await t.feeJuiceBridgeTestHarness.prepareTokensOnL1(FEE_FUNDING_FOR_TESTER_ACCOUNT, bobsAddress);
101+
const claim = await t.feeJuiceBridgeTestHarness.prepareTokensOnL1(bobsAddress);
102102
const paymentMethod = new FeeJuicePaymentMethodWithClaim(bobsWallet, claim);
103103
const tx = await bobsAccountManager.deploy({ fee: { paymentMethod } }).wait();
104104
expect(tx.transactionFee!).toBeGreaterThan(0n);
105-
await expect(t.getGasBalanceFn(bobsAddress)).resolves.toEqual([
106-
FEE_FUNDING_FOR_TESTER_ACCOUNT - tx.transactionFee!,
107-
]);
105+
await expect(t.getGasBalanceFn(bobsAddress)).resolves.toEqual([claim.claimAmount - tx.transactionFee!]);
108106
});
109107

110108
it('pays privately through an FPC', async () => {
111109
// Alice mints bananas to Bob
112-
const mintedBananas = FEE_FUNDING_FOR_TESTER_ACCOUNT;
110+
const mintedBananas = await t.feeJuiceBridgeTestHarness.l1TokenManager.getMintAmount();
113111
await t.mintPrivateBananas(mintedBananas, bobsAddress);
114112

115113
// Bob deploys his account through the private FPC
@@ -131,7 +129,7 @@ describe('e2e_fees account_init', () => {
131129
});
132130

133131
it('pays publicly through an FPC', async () => {
134-
const mintedBananas = FEE_FUNDING_FOR_TESTER_ACCOUNT;
132+
const mintedBananas = await t.feeJuiceBridgeTestHarness.l1TokenManager.getMintAmount();
135133
await bananaCoin.methods.mint_to_public(bobsAddress, mintedBananas).send({ from: aliceAddress }).wait();
136134

137135
const paymentMethod = new PublicFeePaymentMethod(bananaFPC.address, bobsWallet);
@@ -164,7 +162,7 @@ describe('e2e_fees account_init', () => {
164162
const bobsInstance = bobsAccountManager.getInstance();
165163

166164
// Alice mints bananas to Bob and deploys bob's account, paying the fees from her balance.
167-
const mintedBananas = FEE_FUNDING_FOR_TESTER_ACCOUNT;
165+
const mintedBananas = await t.feeJuiceBridgeTestHarness.l1TokenManager.getMintAmount();
168166
await t.mintPrivateBananas(mintedBananas, bobsAddress);
169167

170168
const [aliceBalanceBefore] = await t.getGasBalanceFn(aliceAddress);

yarn-project/end-to-end/src/e2e_fees/bridging_race.notest.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
22
import { Fr, type Logger, type PXE, sleep } from '@aztec/aztec.js';
3-
import { FEE_FUNDING_FOR_TESTER_ACCOUNT } from '@aztec/constants';
43
import { Fq } from '@aztec/foundation/fields';
54
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
65

@@ -64,11 +63,13 @@ describe('e2e_fees bridging_race', () => {
6463
// Waiting for the archiver to sync the message _before_ waiting for the mandatory 2 L2 blocks to pass fixed it
6564
// This was added everywhere we wait for two blocks, which is spread across three different places in the codebase
6665
// Yes, we need to REFACTOR it at some point
67-
const amount = FEE_FUNDING_FOR_TESTER_ACCOUNT;
68-
const claim = await t.feeJuiceBridgeTestHarness.prepareTokensOnL1(amount, bobsAddress);
66+
const claim = await t.feeJuiceBridgeTestHarness.prepareTokensOnL1(bobsAddress);
6967
const { claimSecret: secret, messageLeafIndex: index } = claim;
70-
await t.feeJuiceContract.methods.claim(bobsAddress, amount, secret, index).send({ from: bobsAddress }).wait();
68+
await t.feeJuiceContract.methods
69+
.claim(bobsAddress, claim.claimAmount, secret, index)
70+
.send({ from: bobsAddress })
71+
.wait();
7172
const [balance] = await t.getGasBalanceFn(bobsAddress);
72-
expect(balance).toEqual(amount);
73+
expect(balance).toEqual(claim.claimAmount);
7374
});
7475
});

yarn-project/end-to-end/src/e2e_fees/fee_juice_payments.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
FeeJuicePaymentMethodWithClaim,
99
type PXE,
1010
} from '@aztec/aztec.js';
11-
import { FEE_FUNDING_FOR_TESTER_ACCOUNT } from '@aztec/constants';
1211
import type { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
1312
import type { TokenContract as BananaCoin } from '@aztec/noir-contracts.js/Token';
1413
import type { GasSettings } from '@aztec/stdlib/gas';
@@ -73,7 +72,7 @@ describe('e2e_fees Fee Juice payments', () => {
7372
});
7473

7574
it('claims bridged funds and pays with them on the same tx', async () => {
76-
const claim = await t.feeJuiceBridgeTestHarness.prepareTokensOnL1(FEE_FUNDING_FOR_TESTER_ACCOUNT, bobAddress);
75+
const claim = await t.feeJuiceBridgeTestHarness.prepareTokensOnL1(bobAddress);
7776
// docs:start:claim_and_pay
7877
const paymentMethod = new FeeJuicePaymentMethodWithClaim(bobWallet, claim);
7978
const receipt = await feeJuiceContract
@@ -85,8 +84,8 @@ describe('e2e_fees Fee Juice payments', () => {
8584
const endBalance = await feeJuiceContract.methods.balance_of_public(bobAddress).simulate({ from: bobAddress });
8685

8786
expect(endBalance).toBeGreaterThan(0n);
88-
expect(endBalance).toBeLessThan(FEE_FUNDING_FOR_TESTER_ACCOUNT);
89-
expect(endBalance).toEqual(FEE_FUNDING_FOR_TESTER_ACCOUNT - receipt.transactionFee!);
87+
expect(endBalance).toBeLessThan(claim.claimAmount);
88+
expect(endBalance).toEqual(claim.claimAmount - receipt.transactionFee!);
9089
});
9190
});
9291

yarn-project/end-to-end/src/e2e_fees/fees_test.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
sleep,
1010
} from '@aztec/aztec.js';
1111
import { CheatCodes } from '@aztec/aztec/testing';
12-
import { FEE_FUNDING_FOR_TESTER_ACCOUNT } from '@aztec/constants';
1312
import { type DeployL1ContractsArgs, RollupContract, createExtendedL1Client } from '@aztec/ethereum';
1413
import { ChainMonitor } from '@aztec/ethereum/test';
1514
import { EthAddress } from '@aztec/foundation/eth-address';
@@ -158,10 +157,13 @@ export class FeesTest {
158157
return { sequencerBlockRewards, proverBlockRewards };
159158
}
160159

161-
async mintAndBridgeFeeJuice(minter: AztecAddress, recipient: AztecAddress, amount: bigint) {
162-
const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(amount, recipient);
160+
async mintAndBridgeFeeJuice(minter: AztecAddress, recipient: AztecAddress) {
161+
const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(recipient);
163162
const { claimSecret: secret, messageLeafIndex: index } = claim;
164-
await this.feeJuiceContract.methods.claim(recipient, amount, secret, index).send({ from: minter }).wait();
163+
await this.feeJuiceContract.methods
164+
.claim(recipient, claim.claimAmount, secret, index)
165+
.send({ from: minter })
166+
.wait();
165167
}
166168

167169
/** Alice mints bananaCoin tokens privately to the target address and redeems them. */
@@ -287,11 +289,7 @@ export class FeesTest {
287289

288290
this.logger.info(`BananaPay deployed at ${bananaFPC.address}`);
289291

290-
await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(
291-
FEE_FUNDING_FOR_TESTER_ACCOUNT,
292-
bananaFPC.address,
293-
this.aliceAddress,
294-
);
292+
await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(bananaFPC.address, this.aliceAddress);
295293

296294
return {
297295
bananaFPCAddress: bananaFPC.address,

yarn-project/end-to-end/src/fixtures/e2e_prover_test.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import type { BlobSinkServer } from '@aztec/blob-sink/server';
2626
import type { DeployL1ContractsReturnType } from '@aztec/ethereum';
2727
import { Buffer32 } from '@aztec/foundation/buffer';
2828
import { SecretValue } from '@aztec/foundation/config';
29-
import { TestERC20Abi } from '@aztec/l1-artifacts';
29+
import { FeeAssetHandlerAbi } from '@aztec/l1-artifacts';
3030
import { TokenContract } from '@aztec/noir-contracts.js/Token';
3131
import { type ProverNode, type ProverNodeConfig, createProverNode } from '@aztec/prover-node';
3232
import type { PXEService } from '@aztec/pxe/server';
@@ -289,7 +289,7 @@ export class FullProverTest {
289289
this.proverAddress = EthAddress.fromString(proverNodeSenderAddress);
290290

291291
this.logger.verbose(`Funding prover node at ${proverNodeSenderAddress}`);
292-
await this.mintL1ERC20(proverNodeSenderAddress, 100_000_000n);
292+
await this.mintFeeJuice(proverNodeSenderAddress);
293293

294294
this.logger.verbose('Starting prover node');
295295
const proverConfig: ProverNodeConfig = {
@@ -328,11 +328,12 @@ export class FullProverTest {
328328
return this;
329329
}
330330

331-
private async mintL1ERC20(recipient: Hex, amount: bigint) {
332-
const erc20Address = this.context.deployL1ContractsValues.l1ContractAddresses.feeJuiceAddress;
331+
private async mintFeeJuice(recipient: Hex) {
332+
const handlerAddress = this.context.deployL1ContractsValues.l1ContractAddresses.feeAssetHandlerAddress!;
333+
this.logger.verbose(`Minting fee juice to ${recipient} using handler at ${handlerAddress}`);
333334
const client = this.context.deployL1ContractsValues.l1Client;
334-
const erc20 = getContract({ abi: TestERC20Abi, address: erc20Address.toString(), client });
335-
const hash = await erc20.write.mint([recipient, amount]);
335+
const handler = getContract({ abi: FeeAssetHandlerAbi, address: handlerAddress.toString(), client });
336+
const hash = await handler.write.mint([recipient]);
336337
await this.context.deployL1ContractsValues.l1Client.waitForTransactionReceipt({ hash });
337338
}
338339

0 commit comments

Comments
 (0)