@aztec/end-to-end 0.0.1-commit.f5d02921e → 0.0.1-commit.f650c0a5c

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +27 -0
  2. package/dest/bench/client_flows/client_flows_benchmark.js +1 -1
  3. package/dest/e2e_epochs/epochs_test.js +3 -3
  4. package/dest/e2e_fees/fees_test.js +1 -1
  5. package/dest/e2e_p2p/inactivity_slash_test.js +2 -2
  6. package/dest/e2e_p2p/p2p_network.d.ts +5 -7
  7. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  8. package/dest/e2e_p2p/p2p_network.js +8 -12
  9. package/dest/e2e_p2p/reqresp/utils.js +1 -1
  10. package/dest/e2e_p2p/shared.d.ts +5 -7
  11. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  12. package/dest/e2e_p2p/shared.js +16 -42
  13. package/dest/fixtures/authwit_proxy.d.ts +1 -1
  14. package/dest/fixtures/authwit_proxy.d.ts.map +1 -1
  15. package/dest/fixtures/authwit_proxy.js +4 -0
  16. package/dest/fixtures/e2e_prover_test.d.ts +1 -1
  17. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  18. package/dest/fixtures/e2e_prover_test.js +2 -2
  19. package/dest/fixtures/setup.d.ts +5 -4
  20. package/dest/fixtures/setup.d.ts.map +1 -1
  21. package/dest/fixtures/setup.js +7 -6
  22. package/dest/fixtures/setup_p2p_test.d.ts +6 -6
  23. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  24. package/dest/fixtures/setup_p2p_test.js +8 -8
  25. package/dest/legacy-jest-resolver.d.cts +3 -0
  26. package/dest/legacy-jest-resolver.d.cts.map +1 -0
  27. package/dest/spartan/setup_test_wallets.d.ts +1 -1
  28. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  29. package/dest/spartan/setup_test_wallets.js +7 -39
  30. package/dest/test-wallet/test_wallet.d.ts +6 -7
  31. package/dest/test-wallet/test_wallet.d.ts.map +1 -1
  32. package/dest/test-wallet/test_wallet.js +36 -27
  33. package/package.json +40 -39
  34. package/src/bench/client_flows/client_flows_benchmark.ts +1 -1
  35. package/src/e2e_epochs/epochs_test.ts +3 -3
  36. package/src/e2e_fees/fees_test.ts +1 -1
  37. package/src/e2e_p2p/inactivity_slash_test.ts +2 -2
  38. package/src/e2e_p2p/p2p_network.ts +16 -23
  39. package/src/e2e_p2p/reqresp/utils.ts +1 -1
  40. package/src/e2e_p2p/shared.ts +16 -57
  41. package/src/fixtures/authwit_proxy.ts +4 -0
  42. package/src/fixtures/e2e_prover_test.ts +5 -2
  43. package/src/fixtures/setup.ts +12 -13
  44. package/src/fixtures/setup_p2p_test.ts +9 -9
  45. package/src/legacy-jest-resolver.cjs +135 -0
  46. package/src/spartan/setup_test_wallets.ts +5 -31
  47. package/src/test-wallet/test_wallet.ts +53 -28
@@ -25,13 +25,14 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
25
25
  import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
26
26
  import { deriveSigningKey } from '@aztec/stdlib/keys';
27
27
  import type { NoteDao } from '@aztec/stdlib/note';
