@aztec/end-to-end 0.0.1-commit.ff7989d6c → 0.0.1-commit.fff30aa

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 (116) hide show
  1. package/README.md +27 -0
  2. package/dest/bench/client_flows/client_flows_benchmark.d.ts +1 -1
  3. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  4. package/dest/bench/client_flows/client_flows_benchmark.js +18 -11
  5. package/dest/bench/utils.d.ts +1 -1
  6. package/dest/bench/utils.d.ts.map +1 -1
  7. package/dest/bench/utils.js +6 -3
  8. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +3 -2
  9. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  10. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +15 -15
  11. package/dest/e2e_epochs/epochs_test.d.ts +3 -1
  12. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  13. package/dest/e2e_epochs/epochs_test.js +5 -2
  14. package/dest/e2e_fees/fees_test.d.ts +1 -1
  15. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  16. package/dest/e2e_fees/fees_test.js +14 -7
  17. package/dest/e2e_nested_contract/nested_contract_test.d.ts +1 -1
  18. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  19. package/dest/e2e_nested_contract/nested_contract_test.js +4 -6
  20. package/dest/e2e_p2p/inactivity_slash_test.d.ts +1 -1
  21. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
  22. package/dest/e2e_p2p/inactivity_slash_test.js +1 -0
  23. package/dest/e2e_p2p/p2p_network.d.ts +3 -2
  24. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  25. package/dest/e2e_p2p/p2p_network.js +18 -15
  26. package/dest/e2e_p2p/shared.d.ts +33 -1
  27. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  28. package/dest/e2e_p2p/shared.js +56 -2
  29. package/dest/e2e_token_contract/token_contract_test.d.ts +1 -1
  30. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  31. package/dest/e2e_token_contract/token_contract_test.js +11 -11
  32. package/dest/fixtures/authwit_proxy.d.ts +3 -3
  33. package/dest/fixtures/authwit_proxy.d.ts.map +1 -1
  34. package/dest/fixtures/authwit_proxy.js +4 -0
  35. package/dest/fixtures/e2e_prover_test.d.ts +1 -1
  36. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  37. package/dest/fixtures/e2e_prover_test.js +6 -6
  38. package/dest/fixtures/setup.d.ts +10 -7
  39. package/dest/fixtures/setup.d.ts.map +1 -1
  40. package/dest/fixtures/setup.js +16 -12
  41. package/dest/fixtures/token_utils.d.ts +1 -1
  42. package/dest/fixtures/token_utils.d.ts.map +1 -1
  43. package/dest/fixtures/token_utils.js +2 -2
  44. package/dest/forward-compatibility/wallet_rpc_client.d.ts +7 -0
  45. package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
  46. package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
  47. package/dest/forward-compatibility/wallet_service.d.ts +3 -0
  48. package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
  49. package/dest/forward-compatibility/wallet_service.js +109 -0
  50. package/dest/install_legacy_contracts.d.cts +10 -0
  51. package/dest/install_legacy_contracts.d.cts.map +1 -0
  52. package/dest/legacy-jest-resolver.d.cts +3 -0
  53. package/dest/legacy-jest-resolver.d.cts.map +1 -0
  54. package/dest/shared/cross_chain_test_harness.d.ts +1 -1
  55. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  56. package/dest/shared/cross_chain_test_harness.js +13 -13
  57. package/dest/shared/gas_portal_test_harness.js +2 -2
  58. package/dest/shared/submit-transactions.js +1 -1
  59. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  60. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  61. package/dest/shared/uniswap_l1_l2.js +14 -17
  62. package/dest/simulators/lending_simulator.d.ts +1 -1
  63. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  64. package/dest/simulators/lending_simulator.js +4 -4
  65. package/dest/simulators/token_simulator.d.ts +1 -1
  66. package/dest/simulators/token_simulator.d.ts.map +1 -1
  67. package/dest/simulators/token_simulator.js +2 -2
  68. package/dest/spartan/setup_test_wallets.d.ts +4 -2
  69. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  70. package/dest/spartan/setup_test_wallets.js +28 -15
  71. package/dest/spartan/utils/index.d.ts +2 -1
  72. package/dest/spartan/utils/index.d.ts.map +1 -1
  73. package/dest/spartan/utils/index.js +2 -0
  74. package/dest/spartan/utils/nodes.d.ts +5 -4
  75. package/dest/spartan/utils/nodes.d.ts.map +1 -1
  76. package/dest/spartan/utils/nodes.js +5 -4
  77. package/dest/test-wallet/test_wallet.d.ts +24 -23
  78. package/dest/test-wallet/test_wallet.d.ts.map +1 -1
  79. package/dest/test-wallet/test_wallet.js +115 -80
  80. package/dest/test-wallet/wallet_worker_script.js +41 -33
  81. package/dest/test-wallet/worker_wallet.d.ts +4 -4
  82. package/dest/test-wallet/worker_wallet.d.ts.map +1 -1
  83. package/dest/test-wallet/worker_wallet.js +51 -3
  84. package/dest/test-wallet/worker_wallet_schema.d.ts +4 -4
  85. package/package.json +41 -40
  86. package/src/bench/client_flows/client_flows_benchmark.ts +40 -32
  87. package/src/bench/utils.ts +7 -2
  88. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +21 -20
  89. package/src/e2e_epochs/epochs_test.ts +14 -2
  90. package/src/e2e_fees/fees_test.ts +14 -7
  91. package/src/e2e_nested_contract/nested_contract_test.ts +6 -4
  92. package/src/e2e_p2p/inactivity_slash_test.ts +1 -0
  93. package/src/e2e_p2p/p2p_network.ts +24 -20
  94. package/src/e2e_p2p/shared.ts +97 -2
  95. package/src/e2e_token_contract/token_contract_test.ts +16 -8
  96. package/src/fixtures/authwit_proxy.ts +4 -0
  97. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  98. package/src/fixtures/e2e_prover_test.ts +11 -5
  99. package/src/fixtures/setup.ts +27 -18
  100. package/src/fixtures/token_utils.ts +4 -2
  101. package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
  102. package/src/forward-compatibility/wallet_service.ts +104 -0
  103. package/src/install_legacy_contracts.cjs +75 -0
  104. package/src/legacy-jest-resolver.cjs +101 -0
  105. package/src/shared/cross_chain_test_harness.ts +13 -9
  106. package/src/shared/gas_portal_test_harness.ts +1 -1
  107. package/src/shared/submit-transactions.ts +1 -1
  108. package/src/shared/uniswap_l1_l2.ts +35 -28
  109. package/src/simulators/lending_simulator.ts +8 -4
  110. package/src/simulators/token_simulator.ts +6 -2
  111. package/src/spartan/setup_test_wallets.ts +51 -19
  112. package/src/spartan/utils/index.ts +3 -0
  113. package/src/spartan/utils/nodes.ts +6 -3
  114. package/src/test-wallet/test_wallet.ts +144 -99
  115. package/src/test-wallet/wallet_worker_script.ts +47 -30
  116. package/src/test-wallet/worker_wallet.ts +54 -5
