@aztec/end-to-end 0.0.1-commit.1142ef1 → 0.0.1-commit.11bf3dd6e

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 (252) hide show
  1. package/README.md +27 -0
  2. package/dest/bench/client_flows/benchmark.d.ts +3 -2
  3. package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
  4. package/dest/bench/client_flows/benchmark.js +21 -1
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts +13 -14
  6. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  7. package/dest/bench/client_flows/client_flows_benchmark.js +118 -140
  8. package/dest/bench/client_flows/config.d.ts +2 -2
  9. package/dest/bench/client_flows/config.d.ts.map +1 -1
  10. package/dest/bench/client_flows/config.js +18 -0
  11. package/dest/bench/utils.d.ts +6 -5
  12. package/dest/bench/utils.d.ts.map +1 -1
  13. package/dest/bench/utils.js +13 -8
  14. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +11 -9
  15. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  16. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +108 -114
  17. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +7 -8
  18. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  19. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +68 -64
  20. package/dest/e2e_deploy_contract/deploy_test.d.ts +5 -4
  21. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  22. package/dest/e2e_deploy_contract/deploy_test.js +18 -13
  23. package/dest/e2e_epochs/epochs_test.d.ts +17 -7
  24. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  25. package/dest/e2e_epochs/epochs_test.js +92 -42
  26. package/dest/e2e_fees/bridging_race.notest.js +3 -5
  27. package/dest/e2e_fees/fees_test.d.ts +14 -14
  28. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  29. package/dest/e2e_fees/fees_test.js +133 -144
  30. package/dest/e2e_l1_publisher/write_json.d.ts +4 -3
  31. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
  32. package/dest/e2e_l1_publisher/write_json.js +14 -13
  33. package/dest/e2e_nested_contract/nested_contract_test.d.ts +6 -9
  34. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  35. package/dest/e2e_nested_contract/nested_contract_test.js +30 -40
  36. package/dest/e2e_p2p/inactivity_slash_test.d.ts +3 -3
  37. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
  38. package/dest/e2e_p2p/inactivity_slash_test.js +6 -6
  39. package/dest/e2e_p2p/p2p_network.d.ts +15 -15
  40. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  41. package/dest/e2e_p2p/p2p_network.js +144 -119
  42. package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
  43. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
  44. package/dest/e2e_p2p/reqresp/utils.js +190 -0
  45. package/dest/e2e_p2p/shared.d.ts +30 -12
  46. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  47. package/dest/e2e_p2p/shared.js +62 -60
  48. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +2 -0
  49. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +1 -0
  50. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.js +184 -0
  51. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts +18 -0
  52. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +1 -0
  53. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.js +120 -0
  54. package/dest/e2e_token_contract/token_contract_test.d.ts +19 -10
  55. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  56. package/dest/e2e_token_contract/token_contract_test.js +100 -92
  57. package/dest/fixtures/authwit_proxy.d.ts +15 -0
  58. package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
  59. package/dest/fixtures/authwit_proxy.js +34 -0
  60. package/dest/fixtures/e2e_prover_test.d.ts +14 -19
  61. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  62. package/dest/fixtures/e2e_prover_test.js +113 -133
  63. package/dest/fixtures/elu_monitor.d.ts +21 -0
  64. package/dest/fixtures/elu_monitor.d.ts.map +1 -0
  65. package/dest/fixtures/elu_monitor.js +102 -0
  66. package/dest/fixtures/fixtures.d.ts +5 -1
  67. package/dest/fixtures/fixtures.d.ts.map +1 -1
  68. package/dest/fixtures/fixtures.js +6 -0
  69. package/dest/fixtures/get_bb_config.d.ts +1 -1
  70. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  71. package/dest/fixtures/get_bb_config.js +5 -5
  72. package/dest/fixtures/ha_setup.d.ts +71 -0
  73. package/dest/fixtures/ha_setup.d.ts.map +1 -0
  74. package/dest/fixtures/ha_setup.js +116 -0
  75. package/dest/fixtures/index.d.ts +2 -1
  76. package/dest/fixtures/index.d.ts.map +1 -1
  77. package/dest/fixtures/index.js +1 -0
  78. package/dest/fixtures/setup.d.ts +242 -0
  79. package/dest/fixtures/setup.d.ts.map +1 -0
  80. package/dest/fixtures/setup.js +611 -0
  81. package/dest/fixtures/setup_p2p_test.d.ts +18 -11
  82. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  83. package/dest/fixtures/setup_p2p_test.js +43 -32
  84. package/dest/fixtures/token_utils.d.ts +2 -2
  85. package/dest/fixtures/token_utils.d.ts.map +1 -1
  86. package/dest/fixtures/token_utils.js +7 -6
  87. package/dest/fixtures/utils.d.ts +5 -191
  88. package/dest/fixtures/utils.d.ts.map +1 -1
  89. package/dest/fixtures/utils.js +4 -615
  90. package/dest/forward-compatibility/wallet_rpc_client.d.ts +7 -0
  91. package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
  92. package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
  93. package/dest/forward-compatibility/wallet_service.d.ts +3 -0
  94. package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
  95. package/dest/forward-compatibility/wallet_service.js +109 -0
  96. package/dest/legacy-jest-resolver.d.cts +3 -0
  97. package/dest/legacy-jest-resolver.d.cts.map +1 -0
  98. package/dest/quality_of_service/prometheus_client.d.ts +38 -0
  99. package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
  100. package/dest/quality_of_service/prometheus_client.js +67 -0
  101. package/dest/shared/cross_chain_test_harness.d.ts +14 -4
  102. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  103. package/dest/shared/cross_chain_test_harness.js +24 -24
  104. package/dest/shared/gas_portal_test_harness.d.ts +11 -1
  105. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  106. package/dest/shared/gas_portal_test_harness.js +3 -3
  107. package/dest/shared/index.d.ts +2 -1
  108. package/dest/shared/index.d.ts.map +1 -1
  109. package/dest/shared/index.js +1 -0
  110. package/dest/shared/jest_setup.js +41 -1
  111. package/dest/shared/mock_state_view.d.ts +86 -0
  112. package/dest/shared/mock_state_view.d.ts.map +1 -0
  113. package/dest/shared/mock_state_view.js +186 -0
  114. package/dest/shared/submit-transactions.d.ts +4 -4
  115. package/dest/shared/submit-transactions.d.ts.map +1 -1
  116. package/dest/shared/submit-transactions.js +9 -11
  117. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  118. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  119. package/dest/shared/uniswap_l1_l2.js +27 -28
  120. package/dest/simulators/lending_simulator.d.ts +5 -1
  121. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  122. package/dest/simulators/lending_simulator.js +6 -6
  123. package/dest/simulators/token_simulator.d.ts +1 -1
  124. package/dest/simulators/token_simulator.d.ts.map +1 -1
  125. package/dest/simulators/token_simulator.js +3 -24
  126. package/dest/spartan/setup_test_wallets.d.ts +12 -3
  127. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  128. package/dest/spartan/setup_test_wallets.js +130 -42
  129. package/dest/spartan/tx_metrics.d.ts +51 -2
  130. package/dest/spartan/tx_metrics.d.ts.map +1 -1
  131. package/dest/spartan/tx_metrics.js +334 -7
  132. package/dest/spartan/utils/bot.d.ts +28 -0
  133. package/dest/spartan/utils/bot.d.ts.map +1 -0
  134. package/dest/spartan/utils/bot.js +142 -0
  135. package/dest/spartan/utils/chaos.d.ts +79 -0
  136. package/dest/spartan/utils/chaos.d.ts.map +1 -0
  137. package/dest/spartan/utils/chaos.js +142 -0
  138. package/dest/spartan/utils/clients.d.ts +39 -0
  139. package/dest/spartan/utils/clients.d.ts.map +1 -0
  140. package/dest/spartan/utils/clients.js +90 -0
  141. package/dest/spartan/utils/config.d.ts +45 -0
  142. package/dest/spartan/utils/config.d.ts.map +1 -0
  143. package/dest/spartan/utils/config.js +23 -0
  144. package/dest/spartan/utils/health.d.ts +63 -0
  145. package/dest/spartan/utils/health.d.ts.map +1 -0
  146. package/dest/spartan/utils/health.js +202 -0
  147. package/dest/spartan/utils/helm.d.ts +15 -0
  148. package/dest/spartan/utils/helm.d.ts.map +1 -0
  149. package/dest/spartan/utils/helm.js +47 -0
  150. package/dest/spartan/utils/index.d.ts +11 -0
  151. package/dest/spartan/utils/index.d.ts.map +1 -0
  152. package/dest/spartan/utils/index.js +22 -0
  153. package/dest/spartan/utils/k8s.d.ts +128 -0
  154. package/dest/spartan/utils/k8s.d.ts.map +1 -0
  155. package/dest/spartan/utils/k8s.js +381 -0
  156. package/dest/spartan/utils/nodes.d.ts +40 -0
  157. package/dest/spartan/utils/nodes.d.ts.map +1 -0
  158. package/dest/spartan/utils/nodes.js +461 -0
  159. package/dest/spartan/utils/pod_logs.d.ts +25 -0
  160. package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
  161. package/dest/spartan/utils/pod_logs.js +74 -0
  162. package/dest/spartan/utils/scripts.d.ts +30 -0
  163. package/dest/spartan/utils/scripts.d.ts.map +1 -0
  164. package/dest/spartan/utils/scripts.js +81 -0
  165. package/dest/spartan/utils.d.ts +2 -253
  166. package/dest/spartan/utils.d.ts.map +1 -1
  167. package/dest/spartan/utils.js +1 -892
  168. package/dest/test-wallet/test_wallet.d.ts +84 -0
  169. package/dest/test-wallet/test_wallet.d.ts.map +1 -0
  170. package/dest/test-wallet/test_wallet.js +249 -0
  171. package/dest/test-wallet/utils.d.ts +41 -0
  172. package/dest/test-wallet/utils.d.ts.map +1 -0
  173. package/dest/test-wallet/utils.js +71 -0
  174. package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
  175. package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
  176. package/dest/test-wallet/wallet_worker_script.js +48 -0
  177. package/dest/test-wallet/worker_wallet.d.ts +52 -0
  178. package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
  179. package/dest/test-wallet/worker_wallet.js +151 -0
  180. package/dest/test-wallet/worker_wallet_schema.d.ts +279 -0
  181. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
  182. package/dest/test-wallet/worker_wallet_schema.js +10 -0
  183. package/package.json +47 -43
  184. package/src/bench/client_flows/benchmark.ts +24 -2
  185. package/src/bench/client_flows/client_flows_benchmark.ts +157 -210
  186. package/src/bench/client_flows/config.ts +9 -1
  187. package/src/bench/utils.ts +15 -8
  188. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +123 -151
  189. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +103 -111
  190. package/src/e2e_deploy_contract/deploy_test.ts +22 -15
  191. package/src/e2e_epochs/epochs_test.ts +140 -92
  192. package/src/e2e_fees/bridging_race.notest.ts +4 -10
  193. package/src/e2e_fees/fees_test.ts +170 -224
  194. package/src/e2e_l1_publisher/write_json.ts +16 -13
  195. package/src/e2e_nested_contract/nested_contract_test.ts +35 -56
  196. package/src/e2e_p2p/inactivity_slash_test.ts +6 -6
  197. package/src/e2e_p2p/p2p_network.ts +210 -185
  198. package/src/e2e_p2p/reqresp/utils.ts +256 -0
  199. package/src/e2e_p2p/shared.ts +92 -80
  200. package/src/e2e_storage_proof/fixtures/storage_proof.json +915 -0
  201. package/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts +190 -0
  202. package/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts +173 -0
  203. package/src/e2e_token_contract/token_contract_test.ts +121 -119
  204. package/src/fixtures/authwit_proxy.ts +54 -0
  205. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  206. package/src/fixtures/e2e_prover_test.ts +140 -183
  207. package/src/fixtures/elu_monitor.ts +126 -0
  208. package/src/fixtures/fixtures.ts +10 -0
  209. package/src/fixtures/get_bb_config.ts +7 -6
  210. package/src/fixtures/ha_setup.ts +186 -0
  211. package/src/fixtures/index.ts +1 -0
  212. package/src/fixtures/setup.ts +910 -0
  213. package/src/fixtures/setup_p2p_test.ts +48 -52
  214. package/src/fixtures/token_utils.ts +7 -6
  215. package/src/fixtures/utils.ts +27 -901
  216. package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
  217. package/src/forward-compatibility/wallet_service.ts +104 -0
  218. package/src/guides/up_quick_start.sh +3 -3
  219. package/src/legacy-jest-resolver.cjs +135 -0
  220. package/src/quality_of_service/prometheus_client.ts +113 -0
  221. package/src/shared/cross_chain_test_harness.ts +24 -34
  222. package/src/shared/gas_portal_test_harness.ts +2 -2
  223. package/src/shared/index.ts +1 -0
  224. package/src/shared/jest_setup.ts +51 -1
  225. package/src/shared/mock_state_view.ts +188 -0
  226. package/src/shared/submit-transactions.ts +11 -16
  227. package/src/shared/uniswap_l1_l2.ts +49 -51
  228. package/src/simulators/lending_simulator.ts +10 -6
  229. package/src/simulators/token_simulator.ts +6 -30
  230. package/src/spartan/setup_test_wallets.ts +183 -26
  231. package/src/spartan/tx_metrics.ts +256 -10
  232. package/src/spartan/utils/bot.ts +188 -0
  233. package/src/spartan/utils/chaos.ts +253 -0
  234. package/src/spartan/utils/clients.ts +100 -0
  235. package/src/spartan/utils/config.ts +29 -0
  236. package/src/spartan/utils/health.ts +255 -0
  237. package/src/spartan/utils/helm.ts +84 -0
  238. package/src/spartan/utils/index.ts +71 -0
  239. package/src/spartan/utils/k8s.ts +535 -0
  240. package/src/spartan/utils/nodes.ts +543 -0
  241. package/src/spartan/utils/pod_logs.ts +99 -0
  242. package/src/spartan/utils/scripts.ts +99 -0
  243. package/src/spartan/utils.ts +1 -1158
  244. package/src/test-wallet/test_wallet.ts +351 -0
  245. package/src/test-wallet/utils.ts +112 -0
  246. package/src/test-wallet/wallet_worker_script.ts +60 -0
  247. package/src/test-wallet/worker_wallet.ts +214 -0
  248. package/src/test-wallet/worker_wallet_schema.ts +13 -0
  249. package/dest/fixtures/snapshot_manager.d.ts +0 -93
  250. package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
  251. package/dest/fixtures/snapshot_manager.js +0 -488
  252. package/src/fixtures/snapshot_manager.ts +0 -646
