@aztec/end-to-end 0.0.1-commit.96bb3f7 → 0.0.1-commit.993d240

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 (263) hide show
  1. package/README.md +27 -0
  2. package/dest/bench/client_flows/benchmark.d.ts +17 -2
  3. package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
  4. package/dest/bench/client_flows/benchmark.js +38 -1
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts +14 -15
  6. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  7. package/dest/bench/client_flows/client_flows_benchmark.js +132 -150
  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 +15 -8
  14. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +12 -10
  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 +120 -117
  17. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +21 -11
  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 +103 -67
  20. package/dest/e2e_deploy_contract/deploy_test.d.ts +6 -5
  21. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  22. package/dest/e2e_deploy_contract/deploy_test.js +20 -14
  23. package/dest/e2e_epochs/epochs_test.d.ts +39 -8
  24. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  25. package/dest/e2e_epochs/epochs_test.js +171 -50
  26. package/dest/e2e_fees/bridging_race.notest.js +3 -5
  27. package/dest/e2e_fees/fees_test.d.ts +18 -15
  28. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  29. package/dest/e2e_fees/fees_test.js +157 -142
  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 +7 -10
  34. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  35. package/dest/e2e_nested_contract/nested_contract_test.js +32 -41
  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 +8 -6
  39. package/dest/e2e_p2p/p2p_network.d.ts +20 -17
  40. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  41. package/dest/e2e_p2p/p2p_network.js +166 -123
  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 +206 -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 +86 -66
  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 +20 -11
  55. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  56. package/dest/e2e_token_contract/token_contract_test.js +103 -93
  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 +15 -20
  61. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  62. package/dest/fixtures/e2e_prover_test.js +115 -134
  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 +77 -1
  67. package/dest/fixtures/fixtures.d.ts.map +1 -1
  68. package/dest/fixtures/fixtures.js +74 -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/schnorr_hardcoded_account_contract.d.ts +25 -0
  79. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts.map +1 -0
  80. package/dest/fixtures/schnorr_hardcoded_account_contract.js +37 -0
  81. package/dest/fixtures/setup.d.ts +266 -0
  82. package/dest/fixtures/setup.d.ts.map +1 -0
  83. package/dest/fixtures/setup.js +714 -0
  84. package/dest/fixtures/setup_p2p_test.d.ts +22 -11
  85. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  86. package/dest/fixtures/setup_p2p_test.js +43 -32
  87. package/dest/fixtures/token_utils.d.ts +2 -2
  88. package/dest/fixtures/token_utils.d.ts.map +1 -1
  89. package/dest/fixtures/token_utils.js +7 -6
  90. package/dest/fixtures/utils.d.ts +5 -191
  91. package/dest/fixtures/utils.d.ts.map +1 -1
  92. package/dest/fixtures/utils.js +4 -615
  93. package/dest/forward-compatibility/wallet_rpc_client.d.ts +7 -0
  94. package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
  95. package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
  96. package/dest/forward-compatibility/wallet_service.d.ts +3 -0
  97. package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
  98. package/dest/forward-compatibility/wallet_service.js +109 -0
  99. package/dest/install_legacy_contracts.d.cts +10 -0
  100. package/dest/install_legacy_contracts.d.cts.map +1 -0
  101. package/dest/legacy-jest-resolver.d.cts +3 -0
  102. package/dest/legacy-jest-resolver.d.cts.map +1 -0
  103. package/dest/quality_of_service/prometheus_client.d.ts +38 -0
  104. package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
  105. package/dest/quality_of_service/prometheus_client.js +67 -0
  106. package/dest/shared/cross_chain_test_harness.d.ts +17 -5
  107. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  108. package/dest/shared/cross_chain_test_harness.js +33 -29
  109. package/dest/shared/gas_portal_test_harness.d.ts +18 -5
  110. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  111. package/dest/shared/gas_portal_test_harness.js +20 -11
  112. package/dest/shared/index.d.ts +2 -1
  113. package/dest/shared/index.d.ts.map +1 -1
  114. package/dest/shared/index.js +1 -0
  115. package/dest/shared/jest_setup.js +41 -1
  116. package/dest/shared/mock_state_view.d.ts +86 -0
  117. package/dest/shared/mock_state_view.d.ts.map +1 -0
  118. package/dest/shared/mock_state_view.js +186 -0
  119. package/dest/shared/submit-transactions.d.ts +4 -4
  120. package/dest/shared/submit-transactions.d.ts.map +1 -1
  121. package/dest/shared/submit-transactions.js +9 -11
  122. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  123. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  124. package/dest/shared/uniswap_l1_l2.js +73 -50
  125. package/dest/shared/wait_for_l1_to_l2_message.d.ts +13 -0
  126. package/dest/shared/wait_for_l1_to_l2_message.d.ts.map +1 -0
  127. package/dest/shared/wait_for_l1_to_l2_message.js +10 -0
  128. package/dest/simulators/lending_simulator.d.ts +14 -3
  129. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  130. package/dest/simulators/lending_simulator.js +28 -16
  131. package/dest/simulators/token_simulator.d.ts +1 -1
  132. package/dest/simulators/token_simulator.d.ts.map +1 -1
  133. package/dest/simulators/token_simulator.js +3 -24
  134. package/dest/spartan/setup_test_wallets.d.ts +12 -3
  135. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  136. package/dest/spartan/setup_test_wallets.js +133 -43
  137. package/dest/spartan/tx_metrics.d.ts +68 -5
  138. package/dest/spartan/tx_metrics.d.ts.map +1 -1
  139. package/dest/spartan/tx_metrics.js +399 -19
  140. package/dest/spartan/utils/bot.d.ts +28 -0
  141. package/dest/spartan/utils/bot.d.ts.map +1 -0
  142. package/dest/spartan/utils/bot.js +142 -0
  143. package/dest/spartan/utils/chaos.d.ts +79 -0
  144. package/dest/spartan/utils/chaos.d.ts.map +1 -0
  145. package/dest/spartan/utils/chaos.js +142 -0
  146. package/dest/spartan/utils/clients.d.ts +39 -0
  147. package/dest/spartan/utils/clients.d.ts.map +1 -0
  148. package/dest/spartan/utils/clients.js +90 -0
  149. package/dest/spartan/utils/config.d.ts +19 -0
  150. package/dest/spartan/utils/config.d.ts.map +1 -0
  151. package/dest/spartan/utils/config.js +23 -0
  152. package/dest/spartan/utils/health.d.ts +63 -0
  153. package/dest/spartan/utils/health.d.ts.map +1 -0
  154. package/dest/spartan/utils/health.js +202 -0
  155. package/dest/spartan/utils/helm.d.ts +15 -0
  156. package/dest/spartan/utils/helm.d.ts.map +1 -0
  157. package/dest/spartan/utils/helm.js +47 -0
  158. package/dest/spartan/utils/index.d.ts +11 -0
  159. package/dest/spartan/utils/index.d.ts.map +1 -0
  160. package/dest/spartan/utils/index.js +22 -0
  161. package/dest/spartan/utils/k8s.d.ts +128 -0
  162. package/dest/spartan/utils/k8s.d.ts.map +1 -0
  163. package/dest/spartan/utils/k8s.js +381 -0
  164. package/dest/spartan/utils/nodes.d.ts +40 -0
  165. package/dest/spartan/utils/nodes.d.ts.map +1 -0
  166. package/dest/spartan/utils/nodes.js +461 -0
  167. package/dest/spartan/utils/pod_logs.d.ts +25 -0
  168. package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
  169. package/dest/spartan/utils/pod_logs.js +74 -0
  170. package/dest/spartan/utils/scripts.d.ts +30 -0
  171. package/dest/spartan/utils/scripts.d.ts.map +1 -0
  172. package/dest/spartan/utils/scripts.js +81 -0
  173. package/dest/spartan/utils.d.ts +2 -253
  174. package/dest/spartan/utils.d.ts.map +1 -1
  175. package/dest/spartan/utils.js +1 -892
  176. package/dest/test-wallet/test_wallet.d.ts +85 -0
  177. package/dest/test-wallet/test_wallet.d.ts.map +1 -0
  178. package/dest/test-wallet/test_wallet.js +273 -0
  179. package/dest/test-wallet/utils.d.ts +41 -0
  180. package/dest/test-wallet/utils.d.ts.map +1 -0
  181. package/dest/test-wallet/utils.js +66 -0
  182. package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
  183. package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
  184. package/dest/test-wallet/wallet_worker_script.js +48 -0
  185. package/dest/test-wallet/worker_wallet.d.ts +53 -0
  186. package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
  187. package/dest/test-wallet/worker_wallet.js +155 -0
  188. package/dest/test-wallet/worker_wallet_schema.d.ts +160 -0
  189. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
  190. package/dest/test-wallet/worker_wallet_schema.js +22 -0
  191. package/package.json +53 -45
  192. package/src/bench/client_flows/benchmark.ts +43 -2
  193. package/src/bench/client_flows/client_flows_benchmark.ts +189 -240
  194. package/src/bench/client_flows/config.ts +9 -1
  195. package/src/bench/utils.ts +17 -9
  196. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +141 -152
  197. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +144 -114
  198. package/src/e2e_deploy_contract/deploy_test.ts +24 -16
  199. package/src/e2e_epochs/epochs_test.ts +217 -93
  200. package/src/e2e_fees/bridging_race.notest.ts +4 -10
  201. package/src/e2e_fees/fees_test.ts +206 -227
  202. package/src/e2e_l1_publisher/write_json.ts +16 -13
  203. package/src/e2e_nested_contract/nested_contract_test.ts +38 -57
  204. package/src/e2e_p2p/inactivity_slash_test.ts +8 -6
  205. package/src/e2e_p2p/p2p_network.ts +238 -190
  206. package/src/e2e_p2p/reqresp/utils.ts +274 -0
  207. package/src/e2e_p2p/shared.ts +111 -83
  208. package/src/e2e_storage_proof/fixtures/storage_proof.json +915 -0
  209. package/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts +190 -0
  210. package/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts +173 -0
  211. package/src/e2e_token_contract/token_contract_test.ts +129 -117
  212. package/src/fixtures/authwit_proxy.ts +54 -0
  213. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  214. package/src/fixtures/e2e_prover_test.ts +143 -184
  215. package/src/fixtures/elu_monitor.ts +126 -0
  216. package/src/fixtures/fixtures.ts +96 -0
  217. package/src/fixtures/get_bb_config.ts +7 -6
  218. package/src/fixtures/ha_setup.ts +188 -0
  219. package/src/fixtures/index.ts +1 -0
  220. package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
  221. package/src/fixtures/setup.ts +1037 -0
  222. package/src/fixtures/setup_p2p_test.ts +52 -52
  223. package/src/fixtures/token_utils.ts +7 -6
  224. package/src/fixtures/utils.ts +29 -901
  225. package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
  226. package/src/forward-compatibility/wallet_service.ts +104 -0
  227. package/src/guides/up_quick_start.sh +3 -5
  228. package/src/install_legacy_contracts.cjs +75 -0
  229. package/src/legacy-jest-resolver.cjs +112 -0
  230. package/src/quality_of_service/prometheus_client.ts +113 -0
  231. package/src/shared/cross_chain_test_harness.ts +38 -38
  232. package/src/shared/gas_portal_test_harness.ts +22 -12
  233. package/src/shared/index.ts +1 -0
  234. package/src/shared/jest_setup.ts +51 -1
  235. package/src/shared/mock_state_view.ts +188 -0
  236. package/src/shared/submit-transactions.ts +11 -16
  237. package/src/shared/uniswap_l1_l2.ts +91 -73
  238. package/src/shared/wait_for_l1_to_l2_message.ts +23 -0
  239. package/src/simulators/lending_simulator.ts +34 -16
  240. package/src/simulators/token_simulator.ts +6 -30
  241. package/src/spartan/setup_test_wallets.ts +184 -28
  242. package/src/spartan/tx_metrics.ts +329 -25
  243. package/src/spartan/utils/bot.ts +188 -0
  244. package/src/spartan/utils/chaos.ts +253 -0
  245. package/src/spartan/utils/clients.ts +100 -0
  246. package/src/spartan/utils/config.ts +29 -0
  247. package/src/spartan/utils/health.ts +255 -0
  248. package/src/spartan/utils/helm.ts +84 -0
  249. package/src/spartan/utils/index.ts +71 -0
  250. package/src/spartan/utils/k8s.ts +535 -0
  251. package/src/spartan/utils/nodes.ts +543 -0
  252. package/src/spartan/utils/pod_logs.ts +99 -0
  253. package/src/spartan/utils/scripts.ts +99 -0
  254. package/src/spartan/utils.ts +1 -1158
  255. package/src/test-wallet/test_wallet.ts +376 -0
  256. package/src/test-wallet/utils.ts +108 -0
  257. package/src/test-wallet/wallet_worker_script.ts +60 -0
  258. package/src/test-wallet/worker_wallet.ts +218 -0
  259. package/src/test-wallet/worker_wallet_schema.ts +13 -0
  260. package/dest/fixtures/snapshot_manager.d.ts +0 -93
  261. package/dest/fixtures/snapshot_manager.d.ts.map +0 -1
  262. package/dest/fixtures/snapshot_manager.js +0 -488
  263. package/src/fixtures/snapshot_manager.ts +0 -646