@@ -13,20 +13,24 @@ import type {
13
13
  ProfileOptions,
14
14
  SendOptions,
15
15
  SimulateOptions,
16
+ TxSimulationResultWithAppOffset,
16
17
  Wallet,
17
18
  WalletCapabilities,
18
19
  } from '@aztec/aztec.js/wallet';
19
20
  import type { ChainInfo } from '@aztec/entrypoints/interfaces';
20
21
  import type { Fr } from '@aztec/foundation/curves/bn254';
21
22
  import { jsonStringify } from '@aztec/foundation/json-rpc';
23
+ import { createLogger } from '@aztec/foundation/log';
24
+ import { promiseWithResolvers } from '@aztec/foundation/promise';
22
25
  import type { ApiSchema } from '@aztec/foundation/schemas';
26
+ import { sleep } from '@aztec/foundation/sleep';
23
27
  import { NodeConnector, TransportClient } from '@aztec/foundation/transport';
24
28
  import type { PXEConfig } from '@aztec/pxe/config';
25
29
  import type { ContractArtifact, EventMetadataDefinition, FunctionCall } from '@aztec/stdlib/abi';
26
30
  import type { AuthWitness } from '@aztec/stdlib/auth-witness';
27
31
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
28
32
  import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
29
- import type { ExecutionPayload, TxProfileResult, TxSimulationResult, UtilityExecutionResult } from '@aztec/stdlib/tx';
33
+ import type { ExecutionPayload, TxProfileResult, UtilityExecutionResult } from '@aztec/stdlib/tx';
30
34
  import { Tx } from '@aztec/stdlib/tx';
