Skip to content

Commit 054b399

Browse files
committed
test(e2e): instrument setup-layer deploys and mints with spans
1 parent 053e6a0 commit 054b399

4 files changed

Lines changed: 53 additions & 31 deletions

File tree

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -928,14 +928,16 @@ export async function expectMappingDelta<K, V extends number | bigint>(
928928
* surface as generic "Assertion failed:" and tests that match on the real message fail).
929929
*/
930930
export async function ensureAuthRegistryPublished(wallet: Wallet, from: AztecAddress) {
931-
const { instance, contractClass } = await getStandardAuthRegistry();
932-
if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
933-
await (await publishContractClass(wallet, AuthRegistryArtifact)).send({ from });
934-
}
935-
if (!(await wallet.getContractMetadata(instance.address)).isContractPublished) {
936-
await publishInstance(wallet, instance).send({ from });
937-
}
938-
await wallet.registerContract(instance, AuthRegistryArtifact);
931+
await testSpan('setup:auth-registry', async () => {
932+
const { instance, contractClass } = await getStandardAuthRegistry();
933+
if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
934+
await (await publishContractClass(wallet, AuthRegistryArtifact)).send({ from });
935+
}
936+
if (!(await wallet.getContractMetadata(instance.address)).isContractPublished) {
937+
await publishInstance(wallet, instance).send({ from });
938+
}
939+
await wallet.registerContract(instance, AuthRegistryArtifact);
940+
});
939941
}
940942

941943
/**

yarn-project/end-to-end/src/shared/cross_chain_test_harness.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { TokenBridgeContract } from '@aztec/noir-contracts.js/TokenBridge';
2424

2525
import { type Hex, getContract } from 'viem';
2626

27+
import { testSpan } from '../fixtures/timing.js';
2728
import { mintTokensToPrivate } from '../fixtures/token_utils.js';
2829
import { waitForL1ToL2MessageSeen } from './wait_for_l1_to_l2_message.js';
2930

@@ -76,14 +77,18 @@ export async function deployAndInitializeTokenAndBridgeContracts(
7677
});
7778

7879
// deploy l2 token
79-
const { contract: token } = await TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18).send({
80-
from: owner,
81-
});
80+
const { contract: token } = await testSpan('deploy:token', () =>
81+
TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18).send({
82+
from: owner,
83+
}),
84+
);
8285

8386
// deploy l2 token bridge and attach to the portal
84-
const { contract: bridge } = await TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress).send({
85-
from: owner,
86-
});
87+
const { contract: bridge } = await testSpan('deploy:bridge', () =>
88+
TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress).send({
89+
from: owner,
90+
}),
91+
);
8792

8893
if ((await token.methods.get_admin().simulate({ from: owner })).result !== owner.toBigInt()) {
8994
throw new Error(`Token admin is not ${owner}`);
@@ -241,11 +246,13 @@ export class CrossChainTestHarness {
241246

242247
async mintTokensPublicOnL2(amount: bigint) {
243248
this.logger.info('Minting tokens on L2 publicly');
244-
await this.l2Token.methods.mint_to_public(this.ownerAddress, amount).send({ from: this.ownerAddress });
249+
await testSpan('tx:mint', () =>
250+
this.l2Token.methods.mint_to_public(this.ownerAddress, amount).send({ from: this.ownerAddress }),
251+
);
245252
}
246253

247254
async mintTokensPrivateOnL2(amount: bigint) {
248-
await mintTokensToPrivate(this.l2Token, this.ownerAddress, this.ownerAddress, amount);
255+
await testSpan('tx:mint', () => mintTokensToPrivate(this.l2Token, this.ownerAddress, this.ownerAddress, amount));
249256
}
250257

251258
async sendL2PublicTransfer(transferAmount: bigint, receiverAddress: AztecAddress) {

yarn-project/end-to-end/src/shared/gas_portal_test_harness.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
1010
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
1111
import type { AztecNodeAdmin, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
1212

13+
import { testSpan } from '../fixtures/timing.js';
1314
import { waitForL1ToL2MessageSeen } from './wait_for_l1_to_l2_message.js';
1415

1516
/** Aztec node that may expose the debug mining API in local e2e setups. */
@@ -159,11 +160,13 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness {
159160
}
160161