@@ -0,0 +1,14 @@
1
+ import type { Wallet } from '@aztec/aztec.js/wallet';
2
+ import { WalletSchema } from '@aztec/aztec.js/wallet';
3
+ import { createSafeJsonRpcClient, makeFetch } from '@aztec/foundation/json-rpc/client';
4
+
5
+ /**
6
+ * Creates a JSON-RPC client that connects to a remote wallet service.
7
+ * The returned object implements the {@link Wallet} interface, proxying all calls over HTTP to the specified URL.
8
+ */
9
+ export function createWalletClient(url: string): Wallet {
10
+ return createSafeJsonRpcClient<Wallet>(url, WalletSchema, {
11
+ namespaceMethods: 'wallet',
12
+ fetch: makeFetch([1, 2, 3], false),
13
+ });
14
+ }
@@ -0,0 +1,104 @@
1
+ #!/usr/bin/env -S node --no-warnings
2
+ /**
3
+ * Standalone entrypoint that spins up a local Aztec network (L1 + node) and exposes a {@link NodeEmbeddedWallet} over
4
+ * JSON-RPC.
5
+ *
6
+ * Intended for forward-compatibility testing: an **old** release image runs this script so that **new** tests can send
7
+ * new artifacts to old runtime code (loadContractArtifact, ACIR simulator, class-ID computation, entrypoint encoding,
8
+ * etc.).
9
+ */
10
+ import { getSchnorrAccountContractAddress } from '@aztec/accounts/schnorr';
11
+ import { getInitialTestAccountsData } from '@aztec/accounts/testing';
12
+ import { createLocalNetwork } from '@aztec/aztec';
13
+ import { Fr } from '@aztec/aztec.js/fields';
14
+ import { WalletSchema } from '@aztec/aztec.js/wallet';
15
+ import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
16
+ import { createNamespacedSafeJsonRpcServer, startHttpRpcServer } from '@aztec/foundation/json-rpc/server';
17
+ import { createLogger } from '@aztec/foundation/log';
18
+ import { AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
19
+ import { EmbeddedWallet } from '@aztec/wallets/embedded';
20
+
21
+ const logger = createLogger('wallet-service');
22
+
23
+ const { ETHEREUM_HOSTS = 'http://localhost:8545', NODE_PORT = '8080', WALLET_PORT = '8081' } = process.env;
24
+
25
+ async function main() {
26
+ const l1RpcUrls = ETHEREUM_HOSTS.split(',').map(url => url.trim());
27
+
28
+ // Some tests (e.g. AMM) need 4 accounts but only 3 are funded via genesis. Generate deterministic keys for a 4th
29
+ // account so we can compute its address before network startup and include it in genesis funding. We cannot do this
30
+ // in the test because Wallet interface does not expose account creation functionality (only TestWallet exposes that
31
+ // but that's not used in forward compatibility testing).
32
+ const extraAccountSecret = Fr.fromHexString('0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef');
33
+ const extraAccountSalt = Fr.ZERO;
34
+ const extraAccountSigningKey = GrumpkinScalar.random();
35
+ const extraAccountAddress = await getSchnorrAccountContractAddress(
36
+ extraAccountSecret,
37
+ extraAccountSalt,
38
+ extraAccountSigningKey,
39
+ );
40
+
41
+ logger.info('Starting wallet service...', { l1RpcUrls });
42
+
43
+ // createLocalNetwork deploys L1 contracts, starts the node, and optionally deploys funded test accounts (when
44
+ // TEST_ACCOUNTS=true via env). We are not proving anything just like is done when local network is started by
45
+ // the `aztecStart` function. The extra account address is passed via prefundAddresses so it gets fee juice at genesis.
46
+ const { node, stop: stopNetwork } = await createLocalNetwork(
47
+ { l1RpcUrls, realProofs: false, prefundAddresses: [extraAccountAddress.toString()] },
48
+ logger.info,
49
+ );
50
+
51
+ // Create an ephemeral embedded wallet backed by the local node.
52
+ const wallet = await EmbeddedWallet.create(node, { ephemeral: true });
53
+
54
+ // Re-register the initial test accounts so they are available via wallet.getAccounts(). createLocalNetwork deploys
55
+ // them onchain but uses a temporary wallet that is then stopped.
56
+ //
57
+ // We use the non-lazy import path (@aztec/accounts/testing, not /lazy) to avoid the dynamic JSON import that is
58
+ // incompatible with Node.js import attribute enforcement.
59
+ const testAccountsData = await getInitialTestAccountsData();
60
+ const accounts = await Promise.all(
61
+ testAccountsData.map(({ secret, salt, signingKey }) => wallet.createSchnorrAccount(secret, salt, signingKey)),
62
+ );
63
+
64
+ // Register and deploy the 4th account.
65
+ const extraAccount = await wallet.createSchnorrAccount(extraAccountSecret, extraAccountSalt, extraAccountSigningKey);
66
+ const deployMethod = await extraAccount.getDeployMethod();
67
+ await deployMethod.send({ from: accounts[0].address });
68
+
69
+ logger.info('Embedded wallet created', {
70
+ accounts: [...accounts, extraAccount].map(a => a.address.toString()),
71
+ });
72
+
73
+ // Contract artifacts are large, so allow generous body sizes for RPC requests.
74
+ const rpcOptions = { maxBodySizeBytes: '50mb' };
75
+
76
+ // Serve node RPC
77
+ const nodeRpcServer = createNamespacedSafeJsonRpcServer({ node: [node, AztecNodeApiSchema] }, rpcOptions);
78
+ const nodeHttpServer = await startHttpRpcServer(nodeRpcServer, { port: NODE_PORT });
79
+ logger.info(`Node JSON-RPC server listening on port ${nodeHttpServer.port}`);
80
+
81
+ // Serve wallet RPC
82
+ const walletRpcServer = createNamespacedSafeJsonRpcServer({ wallet: [wallet, WalletSchema] }, rpcOptions);
83
+ const walletHttpServer = await startHttpRpcServer(walletRpcServer, { port: WALLET_PORT });
84
+ logger.info(`Wallet JSON-RPC server listening on port ${walletHttpServer.port}`);
85
+
86
+ const shutdown = async () => {
87
+ logger.info('Shutting down...');
88
+ nodeHttpServer.close();
89
+ walletHttpServer.close();
90
+ await wallet.stop();
91
+ await stopNetwork();
92
+ process.exit(0);
93
+ };
94
+
95
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
96
+ process.once('SIGINT', shutdown);
97
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
98
+ process.once('SIGTERM', shutdown);
99
+ }
100
+
101
+ main().catch(err => {
102
+ logger.error('Wallet service failed to start', err);
103
+ process.exit(1);
104
+ });
@@ -23,6 +23,8 @@ aztec-wallet create-account -a alice -f test0
23
23
  aztec-wallet create-account -a bob -f test0
24
24
  # docs:end:declare-accounts
25
25
 
26
+ aztec-wallet bridge-fee-juice 1000000000000000000000 accounts:alice --mint --no-wait
27
+
26
28
  DEPLOY_OUTPUT=$(aztec-wallet deploy ../noir-contracts.js/artifacts/token_contract-Token.json --args accounts:test0 Test TST 18 -f test0)
27
29
  TOKEN_ADDRESS=$(echo "$DEPLOY_OUTPUT" | grep -oE 'Contract deployed at 0x[0-9a-fA-F]+' | cut -d ' ' -f4)
28
30
  echo "Deployed contract at $TOKEN_ADDRESS"
@@ -38,9 +40,7 @@ fi
38
40
 
39
41
  TRANSFER_AMOUNT=42
40
42
 
41
- aztec-wallet create-authwit transfer_in_private accounts:test0 -ca last --args accounts:alice accounts:bob $TRANSFER_AMOUNT 1 -f alice
42
-
43
- aztec-wallet send transfer_in_private -ca last --args accounts:alice accounts:bob $TRANSFER_AMOUNT 1 -aw authwits:last -f test0
43
+ aztec-wallet send transfer_in_private -ca last --args accounts:alice accounts:bob $TRANSFER_AMOUNT 0 -f alice --payment method=fee_juice,claim
44
44
 
45
45
  # Test end result
46
46
  ALICE_BALANCE=$(aztec-wallet simulate balance_of_private -ca last --args accounts:alice -f alice)
@@ -0,0 +1,135 @@
1
+ // Custom Jest resolver. When CONTRACT_ARTIFACTS_VERSION is set, redirects *only* JSON artifact files under
2
+ // @aztec/noir-contracts.js/artifacts/, @aztec/noir-test-contracts.js/artifacts/, and @aztec/accounts/artifacts/ to a local cache of the pinned
3
+ // legacy versions. TypeScript wrapper classes (e.g. Token.ts) continue to load from the current workspace and use the
4
+ // current @aztec/aztec.js — only the artifact JSON (the deployed-contract ABI / bytecode / notes surface) is swapped.
5
+ //
6
+ // Why JSON-only: the JSON artifact is the actual interchange surface a "deployed contract" exposes. The TS wrapper is
7
+ // generated client-side ergonomics that's tightly coupled to the current @aztec/aztec.js API. Redirecting the wrapper
8
+ // would couple this test to a moving aztec.js surface and break at import time on unrelated breaking changes; we want
9
+ // to fail only on actual artifact-compat regressions.
10
+ //
11
+ // The cache is populated on demand by running `npm install` into .legacy-contracts/<version>/.
12
+ //
13
+ // Activated by env var; passthrough otherwise.
14
+ /* eslint-disable @typescript-eslint/no-require-imports */
15
+
16
+ const path = require('path');
17
+ const fs = require('fs');
18
+ const { execSync } = require('child_process');
19
+
20
+ const version = process.env.CONTRACT_ARTIFACTS_VERSION;
21
+ const REDIRECTED = ['@aztec/noir-contracts.js', '@aztec/noir-test-contracts.js', '@aztec/accounts'];
22
+
23
+ // Jest sets rootDir to <e2e>/src; this file lives there too.
24
+ const e2eRoot = path.resolve(__dirname, '..');
25
+ const cacheRoot = version ? path.join(e2eRoot, '.legacy-contracts', version) : null;
26
+
27
+ function pkgJsonPath(name) {
28
+ return path.join(cacheRoot, 'node_modules', name, 'package.json');
29
+ }
30
+
31
+ function ensureCache() {
32
+ const missing = REDIRECTED.some(p => !fs.existsSync(pkgJsonPath(p)));
33
+ if (!missing) {
34
+ return;
35
+ }
36
+ fs.mkdirSync(cacheRoot, { recursive: true });
37
+ // Seed a standalone package.json so `npm install --prefix` treats cacheRoot as its own project. Without this, npm
38
+ // walks up and finds the yarn-project workspace root, which breaks on `workspace:` protocol deps and risks
39
+ // clobbering the monorepo's node_modules.
40
+ const seed = path.join(cacheRoot, 'package.json');
41
+ if (!fs.existsSync(seed)) {
42
+ fs.writeFileSync(seed, JSON.stringify({ name: 'legacy-contracts-cache', private: true }));
43
+ }
44
+
45
+ const specs = REDIRECTED.map(p => `${p}@${version}`).join(' ');
46
+ process.stderr.write(`[legacy-contracts] installing ${specs} into ${cacheRoot}\n`);
47
+ // --prefix: install into cacheRoot instead of cwd, so the cache is isolated from the monorepo.
48
+ // --no-save: don't write the installed packages back to the seeded package.json.
49
+ // --ignore-scripts: skip lifecycle scripts (preinstall/postinstall) of the legacy packages and their transitive
50
+ // deps; we only want the files on disk, not to run any build steps.
51
+ // --legacy-peer-deps: tolerate peer-dependency mismatches between the pinned legacy @aztec/* graph and whatever
52
+ // current versions npm would otherwise try to reconcile.
53
+ execSync(`npm install --prefix "${cacheRoot}" --no-save --ignore-scripts --legacy-peer-deps ${specs}`, {
54
+ stdio: 'inherit',
55
+ });
56
+
57
+ // Verify versions on disk match the requested version.
58
+ for (const p of REDIRECTED) {
59
+ const onDisk = JSON.parse(fs.readFileSync(pkgJsonPath(p), 'utf8')).version;
60
+ if (onDisk !== version) {
61
+ throw new Error(`[legacy-contracts] ${p} on disk is ${onDisk}, expected ${version}`);
62
+ }
63
+ }
64
+ }
65
+
66
+ if (version) {
67
+ ensureCache();
68
+ }
69
+
70
+ let bannerPrinted = false;
71
+ const seen = new Set();
72
+
73
+ function printBannerOnce() {
74
+ if (bannerPrinted || !version) {
75
+ return;
76
+ }
77
+ bannerPrinted = true;
78
+ const lines = ['='.repeat(60), `[legacy-contracts][jest] CONTRACT_ARTIFACTS_VERSION=${version}`];
79
+ for (const p of REDIRECTED) {
80
+ const v = JSON.parse(fs.readFileSync(pkgJsonPath(p), 'utf8')).version;
81
+ if (v !== version) {
82
+ throw new Error(`[legacy-contracts] ${p} on disk is ${v}, expected ${version}`);
83
+ }
84
+ lines.push(`[legacy-contracts][jest] redirecting ${p}/artifacts/*.json -> .legacy-contracts/${version}/...`);
85
+ }
86
+ lines.push('='.repeat(60));
87
+ process.stderr.write(lines.join('\n') + '\n');
88
+ }
89
+
90
+ // Match a resolved absolute path against the workspace artifacts dirs and return the legacy cache equivalent, or null
91
+ // if it's not an artifact path we should redirect.
92
+ function legacyArtifactPath(resolved) {
93
+ if (!resolved.endsWith('.json')) {
94
+ return null;
95
+ }
96
+ for (const pkg of REDIRECTED) {
97
+ // pkg = '@aztec/noir-contracts.js' -> match '/noir-contracts.js/artifacts/'
98
+ const dirName = pkg.split('/')[1];
99
+ const marker = `/${dirName}/artifacts/`;
100
+ const idx = resolved.indexOf(marker);
101
+ if (idx === -1) {
102
+ continue;
103
+ }
104
+ const basename = resolved.slice(idx + marker.length);
105
+ return path.join(cacheRoot, 'node_modules', pkg, 'artifacts', basename);
106
+ }
107
+ return null;
108
+ }
109
+
110
+ module.exports = function legacyResolver(request, options) {
111
+ // Always run the default resolver first. We only inspect (and possibly rewrite) the *result*; this catches both
112
+ // bare-specifier imports of `@aztec/noir-contracts.js/artifacts/foo.json` and the relative `../artifacts/foo.json`
113
+ // imports inside the workspace TS wrapper classes — both resolve to the same workspace artifact path that we then
114
+ // redirect.
115
+ const resolved = options.defaultResolver(request, options);
116
+ if (!version) {
117
+ return resolved;
118
+ }
119
+ printBannerOnce();
120
+ const legacy = legacyArtifactPath(resolved);
121
+ if (!legacy) {
122
+ return resolved;
123
+ }
124
+ if (!fs.existsSync(legacy)) {
125
+ throw new Error(
126
+ `[legacy-contracts] artifact ${path.basename(legacy)} not present in legacy cache @${version}; ` +
127
+ `the contract may have been added after that release. Pin a newer CONTRACT_ARTIFACTS_VERSION or skip this test.`,
128
+ );
129
+ }
130
+ if (!seen.has(resolved)) {
131
+ seen.add(resolved);
132
+ process.stderr.write(`[legacy-contracts][jest] redirected ${path.basename(legacy)} -> ${legacy}\n`);
133
+ }
134
+ return legacy;
135
+ };
@@ -0,0 +1,113 @@
1
+ export type PromteheusClientOptions = {
2
+ server: URL;
3
+ };
4
+
5
+ export class PrometheusClient {
6
+ constructor(
7
+ private config: PromteheusClientOptions,
8
+ private httpClient: typeof fetch = fetch,
9
+ ) {}
10
+
11
+ public async querySingleValue(query: string, time = new Date()): Promise<number> {
12
+ const resp = await this.queryRaw(query, time);
13
+ if (resp.status === 'success') {
14
+ if (resp.data.resultType === 'vector') {
15
+ if (resp.data.result.length === 0) {
16
+ return 0;
17
+ }
18
+ const [_, value] = resp.data.result[0].value;
19
+ return parseFloat(value);
20
+ }
21
+ }
22
+
23
+ throw new TypeError('Unsupported response body', { cause: JSON.stringify(resp) });
24
+ }
25
+
26
+ public queryRaw(query: string, time = new Date()): Promise<PrometheusResponse> {
27
+ const searchParams = new URLSearchParams();
28
+ searchParams.set('query', query);
29
+ searchParams.set('time', String(Math.trunc(time.getTime() / 1000)));
30
+ searchParams.set('limit', '10');
31
+
32
+ return this.callPrometheus('query', searchParams);
33
+ }
34
+
35
+ public queryRangeRaw(
36
+ query: string,
37
+ step: PrometheusDuration,
38
+ start: Date,
39
+ end = new Date(),
40
+ ): Promise<PrometheusResponse> {
41
+ const searchParams = new URLSearchParams();
42
+ searchParams.set('query', query);
43
+ searchParams.set('step', step);
44
+ searchParams.set('start', String(Math.trunc(start.getTime() / 1000)));
45
+ searchParams.set('end', String(Math.trunc(end.getTime() / 1000)));
46
+ searchParams.set('limit', '10');
47
+
48
+ return this.callPrometheus('query_range', searchParams);
49
+ }
50
+
51
+ private async callPrometheus(api: string, searchParams: URLSearchParams): Promise<PrometheusResponse> {
52
+ const url = new URL('api/v1/' + api, this.config.server);
53
+ for (const [name, value] of searchParams) {
54
+ url.searchParams.append(name, value);
55
+ }
56
+
57
+ const resp = await this.httpClient(url, { method: 'GET' });
58
+ if (!resp.ok || resp.status !== 200) {
59
+ throw new Error('Invalid HTTP response from Prometheus', {
60
+ cause: {
61
+ url,
62
+ status: resp.status,
63
+ statusText: resp.statusText,
64
+ },
65
+ });
66
+ }
67
+
68
+ const body = await resp.json();
69
+ if ('status' in body && (body.status === 'error' || body.status === 'success')) {
70
+ return body;
71
+ }
72
+
73
+ throw new Error('Invalid response from Prometheus', {
74
+ cause: {
75
+ url,
76
+ body,
77
+ },
78
+ });
79
+ }
80
+ }
81
+
82
+ export type PrometheusDuration = `${number}s` | `${number}m` | `${number}h`;
83
+
84
+ export type PrometheusData =
85
+ | {
86
+ resultType: 'vector';
87
+ result: Array<{
88
+ metric: unknown;
89
+ value: [unixTimestamp: number, value: string];
90
+ }>;
91
+ }
92
+ | {
93
+ resultType: 'matrix';
94
+ result: Array<{
95
+ metric: unknown;
96
+ values: [unixTimestamp: number, value: string];
97
+ }>;
98
+ }
99
+ | {
100
+ resultType: 'scalar' | 'string';
101
+ result: unknown;
102
+ };
103
+
104
+ export type PrometheusResponse =
105
+ | {
106
+ status: 'error';
107
+ errorType: string;
108
+ error: string;
109
+ }
110
+ | {
111
+ status: 'success';
112
+ data: PrometheusData;
113
+ };
@@ -18,7 +18,6 @@ import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses'
18
18
  import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
19
19
  import { EpochNumber } from '@aztec/foundation/branded-types';
20
20
  import { retryUntil } from '@aztec/foundation/retry';
21
- import type { FieldsOf } from '@aztec/foundation/types';
22
21
  import { TestERC20Abi, TokenPortalAbi, TokenPortalBytecode } from '@aztec/l1-artifacts';
23
22
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
24
23
  import { TokenBridgeContract } from '@aztec/noir-contracts.js/TokenBridge';
@@ -74,26 +73,26 @@ export async function deployAndInitializeTokenAndBridgeContracts(
74
73
  });