31
35
 
32
36
  import { Worker } from 'worker_threads';
@@ -35,6 +39,10 @@ import { WorkerWalletSchema } from './worker_wallet_schema.js';
35
39
 
36
40
  type WorkerMsg = { fn: string; args: string };
37
41
 
42
+ const log = createLogger('e2e:test-wallet:worker-wallet');
43
+
44
+ const WORKER_READY_TIMEOUT_MS = 120_000;
45
+
38
46
  /**
39
47
  * Wallet implementation that offloads all work to a worker thread.
40
48
  * Implements the Wallet interface by proxying calls over a transport layer
@@ -53,8 +61,18 @@ export class WorkerWallet implements Wallet {
53
61
  * @returns A WorkerWallet ready to use.
54
62
  */
55
63
  static async create(nodeUrl: string, pxeConfig?: Partial<PXEConfig>): Promise<WorkerWallet> {
56
- const worker = new Worker(new URL('./wallet_worker_script.js', import.meta.url), {
64
+ // replace stc/ with dest/ so the wallet works in Jest tests
65
+ const workerUrl = new URL('./wallet_worker_script.js', import.meta.url);
66
+ workerUrl.pathname = workerUrl.pathname.replace('/src/', '/dest/');
67
+ // remove JEST_WORKER_ID so the worker uses pino-pretty transport instead of Jest's raw output.
68
+ const { JEST_WORKER_ID: _, ...parentEnv } = process.env;
69
+ const worker = new Worker(workerUrl, {
57
70
  workerData: { nodeUrl, pxeConfig },
71
+ env: {
72
+ ...parentEnv,
73
+ ...(process.stderr.isTTY || process.env.FORCE_COLOR ? { FORCE_COLOR: '1' } : {}),
74
+ LOG_LEVEL: process.env.WORKER_LOG_LEVEL ?? 'warn',
75
+ },
58
76
  });
59
77
 
60
78
  const connector = new NodeConnector(worker);
@@ -62,8 +80,39 @@ export class WorkerWallet implements Wallet {
62
80
  await client.open();
63
81
 
64
82
  const wallet = new WorkerWallet(worker, client);
65
- // Warmup / readiness check — blocks until the worker has finished creating the TestWallet.
66
- await wallet.getChainInfo();
83
+
84
+ const { promise: workerDied, reject: rejectWorkerDied } = promiseWithResolvers<void>();
85
+ // reject if the worker exits or errors before the warmup completes.
86
+ const onError = (err: Error): void => {
87
+ worker.off('exit', onExit!);
88
+ rejectWorkerDied(new Error(`Worker wallet thread error: ${err.message}`));
89
+ };
90
+
91
+ const onExit = (code: number): void => {
92
+ worker.off('error', onError!);
93
+ rejectWorkerDied(new Error(`Worker wallet thread exited with code ${code} before becoming ready`));
94
+ };
95
+
96
+ worker.once('error', onError);
97
+ worker.once('exit', onExit);
98
+
99
+ const timeout = sleep(WORKER_READY_TIMEOUT_MS).then(() => {
100
+ throw new Error(`Worker wallet creation timed out after ${WORKER_READY_TIMEOUT_MS / 1000}s`);
101
+ });
102
+
103
+ try {
104
+ // wait for worker wallet to start
105
+ await Promise.race([wallet.getChainInfo(), workerDied, timeout]);
106
+ } catch (err) {
107
+ log.error('Worker wallet creation failed, cleaning up', { error: String(err) });
108
+ client.close();
109
+ await worker.terminate();
110
+ throw err;
111
+ } finally {
112
+ worker.off('error', onError);
113
+ worker.off('exit', onExit);
114
+ }
115
+
67
116
  return wallet;
68
117
  }
69
118
 
@@ -117,7 +166,7 @@ export class WorkerWallet implements Wallet {
117
166
  return this.call('registerContract', instance, artifact, secretKey);
118
167
  }
119
168
 
120
- simulateTx(exec: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult> {
169
+ simulateTx(exec: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResultWithAppOffset> {
121
170
  return this.call('simulateTx', exec, opts);
122
171
  }
123
172