161162
async bridgeFromL1ToL2(owner: AztecAddress, claimer: AztecAddress) {
162-
// Prepare the tokens on the L1 side
163-
const claim = await this.prepareTokensOnL1(owner);
163+
await testSpan('setup:bridge', async () => {
164+
// Prepare the tokens on the L1 side
165+
const claim = await this.prepareTokensOnL1(owner);
164166

165-
// Consume L1 -> L2 message and claim tokens privately on L2
166-
await this.consumeMessageOnAztecAndClaimPrivately(owner, claimer, claim);
167+
// Consume L1 -> L2 message and claim tokens privately on L2
168+
await this.consumeMessageOnAztecAndClaimPrivately(owner, claimer, claim);
169+
});
167170
}
168171

169172
private async advanceL2Block() {

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

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { getContract } from 'viem';
2424

2525
import { L1_DIRECT_WRITE_ACCOUNT_INDEX, MNEMONIC, getPaddedMaxFeesPerGas } from '../../fixtures/fixtures.js';
2626
import { type SetupOptions, ensureAuthRegistryPublished, setup } from '../../fixtures/setup.js';
27+
import { testSpan } from '../../fixtures/timing.js';
2728
import { mintTokensToPrivate } from '../../fixtures/token_utils.js';
2829
import { type BalancesFn, getBalancesFn, setupSponsoredFPC } from '../../fixtures/utils.js';
2930
import {
@@ -158,7 +159,9 @@ export class FeesTest extends SingleNodeTestContext {
158159
async mintAndBridgeFeeJuice(minter: AztecAddress, recipient: AztecAddress) {
159160
const claim = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(recipient);
160161
const { claimSecret: secret, messageLeafIndex: index } = claim;
161-
await this.feeJuiceContract.methods.claim(recipient, claim.claimAmount, secret, index).send({ from: minter });
162+
await testSpan('setup:bridge', () =>
163+
this.feeJuiceContract.methods.claim(recipient, claim.claimAmount, secret, index).send({ from: minter }),
164+
);
162165
}
163166

164167
/** Alice mints bananaCoin tokens privately to the target address and redeems them. */
@@ -167,7 +170,7 @@ export class FeesTest extends SingleNodeTestContext {
167170
.balance_of_private(address)
168171
.simulate({ from: address });
169172

170-
await mintTokensToPrivate(this.bananaCoin, this.aliceAddress, address, amount);
173+
await testSpan('tx:mint', () => mintTokensToPrivate(this.bananaCoin, this.aliceAddress, address, amount));
171174

172175
const { result: balanceAfter } = await this.bananaCoin.methods
173176
.balance_of_private(address)
@@ -236,9 +239,11 @@ export class FeesTest extends SingleNodeTestContext {
236239
async applyDeployBananaToken() {
237240
this.logger.info('Applying deploy banana token setup');
238241

239-
const { contract: bananaCoin } = await BananaCoin.deploy(this.wallet, this.aliceAddress, 'BC', 'BC', 18n).send({
240-
from: this.aliceAddress,
241-
});
242+
const { contract: bananaCoin } = await testSpan('deploy:token', () =>
243+
BananaCoin.deploy(this.wallet, this.aliceAddress, 'BC', 'BC', 18n).send({
244+
from: this.aliceAddress,
245+
}),
246+
);
242247
this.logger.info(`BananaCoin deployed at ${bananaCoin.address}`);
243248

244249
this.bananaCoin = bananaCoin;
@@ -257,12 +262,15 @@ export class FeesTest extends SingleNodeTestContext {
257262
expect((await this.wallet.getContractMetadata(feeJuiceContract.address)).isContractPublished).toBe(true);
258263

259264
const bananaCoin = this.bananaCoin;
260-
const { contract: bananaFPC } = await FPCContract.deploy(this.wallet, bananaCoin.address, this.fpcAdmin).send({
261-
from: this.aliceAddress,
262-
});
265+
const { contract: bananaFPC } = await testSpan('deploy:fpc', () =>
266+
FPCContract.deploy(this.wallet, bananaCoin.address, this.fpcAdmin).send({
267+
from: this.aliceAddress,
268+
}),
269+
);
263270

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

273+
// bridgeFromL1ToL2 carries its own setup:bridge span.
266274
await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(bananaFPC.address, this.aliceAddress);
267275

268276
this.bananaFPC = bananaFPC;
@@ -345,9 +353,11 @@ export class FeesTest extends SingleNodeTestContext {
345353
this.logger.info('Applying fund Alice with bananas setup');
346354

347355
await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
348-
await this.bananaCoin.methods
349-
.mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS)
350-
.send({ from: this.aliceAddress });
356+
await testSpan('tx:mint', () =>
357+
this.bananaCoin.methods.mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS).send({
358+
from: this.aliceAddress,
359+
}),
360+
);
351361
}
352362

353363
public async applyFundAliceWithPrivateBananas() {

0 commit comments

Comments
 (0)