@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.b655e406

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 (166) hide show
  1. package/dest/bench/client_flows/benchmark.d.ts +61 -0
  2. package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
  3. package/dest/bench/client_flows/benchmark.js +261 -0
  4. package/dest/bench/client_flows/client_flows_benchmark.d.ts +73 -0
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
  6. package/dest/bench/client_flows/client_flows_benchmark.js +311 -0
  7. package/dest/bench/client_flows/config.d.ts +14 -0
  8. package/dest/bench/client_flows/config.d.ts.map +1 -0
  9. package/dest/bench/client_flows/config.js +106 -0
  10. package/dest/bench/client_flows/data_extractor.d.ts +2 -0
  11. package/dest/bench/client_flows/data_extractor.d.ts.map +1 -0
  12. package/dest/bench/client_flows/data_extractor.js +99 -0
  13. package/dest/bench/utils.d.ts +10 -36
  14. package/dest/bench/utils.d.ts.map +1 -1
  15. package/dest/bench/utils.js +26 -66
  16. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +20 -12
  17. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  18. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +85 -57
  19. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +18 -24
  20. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  21. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +48 -69
  22. package/dest/e2e_deploy_contract/deploy_test.d.ts +14 -6
  23. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  24. package/dest/e2e_deploy_contract/deploy_test.js +13 -19
  25. package/dest/e2e_epochs/epochs_test.d.ts +58 -17
  26. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  27. package/dest/e2e_epochs/epochs_test.js +224 -43
  28. package/dest/e2e_fees/bridging_race.notest.d.ts +2 -0
  29. package/dest/e2e_fees/bridging_race.notest.d.ts.map +1 -0
  30. package/dest/e2e_fees/bridging_race.notest.js +63 -0
  31. package/dest/e2e_fees/fees_test.d.ts +20 -9
  32. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  33. package/dest/e2e_fees/fees_test.js +98 -107
  34. package/dest/e2e_l1_publisher/write_json.d.ts +10 -0
  35. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
  36. package/dest/e2e_l1_publisher/write_json.js +57 -0
  37. package/dest/e2e_multi_validator/utils.d.ts +12 -0
  38. package/dest/e2e_multi_validator/utils.d.ts.map +1 -0
  39. package/dest/e2e_multi_validator/utils.js +214 -0
  40. package/dest/e2e_nested_contract/nested_contract_test.d.ts +9 -6
  41. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  42. package/dest/e2e_nested_contract/nested_contract_test.js +22 -19
  43. package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
  44. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
  45. package/dest/e2e_p2p/inactivity_slash_test.js +135 -0
  46. package/dest/e2e_p2p/p2p_network.d.ts +69 -22
  47. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  48. package/dest/e2e_p2p/p2p_network.js +180 -129
  49. package/dest/e2e_p2p/shared.d.ts +41 -5
  50. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  51. package/dest/e2e_p2p/shared.js +163 -19
  52. package/dest/e2e_token_contract/token_contract_test.d.ts +11 -5
  53. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  54. package/dest/e2e_token_contract/token_contract_test.js +50 -26
  55. package/dest/{e2e_prover → fixtures}/e2e_prover_test.d.ts +14 -9
  56. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
  57. package/dest/{e2e_prover → fixtures}/e2e_prover_test.js +95 -100
  58. package/dest/fixtures/fixtures.d.ts +5 -6
  59. package/dest/fixtures/fixtures.d.ts.map +1 -1
  60. package/dest/fixtures/fixtures.js +4 -3
  61. package/dest/fixtures/get_acvm_config.d.ts +1 -1
  62. package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
  63. package/dest/fixtures/get_acvm_config.js +2 -14
  64. package/dest/fixtures/get_bb_config.d.ts +1 -1
  65. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  66. package/dest/fixtures/get_bb_config.js +10 -17
  67. package/dest/fixtures/l1_to_l2_messaging.d.ts +8 -5
  68. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  69. package/dest/fixtures/l1_to_l2_messaging.js +44 -18
  70. package/dest/fixtures/setup_l1_contracts.d.ts +3 -3
  71. package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
  72. package/dest/fixtures/setup_l1_contracts.js +4 -4
  73. package/dest/fixtures/setup_p2p_test.d.ts +14 -13
  74. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  75. package/dest/fixtures/setup_p2p_test.js +73 -21
  76. package/dest/fixtures/snapshot_manager.d.ts +15 -7
  77. package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
  78. package/dest/fixtures/snapshot_manager.js +147 -121
  79. package/dest/fixtures/token_utils.d.ts +6 -3
  80. package/dest/fixtures/token_utils.d.ts.map +1 -1
  81. package/dest/fixtures/token_utils.js +23 -10
  82. package/dest/fixtures/utils.d.ts +76 -37
  83. package/dest/fixtures/utils.d.ts.map +1 -1
  84. package/dest/fixtures/utils.js +464 -368
  85. package/dest/fixtures/web3signer.d.ts +5 -0
  86. package/dest/fixtures/web3signer.d.ts.map +1 -0
  87. package/dest/fixtures/web3signer.js +53 -0
  88. package/dest/quality_of_service/alert_checker.d.ts +1 -1
  89. package/dest/quality_of_service/alert_checker.d.ts.map +1 -1
  90. package/dest/shared/cross_chain_test_harness.d.ts +41 -25
  91. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  92. package/dest/shared/cross_chain_test_harness.js +104 -50
  93. package/dest/shared/gas_portal_test_harness.d.ts +32 -24
  94. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  95. package/dest/shared/gas_portal_test_harness.js +50 -29
  96. package/dest/shared/jest_setup.js +1 -1
  97. package/dest/shared/submit-transactions.d.ts +5 -3
  98. package/dest/shared/submit-transactions.d.ts.map +1 -1
  99. package/dest/shared/submit-transactions.js +8 -7
  100. package/dest/shared/uniswap_l1_l2.d.ts +13 -11
  101. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  102. package/dest/shared/uniswap_l1_l2.js +138 -108
  103. package/dest/simulators/lending_simulator.d.ts +6 -6
  104. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  105. package/dest/simulators/lending_simulator.js +13 -16
  106. package/dest/simulators/token_simulator.d.ts +5 -2
  107. package/dest/simulators/token_simulator.d.ts.map +1 -1
  108. package/dest/simulators/token_simulator.js +16 -13
  109. package/dest/spartan/setup_test_wallets.d.ts +23 -10
  110. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  111. package/dest/spartan/setup_test_wallets.js +167 -58
  112. package/dest/spartan/utils.d.ts +106 -303
  113. package/dest/spartan/utils.d.ts.map +1 -1
  114. package/dest/spartan/utils.js +434 -130
  115. package/package.json +61 -56
  116. package/src/bench/client_flows/benchmark.ts +341 -0
  117. package/src/bench/client_flows/client_flows_benchmark.ts +402 -0
  118. package/src/bench/client_flows/config.ts +61 -0
  119. package/src/bench/client_flows/data_extractor.ts +111 -0
  120. package/src/bench/utils.ts +22 -76
  121. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +80 -77
  122. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +63 -105
  123. package/src/e2e_deploy_contract/deploy_test.ts +23 -38
  124. package/src/e2e_epochs/epochs_test.ts +274 -54
  125. package/src/e2e_fees/bridging_race.notest.ts +80 -0
  126. package/src/e2e_fees/fees_test.ts +137 -136
  127. package/src/e2e_l1_publisher/write_json.ts +76 -0
  128. package/src/e2e_multi_validator/utils.ts +258 -0
  129. package/src/e2e_nested_contract/nested_contract_test.ts +27 -18
  130. package/src/e2e_p2p/inactivity_slash_test.ts +178 -0
  131. package/src/e2e_p2p/p2p_network.ts +272 -166
  132. package/src/e2e_p2p/shared.ts +244 -29
  133. package/src/e2e_token_contract/token_contract_test.ts +43 -39
  134. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  135. package/src/{e2e_prover → fixtures}/e2e_prover_test.ts +101 -145
  136. package/src/fixtures/fixtures.ts +4 -3
  137. package/src/fixtures/get_acvm_config.ts +3 -11
  138. package/src/fixtures/get_bb_config.ts +18 -13
  139. package/src/fixtures/l1_to_l2_messaging.ts +53 -23
  140. package/src/fixtures/setup_l1_contracts.ts +6 -7
  141. package/src/fixtures/setup_p2p_test.ts +112 -38
  142. package/src/fixtures/snapshot_manager.ts +187 -139
  143. package/src/fixtures/token_utils.ts +29 -12
  144. package/src/fixtures/utils.ts +552 -425
  145. package/src/fixtures/web3signer.ts +63 -0
  146. package/src/guides/up_quick_start.sh +6 -14
  147. package/src/quality_of_service/alert_checker.ts +1 -1
  148. package/src/shared/cross_chain_test_harness.ts +108 -79
  149. package/src/shared/gas_portal_test_harness.ts +58 -49
  150. package/src/shared/jest_setup.ts +1 -1
  151. package/src/shared/submit-transactions.ts +12 -8
  152. package/src/shared/uniswap_l1_l2.ts +173 -176
  153. package/src/simulators/lending_simulator.ts +12 -15
  154. package/src/simulators/token_simulator.ts +21 -13
  155. package/src/spartan/DEVELOP.md +121 -0
  156. package/src/spartan/setup_test_wallets.ts +215 -93
  157. package/src/spartan/utils.ts +490 -130
  158. package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
  159. package/dest/sample-dapp/connect.js +0 -12
  160. package/dest/sample-dapp/contracts.js +0 -10
  161. package/dest/sample-dapp/deploy.js +0 -35
  162. package/dest/sample-dapp/index.js +0 -98
  163. package/src/sample-dapp/connect.mjs +0 -16
  164. package/src/sample-dapp/contracts.mjs +0 -14
  165. package/src/sample-dapp/deploy.mjs +0 -40
  166. package/src/sample-dapp/index.mjs +0 -128