28
- import type {
29
- BlockHeader,
28
+ import {
29
+ type BlockHeader,
30
+ type ContractOverrides,
30
31
  SimulationOverrides,
31
- TxExecutionRequest,
32
- TxHash,
33
- TxReceipt,
34
- TxSimulationResult,
32
+ type TxExecutionRequest,
33
+ type TxHash,
34
+ type TxReceipt,
35
+ type TxSimulationResult,
35
36
  } from '@aztec/stdlib/tx';
36
37
  import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
37
38
  import { BaseWallet, type SimulateViaEntrypointOptions } from '@aztec/wallet-sdk/base-wallet';
@@ -110,23 +111,39 @@ export class TestWallet extends BaseWallet {
110
111
  return this.createAccount(accountData);
111
112
  }
112
113
 
113
- async getFakeAccountDataFor(address: AztecAddress) {
114
- const originalAccount = await this.getAccountFromAddress(address);
115
- const originalAddress = originalAccount.getCompleteAddress();
116
- const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
117
- if (!contractInstance) {
118
- throw new Error(`No contract instance found for address: ${originalAddress.address}`);
114
+ /**
115
+ * Builds contract overrides for all provided addresses by replacing their account contracts with stub implementations.
116
+ */
117
+ protected async buildAccountOverrides(addresses: AztecAddress[]): Promise<ContractOverrides> {
118
+ const accounts = await this.getAccounts();
119
+ const contracts: ContractOverrides = {};
120
+
121
+ const filtered = accounts.filter(acc => addresses.some(addr => addr.equals(acc.item)));
122
+
123
+ for (const account of filtered) {
124
+ const address = account.item;
125
+ const originalAccount = await this.getAccountFromAddress(address);
126
+ const completeAddress = originalAccount.getCompleteAddress();
127
+ const contractInstance = await this.pxe.getContractInstance(completeAddress.address);
128
+ if (!contractInstance) {
129
+ throw new Error(
130
+ `No contract instance found for address: ${completeAddress.address} during account override building. This is a bug!`,
131
+ );
132
+ }
133
+
134
+ const stubInstance = await getContractInstanceFromInstantiationParams(StubAccountContractArtifact, {
135
+ salt: Fr.random(),
136
+ });
137
+
138
+ contracts[address.toString()] = {
139
+ instance: stubInstance,
140
+ artifact: StubAccountContractArtifact,
141
+ };
119
142
  }
120
- const stubAccount = createStubAccount(originalAddress);
121
- const instance = await getContractInstanceFromInstantiationParams(StubAccountContractArtifact, {
122
- salt: Fr.random(),
123
- });
124
- return {
125
- account: stubAccount,
126
- instance,
127
- artifact: StubAccountContractArtifact,
128
- };
143
+
144
+ return contracts;
129
145
  }
146
+
130
147
  protected accounts: Map<string, Account> = new Map();
131
148
 
132
149
  /**
@@ -220,6 +237,8 @@ export class TestWallet extends BaseWallet {
220
237
  ): Promise<TxSimulationResult> {
221
238
  const { from, feeOptions, scopes, skipTxValidation, skipFeeEnforcement } = opts;
222
239
  const skipKernels = this.simulationMode !== 'full';
240
+ const useOverride = this.simulationMode === 'kernelless-override';
241
+
223
242
  const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
224
243
  const finalExecutionPayload = feeExecutionPayload
225
244
  ? mergeExecutionPayloads([feeExecutionPayload, executionPayload])
@@ -228,18 +247,20 @@ export class TestWallet extends BaseWallet {
228
247
 
229
248
  let overrides: SimulationOverrides | undefined;
230
249
  let txRequest: TxExecutionRequest;
250
+ if (useOverride) {
251
+ const accountOverrides = await this.buildAccountOverrides(this.scopesFrom(from, opts.additionalScopes));
252
+ overrides = new SimulationOverrides(accountOverrides);
253
+ }
254
+
231
255
  if (from === NO_FROM) {
232
256
  const entrypoint = new DefaultEntrypoint();
233
257
  txRequest = await entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
234
258
  } else {
235
- const useOverride = this.simulationMode === 'kernelless-override';
236
259
  let fromAccount: Account;
237
260
  if (useOverride) {
238
- const { account, instance, artifact } = await this.getFakeAccountDataFor(from);
239
- fromAccount = account;
240
- overrides = {
241
- contracts: { [from.toString()]: { instance, artifact } },
242
- };
261
+ const originalAccount = await this.getAccountFromAddress(from);
262
+ const completeAddress = originalAccount.getCompleteAddress();
263
+ fromAccount = createStubAccount(completeAddress);
243
264
  } else {
244
265
  fromAccount = await this.getAccountFromAddress(from);
245
266
  }
@@ -268,7 +289,11 @@ export class TestWallet extends BaseWallet {
268
289
  }
269
290
 
270
291
  async proveTx(exec: ExecutionPayload, opts: Omit<SendOptions, 'wait'>): Promise<ProvenTx> {
271
- const fee = await this.completeFeeOptions(opts.from, exec.feePayer, opts.fee?.gasSettings);
292
+ const fee = await this.completeFeeOptions({
293
+ from: opts.from,
294
+ feePayer: exec.feePayer,
295
+ gasSettings: opts.fee?.gasSettings,
296
+ });
272
297
  const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(exec, opts.from, fee);
273
298
  const txProvingResult = await this.pxe.proveTx(txRequest, this.scopesFrom(opts.from, opts.additionalScopes));
274
299
  return new ProvenTx(