@@ -11,18 +11,22 @@ import type { DeployAztecL1ContractsReturnType } from '@aztec/ethereum/deploy-az
11
11
  import { deployL1Contract } from '@aztec/ethereum/deploy-l1-contract';
12
12
  import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
13
13
  import { extractEvent } from '@aztec/ethereum/utils';
14
- import { CheckpointNumber, EpochNumber } from '@aztec/foundation/branded-types';
14
+ import { EpochNumber } from '@aztec/foundation/branded-types';
15
15
  import { sha256ToField } from '@aztec/foundation/crypto/sha256';
16
16
  import { InboxAbi, UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-artifacts';
17
17
  import { UniswapContract } from '@aztec/noir-contracts.js/Uniswap';
18
18
  import { computeL2ToL1MessageHash } from '@aztec/stdlib/hash';
19
19
  import { computeL2ToL1MembershipWitness } from '@aztec/stdlib/messaging';
20
- import type { TestWallet } from '@aztec/test-wallet/server';
21
20
 
22
21
  import { jest } from '@jest/globals';
23
22
  import { type GetContractReturnType, getContract, parseEther, toFunctionSelector } from 'viem';
24
23
 
25
- import { type EndToEndContext, ensureAccountContractsPublished } from '../fixtures/utils.js';
24
+ import {
25
+ type EndToEndContext,
26
+ ensureAccountContractsPublished,
27
+ ensureAuthRegistryPublished,
28
+ } from '../fixtures/utils.js';
29
+ import type { TestWallet } from '../test-wallet/test_wallet.js';
26
30
  import { CrossChainTestHarness } from './cross_chain_test_harness.js';
27
31
 
28
32
  // PSA: This tests works on forked mainnet. There is a dump of the data in `dumpedState` such that we
@@ -32,7 +36,7 @@ import { CrossChainTestHarness } from './cross_chain_test_harness.js';
32
36
  // anvil --fork-url https://mainnet.infura.io/v3/9928b52099854248b3a096be07a6b23c --fork-block-number 17514288 --chain-id 31337
33
37
  // For CI, this is configured in `run_tests.sh` and `docker-compose-images.yml`
34
38
 
35
- const TIMEOUT = 360_000;
39
+ const TIMEOUT = 15 * 60 * 1000;
36
40
 
37
41
  export const uniswapL1L2TestSuite = (
38
42
  setup: () => Promise<EndToEndContext>,
@@ -84,7 +88,7 @@ export const uniswapL1L2TestSuite = (
84
88
 
85
89
  l1Client = deployL1ContractsValues.l1Client;
86
90
 
87
- t.watcher?.setIsMarkingAsProven(false);
91
+ t.watcher.setIsMarkingAsProven(false);
88
92
 
89
93
  if (Number(await l1Client.getBlockNumber()) < expectedForkBlockNumber) {
90
94
  throw new Error('This test must be run on a fork of mainnet with the expected fork block');
@@ -98,6 +102,7 @@ export const uniswapL1L2TestSuite = (
98
102
  ownerEthAddress = EthAddress.fromString((await l1Client.getAddresses())[0]);
99
103
 
100
104
  await ensureAccountContractsPublished(wallet, [ownerAddress, sponsorAddress]);
105
+ await ensureAuthRegistryPublished(wallet, ownerAddress);
101
106
 
102
107
  logger.info('Deploying DAI Portal, initializing and deploying l2 contract...');
103
108
  daiCrossChainHarness = await CrossChainTestHarness.new(
@@ -130,9 +135,9 @@ export const uniswapL1L2TestSuite = (
130
135
  client: l1Client,
131
136
  });
132
137
  // deploy l2 uniswap contract and attach to portal
133
- uniswapL2Contract = await UniswapContract.deploy(wallet, uniswapPortalAddress)
134
- .send({ from: ownerAddress })
135
- .deployed();
138
+ ({ contract: uniswapL2Contract } = await UniswapContract.deploy(wallet, uniswapPortalAddress).send({
139
+ from: ownerAddress,
140
+ }));
136
141
 
137
142
  const registryAddress = (await aztecNode.getNodeInfo()).l1ContractAddresses.registryAddress;
138
143
 
@@ -154,7 +159,6 @@ export const uniswapL1L2TestSuite = (
154
159
  await cleanup();
155
160
  });
156
161
 
157
- // docs:start:uniswap_private
158
162
  it('should uniswap trade on L1 from L2 funds privately (swaps WETH -> DAI)', async () => {
159
163
  const wethL1BeforeBalance = await wethCrossChainHarness.getL1BalanceOf(ownerEthAddress);
160
164
 
@@ -197,7 +201,7 @@ export const uniswapL1L2TestSuite = (
197
201
  logger.info('Withdrawing weth to L1 and sending message to swap to dai');
198
202
  const [secretForDepositingSwappedDai, secretHashForDepositingSwappedDai] = await generateClaimSecret();
199
203
 
200
- const l2UniswapInteractionReceipt = await uniswapL2Contract.methods
204
+ const { receipt: l2UniswapInteractionReceipt } = await uniswapL2Contract.methods
201
205
  .swap_private(
202
206
  wethCrossChainHarness.l2Token.address,
203
207
  wethCrossChainHarness.l2Bridge.address,
@@ -209,8 +213,7 @@ export const uniswapL1L2TestSuite = (
209
213
  secretHashForDepositingSwappedDai,
210
214
  ownerEthAddress,
211
215
  )
212
- .send({ from: ownerAddress, authWitnesses: [transferToPublicAuhtwit] })
213
- .wait();
216
+ .send({ from: ownerAddress, authWitnesses: [transferToPublicAuhtwit] });
214
217
 
215
218
  const swapPrivateFunction = 'swap_private(address,uint256,uint24,address,uint256,bytes32,address)';
216
219
  const swapPrivateContent = sha256ToField([
@@ -252,10 +255,13 @@ export const uniswapL1L2TestSuite = (
252
255
  // ensure that uniswap contract didn't eat the funds.
253
256
  await wethCrossChainHarness.expectPublicBalanceOnL2(uniswapL2Contract.address, 0n);
254
257
 
255
- // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch.
256
- const checkpointNumber = CheckpointNumber.fromBlockNumber(l2UniswapInteractionReceipt.blockNumber!);
257
- const epoch = await rollup.getEpochNumberForCheckpoint(checkpointNumber);
258
- await cheatCodes.rollup.advanceToEpoch(EpochNumber(epoch + 1));
258
+ // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch
259
+ // before we can ask the witness helper for a covering root.
260
+ const minedReceipt = await aztecNode.getTxReceipt(l2UniswapInteractionReceipt.txHash);
261
+ if (minedReceipt.epochNumber === undefined) {
262
+ throw new Error('L2 Uniswap interaction tx is not yet in an epoch');
263
+ }
264
+ await cheatCodes.rollup.advanceToEpoch(EpochNumber(minedReceipt.epochNumber + 1));
259
265
  await waitForProven(aztecNode, l2UniswapInteractionReceipt, { provenTimeout: 300 });
260
266
 
261
267
  // 5. Consume L2 to L1 message by calling uniswapPortal.swap_private()
@@ -263,17 +269,21 @@ export const uniswapL1L2TestSuite = (
263
269
  const daiL1BalanceOfPortalBeforeSwap = await daiCrossChainHarness.getL1BalanceOf(
264
270
  daiCrossChainHarness.tokenPortalAddress,
265
271
  );
266
- const swapResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, swapPrivateLeaf);
267
- const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, withdrawLeaf);
272
+ // Fetch the outbox roots once and share them between the two witnesses in this epoch.
273
+ const epochRoots = await wethCrossChainHarness.outboxContract.getRoots(minedReceipt.epochNumber);
274
+ const swapResult = (await computeL2ToL1MembershipWitness(aztecNode, epochRoots, swapPrivateLeaf, minedReceipt))!;
275
+ const { epochNumber: epoch, numCheckpointsInEpoch } = swapResult;
276
+ const withdrawResult = (await computeL2ToL1MembershipWitness(aztecNode, epochRoots, withdrawLeaf, minedReceipt))!;
268
277
 
269
- const swapPrivateL2MessageIndex = swapResult!.leafIndex;
270
- const swapPrivateSiblingPath = swapResult!.siblingPath;
278
+ const swapPrivateL2MessageIndex = swapResult.leafIndex;
279
+ const swapPrivateSiblingPath = swapResult.siblingPath;
271
280
 
272
- const withdrawL2MessageIndex = withdrawResult!.leafIndex;
273
- const withdrawSiblingPath = withdrawResult!.siblingPath;
281
+ const withdrawL2MessageIndex = withdrawResult.leafIndex;
282
+ const withdrawSiblingPath = withdrawResult.siblingPath;
274
283
 
275
284
  const withdrawMessageMetadata = {
276
285
  _epoch: BigInt(epoch),
286
+ _numCheckpointsInEpoch: BigInt(withdrawResult.numCheckpointsInEpoch),
277
287
  _leafIndex: BigInt(withdrawL2MessageIndex),
278
288
  _path: withdrawSiblingPath
279
289
  .toBufferArray()
@@ -282,6 +292,7 @@ export const uniswapL1L2TestSuite = (
282
292
 
283
293
  const swapPrivateMessageMetadata = {
284
294
  _epoch: BigInt(epoch),
295
+ _numCheckpointsInEpoch: BigInt(numCheckpointsInEpoch),
285
296
  _leafIndex: BigInt(swapPrivateL2MessageIndex),
286
297
  _path: swapPrivateSiblingPath
287
298
  .toBufferArray()
@@ -339,10 +350,8 @@ export const uniswapL1L2TestSuite = (
339
350
  logger.info('WETH balance after swap : ', wethL2BalanceAfterSwap.toString());
340
351
  logger.info('DAI balance after swap : ', daiL2BalanceAfterSwap.toString());
341
352
  });
342
- // docs:end:uniswap_private
343
353
 
344
354
  // TODO(#7463): reenable look into this failure https://github.com/AztecProtocol/aztec-packages/actions/runs/9912612912/job/27388320150?pr=7462
345
- // // docs:start:uniswap_public
346
355
  // it('should uniswap trade on L1 from L2 funds publicly (swaps WETH -> DAI)', async () => {
347
356
  // const wethL1BeforeBalance = await wethCrossChainHarness.getL1BalanceOf(ownerEthAddress);
348
357
 
@@ -428,10 +437,10 @@ export const uniswapL1L2TestSuite = (
428
437
  // ownerEthAddress,
429
438
  // nonceForSwap,
430
439
  // );
431
- // await ownerWallet.setPublicAuthWit({ caller: sponsorAddress, action }, true).send().wait();
440
+ // await ownerWallet.setPublicAuthWit({ caller: sponsorAddress, action }, true).send();
432
441
 
433
442
  // // 4.2 Call swap_public from user2 on behalf of owner
434
- // const uniswapL2Interaction = await action.send().wait();
443
+ // const uniswapL2Interaction = await action.send();
435
444
 
436
445
  // const swapPublicContent = sha256ToField([
437
446
  // Buffer.from(
@@ -575,7 +584,6 @@ export const uniswapL1L2TestSuite = (
575
584
  // logger.info('WETH balance after swap : ', wethL2BalanceAfterSwap.toString());
576
585
  // logger.info('DAI balance after swap : ', daiL2BalanceAfterSwap.toString());
577
586
  // });
578
- // // docs:end:uniswap_public
579
587
 
580
588
  // Edge cases for the private flow:
581
589
  // note - tests for uniswapPortal.sol and minting asset on L2 are covered in other tests.
@@ -649,8 +657,7 @@ export const uniswapL1L2TestSuite = (
649
657
  Fr.random(),
650
658
  ownerEthAddress,
651
659
  )
652
- .send({ from: ownerAddress, authWitnesses: [transferToPublicAuthwith] })
653
- .wait(),
660
+ .send({ from: ownerAddress, authWitnesses: [transferToPublicAuthwith] }),
654
661
  ).rejects.toThrow('Assertion failed: input_asset address is not the same as seen in the bridge contract');
655
662
  });
656
663
 
@@ -675,7 +682,7 @@ export const uniswapL1L2TestSuite = (
675
682
  },
676
683
  true,
677
684
  );
678
- await validateActionInteraction.send().wait();
685
+ await validateActionInteraction.send();
679
686
 
680
687
  // No approval to call `swap` but should work even without it:
681
688
  const [_, secretHashForDepositingSwappedDai] = await generateClaimSecret();
@@ -694,8 +701,7 @@ export const uniswapL1L2TestSuite = (
694
701
  ownerEthAddress,
695
702
  Fr.ZERO, // nonce for swap -> doesn't matter
696
703
  )
697
- .send({ from: ownerAddress })
698
- .wait();
704
+ .send({ from: ownerAddress });
699
705
  // check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
700
706
  await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
701
707
  });
@@ -725,7 +731,7 @@ export const uniswapL1L2TestSuite = (
725
731
  { caller: approvedUser, action },
726
732
  true,
727
733
  );
728
- await validateActionInteraction.send().wait();
734
+ await validateActionInteraction.send();
729
735
 
730
736
  await expect(action.simulate({ from: sponsorAddress })).rejects.toThrow(/unauthorized/);
731
737
  });
@@ -747,7 +753,7 @@ export const uniswapL1L2TestSuite = (
747
753
  },
748
754
  true,
749
755
  );
750
- await validateActionInteraction.send().wait();
756
+ await validateActionInteraction.send();
751
757
 
752
758
  await expect(
753
759
  uniswapL2Contract.methods
@@ -792,7 +798,7 @@ export const uniswapL1L2TestSuite = (
792
798
  logger.info('Withdrawing weth to L1 and sending message to swap to dai');
793
799
 
794
800
  const [, secretHashForDepositingSwappedDai] = await generateClaimSecret();
795
- const withdrawReceipt = await uniswapL2Contract.methods
801
+ const { receipt: withdrawReceipt } = await uniswapL2Contract.methods
796
802
  .swap_private(
797
803
  wethCrossChainHarness.l2Token.address,
798
804
  wethCrossChainHarness.l2Bridge.address,
@@ -804,8 +810,7 @@ export const uniswapL1L2TestSuite = (
804
810
  secretHashForDepositingSwappedDai,
805
811
  ownerEthAddress,
806
812
  )
807
- .send({ from: ownerAddress, authWitnesses: [transferToPublicAuhtwit] })
808
- .wait();
813
+ .send({ from: ownerAddress, authWitnesses: [transferToPublicAuhtwit] });
809
814
 
810
815
  const swapPrivateContent = sha256ToField([
811
816
  Buffer.from(
@@ -844,20 +849,33 @@ export const uniswapL1L2TestSuite = (
844
849
  chainId: new Fr(l1Client.chain.id),
845
850
  });
846
851
 
847
- const epoch = await rollup.getEpochNumberForCheckpoint(
848
- CheckpointNumber.fromBlockNumber(withdrawReceipt.blockNumber!),
849
- );
850
- const swapResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, swapPrivateLeaf);
851
- const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, withdrawLeaf);
852
+ // ensure that user's funds were burnt
853
+ await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
854
+
855
+ // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch
856
+ // before we can ask the witness helper for a covering root.
857
+ const minedReceipt = await aztecNode.getTxReceipt(withdrawReceipt.txHash);
858
+ if (minedReceipt.epochNumber === undefined) {
859
+ throw new Error('Withdraw tx is not yet in an epoch');
860
+ }
861
+ await cheatCodes.rollup.advanceToEpoch(EpochNumber(minedReceipt.epochNumber + 1));
862
+ await waitForProven(aztecNode, withdrawReceipt, { provenTimeout: 300 });
852
863
 
853
- const swapPrivateL2MessageIndex = swapResult!.leafIndex;
854
- const swapPrivateSiblingPath = swapResult!.siblingPath;
864
+ // Fetch the outbox roots once and share them between the two witnesses in this epoch.
865
+ const epochRoots = await wethCrossChainHarness.outboxContract.getRoots(minedReceipt.epochNumber);
866
+ const swapResult = (await computeL2ToL1MembershipWitness(aztecNode, epochRoots, swapPrivateLeaf, minedReceipt))!;
867
+ const { epochNumber: epoch, numCheckpointsInEpoch } = swapResult;
868
+ const withdrawResult = (await computeL2ToL1MembershipWitness(aztecNode, epochRoots, withdrawLeaf, minedReceipt))!;
855
869
 
856
- const withdrawL2MessageIndex = withdrawResult!.leafIndex;
857
- const withdrawSiblingPath = withdrawResult!.siblingPath;
870
+ const swapPrivateL2MessageIndex = swapResult.leafIndex;
871
+ const swapPrivateSiblingPath = swapResult.siblingPath;
872
+
873
+ const withdrawL2MessageIndex = withdrawResult.leafIndex;
874
+ const withdrawSiblingPath = withdrawResult.siblingPath;
858
875
 
859
876
  const withdrawMessageMetadata = {
860
877
  _epoch: BigInt(epoch),
878
+ _numCheckpointsInEpoch: BigInt(withdrawResult.numCheckpointsInEpoch),
861
879
  _leafIndex: BigInt(withdrawL2MessageIndex),
862
880
  _path: withdrawSiblingPath
863
881
  .toBufferArray()
@@ -866,19 +884,13 @@ export const uniswapL1L2TestSuite = (
866
884
 
867
885
  const swapPrivateMessageMetadata = {
868
886
  _epoch: BigInt(epoch),
887
+ _numCheckpointsInEpoch: BigInt(numCheckpointsInEpoch),
869
888
  _leafIndex: BigInt(swapPrivateL2MessageIndex),
870
889
  _path: swapPrivateSiblingPath
871
890
  .toBufferArray()
872
891
  .map((buf: Buffer) => `0x${buf.toString('hex')}`) as readonly `0x${string}`[],
873
892
  };
874
893
 
875
- // ensure that user's funds were burnt
876
- await wethCrossChainHarness.expectPrivateBalanceOnL2(ownerAddress, wethL2BalanceBeforeSwap - wethAmountToBridge);
877
-
878
- // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch.
879
- await cheatCodes.rollup.advanceToEpoch(EpochNumber(epoch + 1));
880
- await waitForProven(aztecNode, withdrawReceipt, { provenTimeout: 300 });
881
-
882
894
  // On L1 call swap_public!
883
895
  logger.info('call swap_public on L1');
884
896
  const swapArgs = [
@@ -918,11 +930,11 @@ export const uniswapL1L2TestSuite = (
918
930
  },
919
931
  true,
920
932
  );
921
- await validateActionInteraction.send().wait();
933
+ await validateActionInteraction.send();
922
934
 
923
935
  // Call swap_public on L2
924
936
  const secretHashForDepositingSwappedDai = Fr.random();
925
- const withdrawReceipt = await uniswapL2Contract.methods
937
+ const { receipt: withdrawReceipt } = await uniswapL2Contract.methods
926
938
  .swap_public(
927
939
  ownerAddress,
928
940
  wethCrossChainHarness.l2Bridge.address,
@@ -936,8 +948,7 @@ export const uniswapL1L2TestSuite = (
936
948
  ownerEthAddress,
937
949
  Fr.ZERO,
938
950
  )
939
- .send({ from: ownerAddress })
940
- .wait();
951
+ .send({ from: ownerAddress });
941
952
 
942
953
  const swapPublicContent = sha256ToField([
943
954
  Buffer.from(
@@ -979,20 +990,33 @@ export const uniswapL1L2TestSuite = (
979
990
  chainId: new Fr(l1Client.chain.id),
980
991
  });
981
992
 
982
- const epoch = await rollup.getEpochNumberForCheckpoint(
983
- CheckpointNumber.fromBlockNumber(withdrawReceipt.blockNumber!),
984
- );
985
- const swapResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, swapPublicLeaf);
986
- const withdrawResult = await computeL2ToL1MembershipWitness(aztecNode, epoch, withdrawLeaf);
993
+ // check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
994
+ await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
995
+
996
+ // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch
997
+ // before we can ask the witness helper for a covering root.
998
+ const minedReceipt = await aztecNode.getTxReceipt(withdrawReceipt.txHash);
999
+ if (minedReceipt.epochNumber === undefined) {
1000
+ throw new Error('Withdraw tx is not yet in an epoch');
1001
+ }
1002
+ await cheatCodes.rollup.advanceToEpoch(EpochNumber(minedReceipt.epochNumber + 1));
1003
+ await waitForProven(aztecNode, withdrawReceipt, { provenTimeout: 300 });
987
1004
 
988
- const swapPublicL2MessageIndex = swapResult!.leafIndex;
989
- const swapPublicSiblingPath = swapResult!.siblingPath;
1005
+ // Fetch the outbox roots once and share them between the two witnesses in this epoch.
1006
+ const epochRoots = await wethCrossChainHarness.outboxContract.getRoots(minedReceipt.epochNumber);
1007
+ const swapResult = (await computeL2ToL1MembershipWitness(aztecNode, epochRoots, swapPublicLeaf, minedReceipt))!;
1008
+ const { epochNumber: epoch, numCheckpointsInEpoch } = swapResult;
1009
+ const withdrawResult = (await computeL2ToL1MembershipWitness(aztecNode, epochRoots, withdrawLeaf, minedReceipt))!;
990
1010
 
991
- const withdrawL2MessageIndex = withdrawResult!.leafIndex;
992
- const withdrawSiblingPath = withdrawResult!.siblingPath;
1011
+ const swapPublicL2MessageIndex = swapResult.leafIndex;
1012
+ const swapPublicSiblingPath = swapResult.siblingPath;
1013
+
1014
+ const withdrawL2MessageIndex = withdrawResult.leafIndex;
1015
+ const withdrawSiblingPath = withdrawResult.siblingPath;
993
1016
 
994
1017
  const withdrawMessageMetadata = {
995
1018
  _epoch: BigInt(epoch),
1019
+ _numCheckpointsInEpoch: BigInt(withdrawResult.numCheckpointsInEpoch),
996
1020
  _leafIndex: BigInt(withdrawL2MessageIndex),
997
1021
  _path: withdrawSiblingPath
998
1022
  .toBufferArray()
@@ -1001,19 +1025,13 @@ export const uniswapL1L2TestSuite = (
1001
1025
 
1002
1026
  const swapPublicMessageMetadata = {
1003
1027
  _epoch: BigInt(epoch),
1028
+ _numCheckpointsInEpoch: BigInt(numCheckpointsInEpoch),
1004
1029
  _leafIndex: BigInt(swapPublicL2MessageIndex),
1005
1030
  _path: swapPublicSiblingPath
1006
1031
  .toBufferArray()
1007
1032
  .map((buf: Buffer) => `0x${buf.toString('hex')}`) as readonly `0x${string}`[],
1008
1033
  };
1009
1034
 
1010
- // check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!)
1011
- await wethCrossChainHarness.expectPublicBalanceOnL2(ownerAddress, 0n);
1012
-
1013
- // Since the outbox is only consumable when the epoch is proven, we need to advance to the next epoch.
1014
- await cheatCodes.rollup.advanceToEpoch(EpochNumber(epoch + 1));
1015
- await waitForProven(aztecNode, withdrawReceipt, { provenTimeout: 300 });
1016
-
1017
1035
  // Call swap_private on L1
1018
1036
  logger.info('Execute withdraw and swap on the uniswapPortal!');
1019
1037
 
@@ -0,0 +1,23 @@
1
+ import type { Fr } from '@aztec/aztec.js/fields';
2
+ import type { AztecNode } from '@aztec/aztec.js/node';
3
+ import { retryUntil } from '@aztec/foundation/retry';
4
+
5
+ /**
6
+ * Waits until the archiver has seen the L1 to L2 message and indexed it. Unlike
7
+ * {@link waitForL1ToL2MessageReady} from `@aztec/aztec.js/messaging`, this does not
8
+ * require the L2 chain to have advanced to the message's checkpoint — it only confirms
9
+ * the message has been picked up from L1. Use this in tests that explicitly produce L2
10
+ * blocks afterwards to make the message consumable.
11
+ */
12
+ export function waitForL1ToL2MessageSeen(
13
+ node: Pick<AztecNode, 'getL1ToL2MessageCheckpoint'>,
14
+ l1ToL2MessageHash: Fr,
15
+ opts: { timeoutSeconds: number },
16
+ ) {
17
+ return retryUntil(
18
+ async () => (await node.getL1ToL2MessageCheckpoint(l1ToL2MessageHash)) !== undefined,
19
+ `L1 to L2 message ${l1ToL2MessageHash.toString()} seen`,
20
+ opts.timeoutSeconds,
21
+ 1,
22
+ );
23
+ }
@@ -4,9 +4,10 @@ import { Fr } from '@aztec/aztec.js/fields';
4
4
  import { CheatCodes } from '@aztec/aztec/testing';
5
5
  import type { RollupContract } from '@aztec/ethereum/contracts';
6
6
  import { SlotNumber } from '@aztec/foundation/branded-types';
7
- import { pedersenHash } from '@aztec/foundation/crypto/pedersen';
7
+ import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
8
8
  import type { TestDateProvider } from '@aztec/foundation/timer';
9
9
  import type { LendingContract } from '@aztec/noir-contracts.js/Lending';
10
+ import type { AztecNode, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
10
11
 
11
12
  import type { TokenSimulator } from './token_simulator.js';
12
13
 
@@ -29,7 +30,7 @@ export class LendingAccount {
29
30
  * @returns Key in public space
30
31
  */
31
32
  public key() {
32
- return pedersenHash([this.address, this.secret]);
33
+ return poseidon2Hash([this.address, this.secret]);
33
34
  }
34
35
  }
35
36
 
@@ -92,30 +93,45 @@ export class LendingSimulator {
92
93
  public stableCoin: TokenSimulator,
93
94
  ) {}
94
95
 
95
- async prepare() {
96
+ prepare() {
96
97
  this.accumulator = BASE;
97
- const slot = await this.rollup.getSlotAt(BigInt(await this.cc.eth.timestamp()) + BigInt(this.ethereumSlotDuration));
98
- this.time = Number(await this.rollup.getTimestampForSlot(slot));
98
+ this.time = 0;
99
99
  }
100
100
 
101
- async progressSlots(diff: number, dateProvider?: TestDateProvider) {
101
+ /**
102
+ * Advances the simulator's accumulator and clock to match a block timestamp observed on chain.
103
+ * Call this BEFORE applying any accumulator-sensitive mutation (borrow/repay) so the mutation
104
+ * sees the same accumulator as the contract did during execution.
105
+ */
106
+ observeBlockTimestamp(ts: number) {
107
+ const diff = ts - this.time;
108
+ if (diff > 0) {
109
+ this.accumulator = muldivDown(this.accumulator, computeMultiplier(this.rate, BigInt(diff)), BASE);
110
+ }
111
+ this.time = ts;
112
+ }
113
+
114
+ async progressSlots(diff: number, _dateProvider?: TestDateProvider, node?: AztecNode & AztecNodeDebug) {
102
115
  if (diff <= 1) {
103
116
  return;
104
117
  }
105
118
 
106
- const slot = await this.rollup.getSlotAt(BigInt(await this.cc.eth.timestamp()));
119
+ const slot = await this.rollup.getSlotAt(BigInt(await this.cc.eth.lastBlockTimestamp()));
107
120
  const targetSlot = SlotNumber(slot + diff);
108
121
  const ts = Number(await this.rollup.getTimestampForSlot(targetSlot));
109
- const timeDiff = ts - this.time;
110
- this.time = ts;
111
122
 
112
- // Mine ethereum blocks such that the next block will be in a new slot
113
- await this.cc.eth.warp(this.time - this.ethereumSlotDuration);
114
- if (dateProvider) {
115
- dateProvider.setTime(this.time * 1000);
123
+ // Queue-aware warp under AutomineSequencer: atomic warp + mineBlock that advances L2 time to the
124
+ // target slot. The cheat code routes through the AutomineSequencer queue when one is installed,
125
+ // and otherwise falls back to a manual warp + mineBlock loop.
126
+ if (node) {
127
+ await this.cc.warpL2TimeAtLeastTo(node, ts);
128
+ } else {
129
+ await this.cc.eth.warp(ts - this.ethereumSlotDuration);
116
130
  }
131
+
132
+ // Mark the latest checkpoint as proven so the rollup does not reorg pending checkpoints when
133
+ // time jumps far enough forward to cross an unproven epoch boundary.
117
134
  await this.cc.rollup.markAsProven(await this.rollup.getCheckpointNumber());
118
- this.accumulator = muldivDown(this.accumulator, computeMultiplier(this.rate, BigInt(timeDiff)), BASE);
119
135
  }
120
136
 
121
137
  depositPrivate(from: AztecAddress, onBehalfOf: Fr, amount: bigint) {
@@ -186,14 +202,16 @@ export class LendingSimulator {
186
202
 
187
203
  expect(this.borrowed).toEqual(this.stableCoin.totalSupply - this.mintedOutside);
188
204
 
189
- const asset = await this.lendingContract.methods.get_asset(0).simulate({ from: this.account.address });
205
+ const { result: asset } = await this.lendingContract.methods.get_asset(0).simulate({ from: this.account.address });
190
206
 
191
207
  const interestAccumulator = asset['interest_accumulator'];
192
208
  expect(interestAccumulator).toEqual(this.accumulator);
193
209
  expect(asset['last_updated_ts']).toEqual(BigInt(this.time));
194
210
 
195
211
  for (const key of [this.account.address, AztecAddress.fromField(await this.account.key())]) {
196
- const privatePos = await this.lendingContract.methods.get_position(key).simulate({ from: this.account.address });
212
+ const { result: privatePos } = await this.lendingContract.methods
213
+ .get_position(key)
214
+ .simulate({ from: this.account.address });
197
215
  expect(new Fr(privatePos['collateral'])).toEqual(this.collateral[key.toString()] ?? Fr.ZERO);
198
216
  expect(new Fr(privatePos['static_debt'])).toEqual(this.staticDebt[key.toString()] ?? Fr.ZERO);
199
217
  expect(privatePos['debt']).toEqual(
@@ -109,7 +109,9 @@ export class TokenSimulator {
109
109
  await Promise.all(
110
110
  chunk(calls, 5).map(batch => new BatchCall(this.defaultWallet, batch).simulate({ from: this.defaultAddress })),
111
111
  )
112
- ).flat();
112
+ )
113
+ .flatMap(r => r.result)
114
+ .map(r => r.result);
113
115
  expect(results[0]).toEqual(this.totalSupply);
114
116
 
115
117
  // Check that all our balances match
@@ -119,39 +121,13 @@ export class TokenSimulator {
119
121
  }
120
122
 
121
123
  async checkPrivate() {
122
- // Private calls
123
- const defaultLookups = [];
124
- const nonDefaultLookups = [];
125
-
126
124
  for (const address of this.accounts) {
127
- if (this.lookupProvider.has(address.toString())) {
128
- nonDefaultLookups.push(address);
129
- } else {
130
- defaultLookups.push(address);
131
- }
132
- }
133
-
134
- const defaultCalls = defaultLookups.map(address => this.token.methods.balance_of_private(address));
135
- const results = (
136
- await Promise.all(
137
- chunk(defaultCalls, 4).map(batch =>
138
- new BatchCall(this.defaultWallet, batch).simulate({ from: this.defaultAddress }),
139
- ),
140
- )
141
- ).flat();
142
- for (let i = 0; i < defaultLookups.length; i++) {
143
- expect(results[i]).toEqual(this.balanceOfPrivate(defaultLookups[i]));
144
- }
145
-
146
- // We are just running individual calls for the non-default lookups
147
- // @todo We should also batch these
148
- for (const address of nonDefaultLookups) {
149
125
  const wallet = this.lookupProvider.get(address.toString());
150
126
  const asset = wallet ? this.token.withWallet(wallet) : this.token;
151
127
 
152
- const actualPrivateBalance = await asset.methods
153
- .balance_of_private({ address })
154
- .simulate({ from: this.defaultAddress });
128
+ const { result: actualPrivateBalance } = await asset.methods
129
+ .balance_of_private(address)
130
+ .simulate({ from: address });
155
131
  expect(actualPrivateBalance).toEqual(this.balanceOfPrivate(address));
156
132
  }
157
133
  }