75
74
 
76
75
  // deploy l2 token
77
- const token = await TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18)
78
- .send({ from: owner })
79
- .deployed();
76
+ const { contract: token } = await TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18).send({
77
+ from: owner,
78
+ });
80
79
 
81
80
  // deploy l2 token bridge and attach to the portal
82
- const bridge = await TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress)
83
- .send({ from: owner })
84
- .deployed();
81
+ const { contract: bridge } = await TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress).send({
82
+ from: owner,
83
+ });
85
84
 
86
- if ((await token.methods.get_admin().simulate({ from: owner })) !== owner.toBigInt()) {
85
+ if ((await token.methods.get_admin().simulate({ from: owner })).result !== owner.toBigInt()) {
87
86
  throw new Error(`Token admin is not ${owner}`);
88
87
  }
89
88
 
90
- if (!(await bridge.methods.get_config().simulate({ from: owner })).token.equals(token.address)) {
89
+ if (!(await bridge.methods.get_config().simulate({ from: owner })).result.token.equals(token.address)) {
91
90
  throw new Error(`Bridge token is not ${token.address}`);
92
91
  }
93
92
 
94
93
  // make the bridge a minter on the token:
95
- await token.methods.set_minter(bridge.address, true).send({ from: owner }).wait();
96
- if ((await token.methods.is_minter(bridge.address).simulate({ from: owner })) === 1n) {
94
+ await token.methods.set_minter(bridge.address, true).send({ from: owner });
95
+ if ((await token.methods.is_minter(bridge.address).simulate({ from: owner })).result === 1n) {
97
96
  throw new Error(`Bridge is not a minter`);
98
97
  }
99
98
 
@@ -235,7 +234,7 @@ export class CrossChainTestHarness {
235
234
 
236
235
  async mintTokensPublicOnL2(amount: bigint) {
237
236
  this.logger.info('Minting tokens on L2 publicly');
238
- await this.l2Token.methods.mint_to_public(this.ownerAddress, amount).send({ from: this.ownerAddress }).wait();
237
+ await this.l2Token.methods.mint_to_public(this.ownerAddress, amount).send({ from: this.ownerAddress });
239
238
  }
240
239
 
241
240
  async mintTokensPrivateOnL2(amount: bigint) {
@@ -246,8 +245,7 @@ export class CrossChainTestHarness {
246
245
  // send a transfer tx to force through rollup with the message included
247
246
  await this.l2Token.methods
248
247
  .transfer_in_public(this.ownerAddress, receiverAddress, transferAmount, 0)
249
- .send({ from: this.ownerAddress })
250
- .wait();
248
+ .send({ from: this.ownerAddress });
251
249
  }
252
250
 
253
251
  async consumeMessageOnAztecAndMintPrivately(
@@ -257,8 +255,7 @@ export class CrossChainTestHarness {
257
255
  const { recipient, claimAmount, claimSecret: secretForL2MessageConsumption, messageLeafIndex } = claim;
258
256
  await this.l2Bridge.methods
259
257
  .claim_private(recipient, claimAmount, secretForL2MessageConsumption, messageLeafIndex)
260
- .send({ from: this.ownerAddress })
261
- .wait();
258
+ .send({ from: this.ownerAddress });
262
259
  }
263
260
 
264
261
  async consumeMessageOnAztecAndMintPublicly(
@@ -268,34 +265,31 @@ export class CrossChainTestHarness {
268
265
  const { claimAmount, claimSecret, messageLeafIndex } = claim;
269
266
  await this.l2Bridge.methods
270
267
  .claim_public(this.ownerAddress, claimAmount, claimSecret, messageLeafIndex)
271
- .send({ from: this.ownerAddress })
272
- .wait();
268
+ .send({ from: this.ownerAddress });
273
269
  }
274
270
 
275
271
  async withdrawPrivateFromAztecToL1(
276
272
  withdrawAmount: bigint,
277
273
  authwitNonce: Fr = Fr.ZERO,
278
274
  authWitness: AuthWitness,
279
- ): Promise<FieldsOf<TxReceipt>> {
280
- const withdrawReceipt = await this.l2Bridge.methods
275
+ ): Promise<TxReceipt> {
276
+ const { receipt: withdrawReceipt } = await this.l2Bridge.methods
281
277
  .exit_to_l1_private(this.l2Token.address, this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce)
282
- .send({ authWitnesses: [authWitness], from: this.ownerAddress })
283
- .wait();
278
+ .send({ authWitnesses: [authWitness], from: this.ownerAddress });
284
279
 
285
280
  return withdrawReceipt;
286
281
  }
287
282
 
288
- async withdrawPublicFromAztecToL1(withdrawAmount: bigint, authwitNonce: Fr = Fr.ZERO): Promise<FieldsOf<TxReceipt>> {
289
- const withdrawReceipt = await this.l2Bridge.methods
283
+ async withdrawPublicFromAztecToL1(withdrawAmount: bigint, authwitNonce: Fr = Fr.ZERO): Promise<TxReceipt> {
284
+ const { receipt: withdrawReceipt } = await this.l2Bridge.methods
290
285
  .exit_to_l1_public(this.ethAccount, withdrawAmount, EthAddress.ZERO, authwitNonce)
291
- .send({ from: this.ownerAddress })
292
- .wait();
286
+ .send({ from: this.ownerAddress });
293
287
 
294
288
  return withdrawReceipt;
295
289
  }
296
290
 
297
291
  async getL2PrivateBalanceOf(owner: AztecAddress) {
298
- return await this.l2Token.methods.balance_of_private(owner).simulate({ from: owner });
292
+ return (await this.l2Token.methods.balance_of_private(owner).simulate({ from: owner })).result;
299
293
  }
300
294
 
301
295
  async expectPrivateBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
@@ -305,7 +299,7 @@ export class CrossChainTestHarness {
305
299
  }
306
300
 
307
301
  async getL2PublicBalanceOf(owner: AztecAddress) {
308
- return await this.l2Token.methods.balance_of_public(owner).simulate({ from: this.ownerAddress });
302
+ return (await this.l2Token.methods.balance_of_public(owner).simulate({ from: this.ownerAddress })).result;
309
303
  }
310
304
 
311
305
  async expectPublicBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
@@ -333,18 +327,14 @@ export class CrossChainTestHarness {
333
327
 
334
328
  async transferToPrivateOnL2(shieldAmount: bigint) {
335
329
  this.logger.info('Transferring to private on L2');
336
- await this.l2Token.methods
337
- .transfer_to_private(this.ownerAddress, shieldAmount)
338
- .send({ from: this.ownerAddress })
339
- .wait();
330
+ await this.l2Token.methods.transfer_to_private(this.ownerAddress, shieldAmount).send({ from: this.ownerAddress });
340
331
  }
341
332
 
342
333
  async transferToPublicOnL2(amount: bigint, authwitNonce = Fr.ZERO) {
343
334
  this.logger.info('Transferring tokens to public');
344
335
  await this.l2Token.methods
345
336
  .transfer_to_public(this.ownerAddress, this.ownerAddress, amount, authwitNonce)
346
- .send({ from: this.ownerAddress })
347
- .wait();
337
+ .send({ from: this.ownerAddress });
348
338
  }
349
339
 
350
340
  /**
@@ -127,11 +127,11 @@ export class GasBridgingTestHarness implements IGasBridgingTestHarness {
127
127
  async consumeMessageOnAztecAndClaimPrivately(owner: AztecAddress, claimer: AztecAddress, claim: L2AmountClaim) {
128
128
  this.logger.info('Consuming messages on L2 Privately');
129
129
  const { claimAmount, claimSecret, messageLeafIndex } = claim;
130
- await this.feeJuice.methods.claim(owner, claimAmount, claimSecret, messageLeafIndex).send({ from: claimer }).wait();
130
+ await this.feeJuice.methods.claim(owner, claimAmount, claimSecret, messageLeafIndex).send({ from: claimer });
131
131
  }
132
132
 
133
133
  async getL2PublicBalanceOf(owner: AztecAddress) {
134
- return await this.feeJuice.methods.balance_of_public(owner).simulate({ from: owner });
134
+ return (await this.feeJuice.methods.balance_of_public(owner).simulate({ from: owner })).result;
135
135
  }
136
136
 
137
137
  async expectPublicBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) {
@@ -1 +1,2 @@
1
1
  export { uniswapL1L2TestSuite } from './uniswap_l1_l2.js';
2
+ export { MockStateView, diffInBps } from './mock_state_view.js';
@@ -1,8 +1,19 @@
1
1
  import { createLogger } from '@aztec/aztec.js/log';
2
2
 
3
- import { beforeEach, expect } from '@jest/globals';
3
+ import { afterAll, afterEach, beforeEach, expect } from '@jest/globals';
4
+ import { readlinkSync } from 'fs';
4
5
  import { basename } from 'path';
5
6
 
7
+ import { EluMonitor } from '../fixtures/elu_monitor.js';
8
+
9
+ const eluMonitor = process.env.ELU_MONITOR_FILE
10
+ ? new EluMonitor(process.env.ELU_MONITOR_FILE, Number(process.env.ELU_MONITOR_INTERVAL_MS) || undefined)
11
+ : undefined;
12
+
13
+ if (eluMonitor) {
14
+ process.on('exit', () => eluMonitor.stop());
15
+ }
16
+
6
17
  beforeEach(() => {
7
18
  const { testPath, currentTestName } = expect.getState();
8
19
  if (!testPath || !currentTestName) {
@@ -10,4 +21,43 @@ beforeEach(() => {
10
21
  }
11
22
  const logger = createLogger(`e2e:${basename(testPath).replace('.test.ts', '')}`);
12
23
  logger.info(`Running test: ${currentTestName}`);
24
+ eluMonitor?.startTest(currentTestName);
25
+ });
26
+
27
+ afterEach(() => {
28
+ eluMonitor?.stopTest();
29
+ });
30
+
31
+ // Log leaked handles after all tests complete. This runs after test-level afterAll hooks,
32
+ // so any handles still alive at this point were not properly cleaned up during teardown.
33
+ // This diagnostic helps identify the source of exit hangs without masking them.
34
+ afterAll(() => {
35
+ const handles = (process as any)._getActiveHandles();
36
+ if (handles.length > 0) {
37
+ const details = handles.map((h: any) => {
38
+ const type = h?.constructor?.name ?? typeof h;
39
+ const fd = h?.fd ?? h?._handle?.fd ?? '?';
40
+ const destroyed = h?.destroyed ?? '?';
41
+ const hasRef = typeof h?.hasRef === 'function' ? h.hasRef() : '?';
42
+ const localAddr = h?.localAddress ?? '';
43
+ const remoteAddr = h?.remoteAddress ?? '';
44
+ const localPort = h?.localPort ?? '';
45
+ const remotePort = h?.remotePort ?? '';
46
+ const proto = Object.getPrototypeOf(h)?.constructor?.name ?? '?';
47
+ const keys = Object.keys(h).slice(0, 10).join(',');
48
+ let fdTarget = '';
49
+ if (typeof fd === 'number') {
50
+ try {
51
+ fdTarget = ` -> ${readlinkSync(`/proc/self/fd/${fd}`)}`;
52
+ } catch {
53
+ // ignore
54
+ }
55
+ }
56
+ return ` ${type}(fd=${fd}, destroyed=${destroyed}, hasRef=${hasRef}${fdTarget}) proto=${proto} addr=${localAddr}:${localPort}->${remoteAddr}:${remotePort} keys=[${keys}]`;
57
+ });
58
+ process.stderr.write(
59
+ `\n[jest_setup] WARNING: ${handles.length} handle(s) still active after teardown:\n${details.join('\n')}\n` +
60
+ `These may prevent Jest from exiting. Investigate and fix the leak.\n\n`,
61
+ );
62
+ }
13
63
  });