@@ -1,16 +1,12 @@
1
1
  import type { AztecNodeService } from '@aztec/aztec-node';
2
- import { type AztecNode, BatchCall, INITIAL_L2_BLOCK_NUM, type SentTx, type WaitOpts } from '@aztec/aztec.js';
3
- import { mean, stdDev, timesParallel } from '@aztec/foundation/collection';
4
- import { randomInt } from '@aztec/foundation/crypto';
5
- import { BenchmarkingContract } from '@aztec/noir-contracts.js/Benchmarking';
6
- import { type PXEService, type PXEServiceConfig, createPXEService } from '@aztec/pxe/server';
2
+ import { BatchCall, type SentTx, type WaitOpts } from '@aztec/aztec.js/contracts';
3
+ import { mean, stdDev, times } from '@aztec/foundation/collection';
4
+ import { BenchmarkingContract } from '@aztec/noir-test-contracts.js/Benchmarking';
7
5
  import type { MetricsType } from '@aztec/telemetry-client';
8
6
  import type { BenchmarkDataPoint, BenchmarkMetricsType, BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
9
7
 
10
- import { writeFileSync } from 'fs';
11
- import { mkdirpSync } from 'fs-extra';
12
- import { globSync } from 'glob';
13
- import { join } from 'path';
8
+ import { mkdirSync, writeFileSync } from 'fs';
9
+ import path from 'path';
14
10
 
15
11
  import { type EndToEndContext, type SetupOptions, setup } from '../fixtures/utils.js';
16
12
 
@@ -25,7 +21,8 @@ export async function benchmarkSetup(
25
21
  },
26
22
  ) {
27
23
  const context = await setup(1, { ...opts, telemetryConfig: { benchmark: true } });
28
- const contract = await BenchmarkingContract.deploy(context.wallet).send().deployed();
24
+ const defaultAccountAddress = context.accounts[0];
25
+ const contract = await BenchmarkingContract.deploy(context.wallet).send({ from: defaultAccountAddress }).deployed();
29
26
  context.logger.info(`Deployed benchmarking contract at ${contract.address}`);
30
27
  const sequencer = (context.aztecNode as AztecNodeService).getSequencer()!;
31
28
  const telemetry = context.telemetryClient! as BenchmarkTelemetryClient;
@@ -36,7 +33,11 @@ export async function benchmarkSetup(
36
33
  await telemetry.flush();
37
34
  const data = telemetry.getMeters();
38
35
  const formatted = formatMetricsForGithubBenchmarkAction(data, opts.metrics);
36
+ if (formatted.length === 0) {
37
+ throw new Error(`No benchmark data generated. Please review your test setup.`);
38
+ }
39
39
  const benchOutput = opts.benchOutput ?? process.env.BENCH_OUTPUT ?? 'bench.json';
40
+ mkdirSync(path.dirname(benchOutput), { recursive: true });
40
41
  writeFileSync(benchOutput, JSON.stringify(formatted));
41
42
  context.logger.info(`Wrote ${data.length} metrics to ${benchOutput}`);
42
43
  await origTeardown();
@@ -52,7 +53,7 @@ type MetricFilter = {
52
53
  };
53
54
 
54
55
  // See https://github.com/benchmark-action/github-action-benchmark/blob/e3c661617bc6aa55f26ae4457c737a55545a86a4/src/extract.ts#L659-L670
55
- type GithubActionBenchmarkResult = {
56
+ export type GithubActionBenchmarkResult = {
56
57
  name: string;
57
58
  value: number;
58
59
  range?: string;
@@ -91,30 +92,6 @@ function getMetricValues(points: BenchmarkDataPoint[]) {
91
92
  }
92
93
  }
93
94
 
94
- /**
95
- * Creates and returns a directory with the current job name and a random number.
96
- * @param index - Index to merge into the dir path.
97
- * @returns A path to a created dir.
98
- */
99
- export function makeDataDirectory(index: number) {
100
- const testName = expect.getState().currentTestName!.split(' ')[0].replaceAll('/', '_');
101
- const db = join('data', testName, index.toString(), `${randomInt(99)}`);
102
- mkdirpSync(db);
103
- return db;
104
- }
105
-
106
- /**
107
- * Returns the size in disk of a folder.
108
- * @param path - Path to the folder.
109
- * @returns Size in bytes.
110
- */
111
- export function getFolderSize(path: string): number {
112
- return globSync('**', { stat: true, cwd: path, nodir: true, withFileTypes: true }).reduce(
113
- (accum, file) => accum + (file as any as { /** Size */ size: number }).size,
114
- 0,
115
- );
116
- }
117
-
118
95
  /**
119
96
  * Returns a call to the benchmark contract. Each call has a private execution (account entrypoint),
120
97
  * a nested private call (create_note), a public call (increment_balance), and a nested public
@@ -126,22 +103,19 @@ export function getFolderSize(path: string): number {
126
103
  * @param heavyPublicCompute - Whether the transactions include heavy public compute (like a big sha256).
127
104
  * @returns A BatchCall instance.
128
105
  */
129
- export async function makeCall(
106
+ function makeCall(
130
107
  index: number,
131
108
  context: EndToEndContext,
132
109
  contract: BenchmarkingContract,
133
110
  heavyPublicCompute: boolean,
134
111
  ) {
135
- const owner = context.wallet.getAddress();
136
- const sender = owner;
112
+ const [owner] = context.accounts;
137
113
  if (heavyPublicCompute) {
138
- return new BatchCall(context.wallet, [
139
- await contract.methods.sha256_hash_2048(randomBytesAsBigInts(2048)).request(),
140
- ]);
114
+ return new BatchCall(context.wallet, [contract.methods.sha256_hash_1024(randomBytesAsBigInts(1024))]);
141
115
  } else {
142
116
  return new BatchCall(context.wallet, [
143
- await contract.methods.create_note(owner, sender, index + 1).request(),
144
- await contract.methods.increment_balance(owner, index + 1).request(),
117
+ contract.methods.create_note(owner, index + 1),
118
+ contract.methods.increment_balance(owner, index + 1),
145
119
  ]);
146
120
  }
147
121
  }
@@ -155,17 +129,17 @@ export async function makeCall(
155
129
  * @param heavyPublicCompute - Whether the transactions include heavy public compute (like a big sha256).
156
130
  * @returns Array of sent txs.
157
131
  */
158
- export async function sendTxs(
132
+ export function sendTxs(
159
133
  txCount: number,
160
134
  context: EndToEndContext,
161
135
  contract: BenchmarkingContract,
162
136
  heavyPublicCompute: boolean = false,
163
- ): Promise<SentTx[]> {
164
- const calls = await timesParallel(txCount, index => makeCall(index, context, contract, heavyPublicCompute));
137
+ ): SentTx[] {
138
+ const calls = times(txCount, index => makeCall(index, context, contract, heavyPublicCompute));
165
139
  context.logger.info(`Creating ${txCount} txs`);
166
- const provenTxs = await Promise.all(calls.map(call => call.prove({ skipPublicSimulation: true })));
140
+ const [from] = context.accounts;
167
141
  context.logger.info(`Sending ${txCount} txs`);
168
- return provenTxs.map(tx => tx.send());
142
+ return calls.map(call => call.send({ from }));
169
143
  }
170
144
 
171
145
  export async function waitTxs(txs: SentTx[], context: EndToEndContext, txWaitOpts?: WaitOpts) {
@@ -174,34 +148,6 @@ export async function waitTxs(txs: SentTx[], context: EndToEndContext, txWaitOpt
174
148
  context.logger.info(`All ${txs.length} txs have been mined`);
175
149
  }
176
150
 
177
- /**
178
- * Creates a new PXE
179
- * @param node - Node to connect the pxe to.
180
- * @param contract - Benchmark contract to add to the pxe.
181
- * @param startingBlock - First l2 block to process.
182
- * @returns The new PXE.
183
- */
184
- export async function createNewPXE(
185
- node: AztecNode,
186
- contract: BenchmarkingContract,
187
- startingBlock: number = INITIAL_L2_BLOCK_NUM,
188
- ): Promise<PXEService> {
189
- const l1Contracts = await node.getL1ContractAddresses();
190
- const { l1ChainId, protocolVersion } = await node.getNodeInfo();
191
- const pxeConfig = {
192
- l2StartingBlock: startingBlock,
193
- l2BlockPollingIntervalMS: 100,
194
- dataDirectory: undefined,
195
- dataStoreMapSizeKB: 1024 * 1024,
196
- l1Contracts,
197
- l1ChainId,
198
- version: protocolVersion,
199
- } as PXEServiceConfig;
200
- const pxe = await createPXEService(node, pxeConfig);
201
- await pxe.registerContract(contract);
202
- return pxe;
203
- }
204
-
205
151
  function randomBytesAsBigInts(length: number): bigint[] {
206
152
  return [...Array(length)].map(_ => BigInt(Math.floor(Math.random() * 255)));
207
153
  }
@@ -1,17 +1,15 @@
1
- import { getSchnorrWallet } from '@aztec/accounts/schnorr';
2
- import {
3
- type AccountWallet,
4
- type CompleteAddress,
5
- Fr,
6
- type Logger,
7
- type TxHash,
8
- computeSecretHash,
9
- createLogger,
10
- } from '@aztec/aztec.js';
11
- import { MAX_NOTE_HASHES_PER_TX } from '@aztec/constants';
12
- import { DocsExampleContract } from '@aztec/noir-contracts.js/DocsExample';
1
+ import { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import { computeSecretHash } from '@aztec/aztec.js/crypto';
3
+ import { Fr } from '@aztec/aztec.js/fields';
4
+ import { type Logger, createLogger } from '@aztec/aztec.js/log';
5
+ import type { AztecNode } from '@aztec/aztec.js/node';
6
+ import type { TxHash } from '@aztec/aztec.js/tx';
7
+ import type { CheatCodes } from '@aztec/aztec/testing';
13
8
  import type { TokenContract } from '@aztec/noir-contracts.js/Token';
14
9
  import { TokenBlacklistContract } from '@aztec/noir-contracts.js/TokenBlacklist';
10
+ import { InvalidAccountContract } from '@aztec/noir-test-contracts.js/InvalidAccount';
11
+ import type { SequencerClient } from '@aztec/sequencer-client';
12
+ import type { TestWallet } from '@aztec/test-wallet/server';
15
13
 
16
14
  import { jest } from '@jest/globals';
17
15
 
@@ -54,31 +52,34 @@ export class Role {
54
52
  }
55
53
 
56
54
  export class BlacklistTokenContractTest {
57
- // A low delay is really poor ux, but we need to keep it low for the tests to run "quickly".
58
55
  // This value MUST match the same value that we have in the contract
59
- static DELAY = 2;
56
+ static CHANGE_ROLES_DELAY = 86400;
60
57
 
61
58
  private snapshotManager: ISnapshotManager;
62
59
  logger: Logger;
63
- wallets: AccountWallet[] = [];
64
- accounts: CompleteAddress[] = [];
60
+ wallet!: TestWallet;
65
61
  asset!: TokenBlacklistContract;
66
62
  tokenSim!: TokenSimulator;
67
- badAccount!: DocsExampleContract;
63
+ badAccount!: InvalidAccountContract;
64
+ cheatCodes!: CheatCodes;
65
+ sequencer!: SequencerClient;
66
+ aztecNode!: AztecNode;
68
67
 
69
- admin!: AccountWallet;
70
- other!: AccountWallet;
71
- blacklisted!: AccountWallet;
68
+ adminAddress!: AztecAddress;
69
+ otherAddress!: AztecAddress;
70
+ blacklistedAddress!: AztecAddress;
72
71
 
73
72
  constructor(testName: string) {
74
73
  this.logger = createLogger(`e2e:e2e_blacklist_token_contract:${testName}`);
75
74
  this.snapshotManager = createSnapshotManager(`e2e_blacklist_token_contract/${testName}`, dataPath);
76
75
  }
77
76
 
78
- async mineBlocks(amount: number = BlacklistTokenContractTest.DELAY) {
79
- for (let i = 0; i < amount; ++i) {
80
- await this.asset.methods.get_roles(this.admin.getAddress()).send().wait();
81
- }
77
+ async crossTimestampOfChange() {
78
+ await this.cheatCodes.warpL2TimeAtLeastBy(
79
+ this.sequencer,
80
+ this.aztecNode,
81
+ BlacklistTokenContractTest.CHANGE_ROLES_DELAY,
82
+ );
82
83
  }
83
84
 
84
85
  /**
@@ -93,12 +94,15 @@ export class BlacklistTokenContractTest {
93
94
  await this.snapshotManager.snapshot(
94
95
  '3_accounts',
95
96
  deployAccounts(3, this.logger),
96
- async ({ deployedAccounts }, { pxe }) => {
97
- this.wallets = await Promise.all(deployedAccounts.map(a => getSchnorrWallet(pxe, a.address, a.signingKey)));
98
- this.admin = this.wallets[0];
99
- this.other = this.wallets[1];
100
- this.blacklisted = this.wallets[2];
101
- this.accounts = this.wallets.map(w => w.getCompleteAddress());
97
+ ({ deployedAccounts }, { cheatCodes, aztecNode, sequencer, wallet }) => {
98
+ this.cheatCodes = cheatCodes;
99
+ this.aztecNode = aztecNode;
100
+ this.sequencer = sequencer;
101
+ this.wallet = wallet;
102
+ this.adminAddress = deployedAccounts[0].address;
103
+ this.otherAddress = deployedAccounts[1].address;
104
+ this.blacklistedAddress = deployedAccounts[2].address;
105
+ return Promise.resolve();
102
106
  },
103
107
  );
104
108
 
@@ -108,36 +112,39 @@ export class BlacklistTokenContractTest {
108
112
  // Create the token contract state.
109
113
  // Move this account thing to addAccounts above?
110
114
  this.logger.verbose(`Public deploy accounts...`);
111
- await publicDeployAccounts(this.wallets[0], this.accounts.slice(0, 3));
115
+ await publicDeployAccounts(this.wallet, [this.adminAddress, this.otherAddress, this.blacklistedAddress]);
112
116
 
113
117
  this.logger.verbose(`Deploying TokenContract...`);
114
- this.asset = await TokenBlacklistContract.deploy(this.admin, this.admin.getAddress()).send().deployed();
118
+ this.asset = await TokenBlacklistContract.deploy(this.wallet, this.adminAddress)
119
+ .send({ from: this.adminAddress })
120
+ .deployed();
115
121
  this.logger.verbose(`Token deployed to ${this.asset.address}`);
116
122
 
117
123
  this.logger.verbose(`Deploying bad account...`);
118
- this.badAccount = await DocsExampleContract.deploy(this.wallets[0]).send().deployed();
124
+ this.badAccount = await InvalidAccountContract.deploy(this.wallet).send({ from: this.adminAddress }).deployed();
119
125
  this.logger.verbose(`Deployed to ${this.badAccount.address}.`);
120
126
 
121
- await this.mineBlocks();
127
+ await this.crossTimestampOfChange();
122
128
 
123
129
  return { tokenContractAddress: this.asset.address, badAccountAddress: this.badAccount.address };
124
130
  },
125
131
  async ({ tokenContractAddress, badAccountAddress }) => {
126
132
  // Restore the token contract state.
127
- this.asset = await TokenBlacklistContract.at(tokenContractAddress, this.wallets[0]);
133
+ this.asset = await TokenBlacklistContract.at(tokenContractAddress, this.wallet);
128
134
  this.logger.verbose(`Token contract address: ${this.asset.address}`);
129
135
 
130
136
  this.tokenSim = new TokenSimulator(
131
137
  this.asset as unknown as TokenContract,
132
- this.wallets[0],
138
+ this.wallet,
139
+ this.adminAddress,
133
140
  this.logger,
134
- this.accounts.map(a => a.address),
141
+ [this.adminAddress, this.otherAddress, this.blacklistedAddress],
135
142
  );
136
143
 
137
- this.badAccount = await DocsExampleContract.at(badAccountAddress, this.wallets[0]);
144
+ this.badAccount = await InvalidAccountContract.at(badAccountAddress, this.wallet);
138
145
  this.logger.verbose(`Bad account address: ${this.badAccount.address}`);
139
146
 
140
- expect(await this.asset.methods.get_roles(this.admin.getAddress()).simulate()).toEqual(
147
+ expect(await this.asset.methods.get_roles(this.adminAddress).simulate({ from: this.adminAddress })).toEqual(
141
148
  new Role().withAdmin().toNoirStruct(),
142
149
  );
143
150
  },
@@ -158,91 +165,87 @@ export class BlacklistTokenContractTest {
158
165
  await this.snapshotManager.teardown();
159
166
  }
160
167
 
161
- #toBoundedVec(arr: Fr[], maxLen: number) {
162
- return { len: arr.length, storage: arr.concat(new Array(maxLen - arr.length).fill(new Fr(0))) };
163
- }
164
-
165
168
  async addPendingShieldNoteToPXE(
166
169
  contract: TokenBlacklistContract,
167
- wallet: AccountWallet,
170
+ recipient: AztecAddress,
168
171
  amount: bigint,
169
172
  secretHash: Fr,
170
173
  txHash: TxHash,
171
174
  ) {
172
- const txEffects = await wallet.getTxEffect(txHash);
175
+ const txEffects = await this.aztecNode.getTxEffect(txHash);
173
176
  await contract.methods
174
177
  .deliver_transparent_note(
175
178
  contract.address,
176
179
  amount,
177
180
  secretHash,
178
181
  txHash.hash,
179
- this.#toBoundedVec(txEffects!.data.noteHashes, MAX_NOTE_HASHES_PER_TX),
182
+ txEffects!.data.noteHashes,
180
183
  txEffects!.data.nullifiers[0],
181
- wallet.getAddress(),
184
+ recipient,
182
185
  )
183
- .simulate();
186
+ .simulate({ from: recipient });
184
187
  }
185
188
 
186
189
  async applyMintSnapshot() {
187
190
  await this.snapshotManager.snapshot(
188
191
  'mint',
189
192
  async () => {
190
- const { asset, accounts, wallets } = this;
193
+ const { asset } = this;
191
194
  const amount = 10000n;
192
195
 
193
196
  const adminMinterRole = new Role().withAdmin().withMinter();
194
- await this.asset
195
- .withWallet(this.admin)
196
- .methods.update_roles(this.admin.getAddress(), adminMinterRole.toNoirStruct())
197
- .send()
197
+ await this.asset.methods
198
+ .update_roles(this.adminAddress, adminMinterRole.toNoirStruct())
199
+ .send({ from: this.adminAddress })
198
200
  .wait();
199
201
 
200
202
  const blacklistRole = new Role().withBlacklisted();
201
- await this.asset
202
- .withWallet(this.admin)
203
- .methods.update_roles(this.blacklisted.getAddress(), blacklistRole.toNoirStruct())
204
- .send()
203
+ await this.asset.methods
204
+ .update_roles(this.blacklistedAddress, blacklistRole.toNoirStruct())
205
+ .send({ from: this.adminAddress })
205
206
  .wait();
206
207
 
207
- await this.mineBlocks(); // This gets us past the block of change
208
+ await this.crossTimestampOfChange();
208
209
 
209
- expect(await this.asset.methods.get_roles(this.admin.getAddress()).simulate()).toEqual(
210
+ expect(await this.asset.methods.get_roles(this.adminAddress).simulate({ from: this.adminAddress })).toEqual(
210
211
  adminMinterRole.toNoirStruct(),
211
212
  );
212
213
 
213
214
  this.logger.verbose(`Minting ${amount} publicly...`);
214
- await asset.methods.mint_public(accounts[0].address, amount).send().wait();
215
+ await asset.methods.mint_public(this.adminAddress, amount).send({ from: this.adminAddress }).wait();
215
216
 
216
217
  this.logger.verbose(`Minting ${amount} privately...`);
217
218
  const secret = Fr.random();
218
219
  const secretHash = await computeSecretHash(secret);
219
- const receipt = await asset.methods.mint_private(amount, secretHash).send().wait();
220
+ const receipt = await asset.methods.mint_private(amount, secretHash).send({ from: this.adminAddress }).wait();
220
221
 
221
- await this.addPendingShieldNoteToPXE(asset, wallets[0], amount, secretHash, receipt.txHash);
222
- const txClaim = asset.methods.redeem_shield(accounts[0].address, amount, secret).send();
223
- await txClaim.wait({ debug: true });
222
+ await this.addPendingShieldNoteToPXE(asset, this.adminAddress, amount, secretHash, receipt.txHash);
223
+ const txClaim = asset.methods
224
+ .redeem_shield(this.adminAddress, amount, secret)
225
+ .send({ from: this.adminAddress });
226
+ await txClaim.wait();
224
227
  this.logger.verbose(`Minting complete.`);
225
228
 
226
229
  return { amount };
227
230
  },
228
231
  async ({ amount }) => {
229
- const {
230
- asset,
231
- accounts: [{ address }],
232
- tokenSim,
233
- } = this;
234
- tokenSim.mintPublic(address, amount);
235
-
236
- const publicBalance = await asset.methods.balance_of_public(address).simulate();
232
+ const { asset, tokenSim } = this;
233
+ tokenSim.mintPublic(this.adminAddress, amount);
234
+
235
+ const publicBalance = await asset.methods
236
+ .balance_of_public(this.adminAddress)
237
+ .simulate({ from: this.adminAddress });
237
238
  this.logger.verbose(`Public balance of wallet 0: ${publicBalance}`);
238
- expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(address));
239
+ expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(this.adminAddress));
239
240
 
240
- tokenSim.mintPrivate(address, amount);
241
- const privateBalance = await asset.methods.balance_of_private(address).simulate();
241
+ tokenSim.mintPrivate(this.adminAddress, amount);
242
+ const privateBalance = await asset.methods
243
+ .balance_of_private(this.adminAddress)
244
+ .simulate({ from: this.adminAddress });
242
245
  this.logger.verbose(`Private balance of wallet 0: ${privateBalance}`);
243
- expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(address));
246
+ expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(this.adminAddress));
244
247
 
245
- const totalSupply = await asset.methods.total_supply().simulate();
248
+ const totalSupply = await asset.methods.total_supply().simulate({ from: this.adminAddress });
246
249
  this.logger.verbose(`Total supply: ${totalSupply}`);
247
250
  expect(totalSupply).toEqual(tokenSim.totalSupply);
248
251