@aztec/end-to-end 0.0.0-test.1 → 0.0.1-fake-ceab37513c

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 (156) hide show
  1. package/dest/bench/client_flows/benchmark.d.ts +60 -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 +69 -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 +315 -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 -27
  14. package/dest/bench/utils.d.ts.map +1 -1
  15. package/dest/bench/utils.js +27 -43
  16. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +15 -7
  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 +66 -38
  19. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +10 -18
  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 +34 -53
  22. package/dest/e2e_deploy_contract/deploy_test.d.ts +4 -2
  23. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  24. package/dest/e2e_deploy_contract/deploy_test.js +9 -6
  25. package/dest/e2e_epochs/epochs_test.d.ts +56 -17
  26. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  27. package/dest/e2e_epochs/epochs_test.js +222 -42
  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 +60 -0
  31. package/dest/e2e_fees/fees_test.d.ts +16 -5
  32. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  33. package/dest/e2e_fees/fees_test.js +87 -88
  34. package/dest/e2e_l1_publisher/write_json.d.ts +8 -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 +5 -5
  41. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  42. package/dest/e2e_nested_contract/nested_contract_test.js +19 -14
  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 +132 -0
  46. package/dest/e2e_p2p/p2p_network.d.ts +56 -21
  47. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  48. package/dest/e2e_p2p/p2p_network.js +154 -125
  49. package/dest/e2e_p2p/shared.d.ts +41 -3
  50. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  51. package/dest/e2e_p2p/shared.js +146 -6
  52. package/dest/e2e_token_contract/token_contract_test.d.ts +10 -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 +51 -24
  55. package/dest/{e2e_prover → fixtures}/e2e_prover_test.d.ts +7 -4
  56. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
  57. package/dest/{e2e_prover → fixtures}/e2e_prover_test.js +67 -62
  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.map +1 -1
  62. package/dest/fixtures/get_acvm_config.js +2 -14
  63. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  64. package/dest/fixtures/get_bb_config.js +8 -15
  65. package/dest/fixtures/l1_to_l2_messaging.d.ts +8 -5
  66. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  67. package/dest/fixtures/l1_to_l2_messaging.js +44 -18
  68. package/dest/fixtures/setup_l1_contracts.d.ts +3 -3
  69. package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
  70. package/dest/fixtures/setup_l1_contracts.js +3 -3
  71. package/dest/fixtures/setup_p2p_test.d.ts +14 -6
  72. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  73. package/dest/fixtures/setup_p2p_test.js +73 -21
  74. package/dest/fixtures/snapshot_manager.d.ts +8 -3
  75. package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
  76. package/dest/fixtures/snapshot_manager.js +120 -104
  77. package/dest/fixtures/token_utils.d.ts +4 -3
  78. package/dest/fixtures/token_utils.d.ts.map +1 -1
  79. package/dest/fixtures/token_utils.js +24 -7
  80. package/dest/fixtures/utils.d.ts +65 -22
  81. package/dest/fixtures/utils.d.ts.map +1 -1
  82. package/dest/fixtures/utils.js +439 -318
  83. package/dest/fixtures/web3signer.d.ts +5 -0
  84. package/dest/fixtures/web3signer.d.ts.map +1 -0
  85. package/dest/fixtures/web3signer.js +42 -0
  86. package/dest/shared/cross_chain_test_harness.d.ts +28 -18
  87. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  88. package/dest/shared/cross_chain_test_harness.js +97 -41
  89. package/dest/shared/gas_portal_test_harness.d.ts +23 -18
  90. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  91. package/dest/shared/gas_portal_test_harness.js +43 -25
  92. package/dest/shared/submit-transactions.d.ts.map +1 -1
  93. package/dest/shared/uniswap_l1_l2.d.ts +5 -6
  94. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  95. package/dest/shared/uniswap_l1_l2.js +136 -90
  96. package/dest/simulators/lending_simulator.d.ts +5 -6
  97. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  98. package/dest/simulators/lending_simulator.js +11 -15
  99. package/dest/simulators/token_simulator.d.ts +2 -1
  100. package/dest/simulators/token_simulator.d.ts.map +1 -1
  101. package/dest/simulators/token_simulator.js +16 -13
  102. package/dest/spartan/setup_test_wallets.d.ts +8 -1
  103. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  104. package/dest/spartan/setup_test_wallets.js +108 -22
  105. package/dest/spartan/utils.d.ts +60 -307
  106. package/dest/spartan/utils.d.ts.map +1 -1
  107. package/dest/spartan/utils.js +200 -115
  108. package/package.json +60 -56
  109. package/src/bench/client_flows/benchmark.ts +341 -0
  110. package/src/bench/client_flows/client_flows_benchmark.ts +422 -0
  111. package/src/bench/client_flows/config.ts +61 -0
  112. package/src/bench/client_flows/data_extractor.ts +111 -0
  113. package/src/bench/utils.ts +26 -52
  114. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +60 -40
  115. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +47 -75
  116. package/src/e2e_deploy_contract/deploy_test.ts +11 -8
  117. package/src/e2e_epochs/epochs_test.ts +276 -54
  118. package/src/e2e_fees/bridging_race.notest.ts +75 -0
  119. package/src/e2e_fees/fees_test.ts +121 -108
  120. package/src/e2e_l1_publisher/write_json.ts +74 -0
  121. package/src/e2e_multi_validator/utils.ts +258 -0
  122. package/src/e2e_nested_contract/nested_contract_test.ts +22 -14
  123. package/src/e2e_p2p/inactivity_slash_test.ts +174 -0
  124. package/src/e2e_p2p/p2p_network.ts +212 -144
  125. package/src/e2e_p2p/shared.ts +234 -14
  126. package/src/e2e_token_contract/token_contract_test.ts +42 -38
  127. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  128. package/src/{e2e_prover → fixtures}/e2e_prover_test.ts +62 -69
  129. package/src/fixtures/fixtures.ts +4 -3
  130. package/src/fixtures/get_acvm_config.ts +2 -10
  131. package/src/fixtures/get_bb_config.ts +15 -11
  132. package/src/fixtures/l1_to_l2_messaging.ts +53 -23
  133. package/src/fixtures/setup_l1_contracts.ts +5 -6
  134. package/src/fixtures/setup_p2p_test.ts +112 -30
  135. package/src/fixtures/snapshot_manager.ts +150 -102
  136. package/src/fixtures/token_utils.ts +33 -8
  137. package/src/fixtures/utils.ts +530 -352
  138. package/src/fixtures/web3signer.ts +46 -0
  139. package/src/guides/up_quick_start.sh +4 -4
  140. package/src/shared/cross_chain_test_harness.ts +92 -52
  141. package/src/shared/gas_portal_test_harness.ts +47 -31
  142. package/src/shared/uniswap_l1_l2.ts +127 -124
  143. package/src/simulators/lending_simulator.ts +11 -15
  144. package/src/simulators/token_simulator.ts +17 -12
  145. package/src/spartan/DEVELOP.md +116 -0
  146. package/src/spartan/setup_test_wallets.ts +144 -29
  147. package/src/spartan/utils.ts +194 -116
  148. package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
  149. package/dest/sample-dapp/connect.js +0 -12
  150. package/dest/sample-dapp/contracts.js +0 -10
  151. package/dest/sample-dapp/deploy.js +0 -35
  152. package/dest/sample-dapp/index.js +0 -98
  153. package/src/sample-dapp/connect.mjs +0 -16
  154. package/src/sample-dapp/contracts.mjs +0 -14
  155. package/src/sample-dapp/deploy.mjs +0 -40
  156. package/src/sample-dapp/index.mjs +0 -128
@@ -1,12 +1,9 @@
1
- import { BatchCall, INITIAL_L2_BLOCK_NUM } from '@aztec/aztec.js';
2
- import { mean, stdDev, timesParallel } from '@aztec/foundation/collection';
3
- import { randomInt } from '@aztec/foundation/crypto';
4
- import { BenchmarkingContract } from '@aztec/noir-contracts.js/Benchmarking';
1
+ import { BatchCall } from '@aztec/aztec.js';
2
+ import { mean, stdDev, times } from '@aztec/foundation/collection';
3
+ import { BenchmarkingContract } from '@aztec/noir-test-contracts.js/Benchmarking';
5
4
  import { createPXEService } from '@aztec/pxe/server';
6
- import { writeFileSync } from 'fs';
7
- import { mkdirpSync } from 'fs-extra';
8
- import { globSync } from 'glob';
9
- import { join } from 'path';
5
+ import { mkdirSync, writeFileSync } from 'fs';
6
+ import path from 'path';
10
7
  import { setup } from '../fixtures/utils.js';
11
8
  /**
12
9
  * Setup for benchmarks. Initializes a remote node with a single account and deploys a benchmark contract.
@@ -17,7 +14,9 @@ import { setup } from '../fixtures/utils.js';
17
14
  benchmark: true
18
15
  }
19
16
  });
20
- const contract = await BenchmarkingContract.deploy(context.wallet).send().deployed();
17
+ const contract = await BenchmarkingContract.deploy(context.wallet).send({
18
+ from: context.wallet.getAddress()
19
+ }).deployed();
21
20
  context.logger.info(`Deployed benchmarking contract at ${contract.address}`);
22
21
  const sequencer = context.aztecNode.getSequencer();
23
22
  const telemetry = context.telemetryClient;
@@ -28,7 +27,13 @@ import { setup } from '../fixtures/utils.js';
28
27
  await telemetry.flush();
29
28
  const data = telemetry.getMeters();
30
29
  const formatted = formatMetricsForGithubBenchmarkAction(data, opts.metrics);
30
+ if (formatted.length === 0) {
31
+ throw new Error(`No benchmark data generated. Please review your test setup.`);
32
+ }
31
33
  const benchOutput = opts.benchOutput ?? process.env.BENCH_OUTPUT ?? 'bench.json';
34
+ mkdirSync(path.dirname(benchOutput), {
35
+ recursive: true
36
+ });
32
37
  writeFileSync(benchOutput, JSON.stringify(formatted));
33
38
  context.logger.info(`Wrote ${data.length} metrics to ${benchOutput}`);
34
39
  await origTeardown();
@@ -76,28 +81,6 @@ function getMetricValues(points) {
76
81
  };
77
82
  }
78
83
  }
79
- /**
80
- * Creates and returns a directory with the current job name and a random number.
81
- * @param index - Index to merge into the dir path.
82
- * @returns A path to a created dir.
83
- */ export function makeDataDirectory(index) {
84
- const testName = expect.getState().currentTestName.split(' ')[0].replaceAll('/', '_');
85
- const db = join('data', testName, index.toString(), `${randomInt(99)}`);
86
- mkdirpSync(db);
87
- return db;
88
- }
89
- /**
90
- * Returns the size in disk of a folder.
91
- * @param path - Path to the folder.
92
- * @returns Size in bytes.
93
- */ export function getFolderSize(path) {
94
- return globSync('**', {
95
- stat: true,
96
- cwd: path,
97
- nodir: true,
98
- withFileTypes: true
99
- }).reduce((accum, file)=>accum + file.size, 0);
100
- }
101
84
  /**
102
85
  * Returns a call to the benchmark contract. Each call has a private execution (account entrypoint),
103
86
  * a nested private call (create_note), a public call (increment_balance), and a nested public
@@ -108,17 +91,16 @@ function getMetricValues(points) {
108
91
  * @param contract - Benchmarking contract.
109
92
  * @param heavyPublicCompute - Whether the transactions include heavy public compute (like a big sha256).
110
93
  * @returns A BatchCall instance.
111
- */ export async function makeCall(index, context, contract, heavyPublicCompute) {
94
+ */ function makeCall(index, context, contract, heavyPublicCompute) {
112
95
  const owner = context.wallet.getAddress();
113
- const sender = owner;
114
96
  if (heavyPublicCompute) {
115
97
  return new BatchCall(context.wallet, [
116
- await contract.methods.sha256_hash_2048(randomBytesAsBigInts(2048)).request()
98
+ contract.methods.sha256_hash_2048(randomBytesAsBigInts(2048))
117
99
  ]);
118
100
  } else {
119
101
  return new BatchCall(context.wallet, [
120
- await contract.methods.create_note(owner, sender, index + 1).request(),
121
- await contract.methods.increment_balance(owner, index + 1).request()
102
+ contract.methods.create_note(owner, index + 1),
103
+ contract.methods.increment_balance(owner, index + 1)
122
104
  ]);
123
105
  }
124
106
  }
@@ -131,10 +113,10 @@ function getMetricValues(points) {
131
113
  * @param heavyPublicCompute - Whether the transactions include heavy public compute (like a big sha256).
132
114
  * @returns Array of sent txs.
133
115
  */ export async function sendTxs(txCount, context, contract, heavyPublicCompute = false) {
134
- const calls = await timesParallel(txCount, (index)=>makeCall(index, context, contract, heavyPublicCompute));
116
+ const calls = times(txCount, (index)=>makeCall(index, context, contract, heavyPublicCompute));
135
117
  context.logger.info(`Creating ${txCount} txs`);
136
118
  const provenTxs = await Promise.all(calls.map((call)=>call.prove({
137
- skipPublicSimulation: true
119
+ from: context.wallet.getAddress()
138
120
  })));
139
121
  context.logger.info(`Sending ${txCount} txs`);
140
122
  return provenTxs.map((tx)=>tx.send());
@@ -150,19 +132,21 @@ export async function waitTxs(txs, context, txWaitOpts) {
150
132
  * @param contract - Benchmark contract to add to the pxe.
151
133
  * @param startingBlock - First l2 block to process.
152
134
  * @returns The new PXE.
153
- */ export async function createNewPXE(node, contract, startingBlock = INITIAL_L2_BLOCK_NUM) {
135
+ */ export async function createNewPXE(node, contract) {
154
136
  const l1Contracts = await node.getL1ContractAddresses();
155
- const { l1ChainId, protocolVersion } = await node.getNodeInfo();
137
+ const { l1ChainId, rollupVersion } = await node.getNodeInfo();
156
138
  const pxeConfig = {
157
- l2StartingBlock: startingBlock,
139
+ l2BlockBatchSize: 50,
158
140
  l2BlockPollingIntervalMS: 100,
159
141
  dataDirectory: undefined,
160
- dataStoreMapSizeKB: 1024 * 1024,
142
+ dataStoreMapSizeKb: 1024 * 1024,
161
143
  l1Contracts,
162
144
  l1ChainId,
163
- version: protocolVersion
145
+ rollupVersion
164
146
  };
147
+ // docs:start:PXEcreate
165
148
  const pxe = await createPXEService(node, pxeConfig);
149
+ // docs:end:PXEcreate
166
150
  await pxe.registerContract(contract);
167
151
  return pxe;
168
152
  }
@@ -1,6 +1,8 @@
1
- import { type AccountWallet, type CompleteAddress, Fr, type Logger, type TxHash } from '@aztec/aztec.js';
2
- import { DocsExampleContract } from '@aztec/noir-contracts.js/DocsExample';
1
+ import { type AccountWallet, AztecAddress, type AztecNode, type CompleteAddress, Fr, type Logger, type PXE, type TxHash } from '@aztec/aztec.js';
2
+ import type { CheatCodes } from '@aztec/aztec/testing';
3
3
  import { TokenBlacklistContract } from '@aztec/noir-contracts.js/TokenBlacklist';
4
+ import { InvalidAccountContract } from '@aztec/noir-test-contracts.js/InvalidAccount';
5
+ import type { SequencerClient } from '@aztec/sequencer-client';
4
6
  import { type SubsystemsContext } from '../fixtures/snapshot_manager.js';
5
7
  import { TokenSimulator } from '../simulators/token_simulator.js';
6
8
  export declare class Role {
@@ -17,20 +19,26 @@ export declare class Role {
17
19
  };
18
20
  }
19
21
  export declare class BlacklistTokenContractTest {
20
- #private;
21
- static DELAY: number;
22
+ static CHANGE_ROLES_DELAY: number;
22
23
  private snapshotManager;
23
24
  logger: Logger;
24
25
  wallets: AccountWallet[];
26
+ pxe: PXE;
25
27
  accounts: CompleteAddress[];
26
28
  asset: TokenBlacklistContract;
27
29
  tokenSim: TokenSimulator;
28
- badAccount: DocsExampleContract;
30
+ badAccount: InvalidAccountContract;
31
+ cheatCodes: CheatCodes;
32
+ sequencer: SequencerClient;
33
+ aztecNode: AztecNode;
29
34
  admin: AccountWallet;
35
+ adminAddress: AztecAddress;
30
36
  other: AccountWallet;
37
+ otherAddress: AztecAddress;
31
38
  blacklisted: AccountWallet;
39
+ blacklistedAddress: AztecAddress;
32
40
  constructor(testName: string);
33
- mineBlocks(amount?: number): Promise<void>;
41
+ crossTimestampOfChange(): Promise<void>;
34
42
  /**
35
43
  * Adds two state shifts to snapshot manager.
36
44
  * 1. Add 3 accounts.
@@ -40,7 +48,7 @@ export declare class BlacklistTokenContractTest {
40
48
  setup(): Promise<void>;
41
49
  snapshot: <T>(name: string, apply: (context: SubsystemsContext) => Promise<T>, restore?: (snapshotData: T, context: SubsystemsContext) => Promise<void>) => Promise<void>;
42
50
  teardown(): Promise<void>;
43
- addPendingShieldNoteToPXE(contract: TokenBlacklistContract, wallet: AccountWallet, amount: bigint, secretHash: Fr, txHash: TxHash): Promise<void>;
51
+ addPendingShieldNoteToPXE(contract: TokenBlacklistContract, recipient: AztecAddress, amount: bigint, secretHash: Fr, txHash: TxHash): Promise<void>;
44
52
  applyMintSnapshot(): Promise<void>;
45
53
  }
46
54
  //# sourceMappingURL=blacklist_token_contract_test.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"blacklist_token_contract_test.d.ts","sourceRoot":"","sources":["../../src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts"],"names":[],"mappings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,QAAQ,EAAE,sBAAsB,EAChC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,EAAE,EACd,MAAM,EAAE,MAAM;IAgBV,iBAAiB;CAmExB"}
1
+ {"version":3,"file":"blacklist_token_contract_test.d.ts","sourceRoot":"","sources":["../../src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAClB,YAAY,EACZ,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,EAAE,EACF,KAAK,MAAM,EACX,KAAK,GAAG,EACR,KAAK,MAAM,EAGZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AACtF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAI/D,OAAO,EAEL,KAAK,iBAAiB,EAIvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAIlE,qBAAa,IAAI;IACf,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,aAAa,CAAS;IAE9B,SAAS;IAKT,UAAU;IAKV,eAAe;IAKf,YAAY;;;;;CAKb;AAED,qBAAa,0BAA0B;IAErC,MAAM,CAAC,kBAAkB,SAAS;IAElC,OAAO,CAAC,eAAe,CAAmB;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,aAAa,EAAE,CAAM;IAC9B,GAAG,EAAG,GAAG,CAAC;IACV,QAAQ,EAAE,eAAe,EAAE,CAAM;IACjC,KAAK,EAAG,sBAAsB,CAAC;IAC/B,QAAQ,EAAG,cAAc,CAAC;IAC1B,UAAU,EAAG,sBAAsB,CAAC;IACpC,UAAU,EAAG,UAAU,CAAC;IACxB,SAAS,EAAG,eAAe,CAAC;IAC5B,SAAS,EAAG,SAAS,CAAC;IAEtB,KAAK,EAAG,aAAa,CAAC;IACtB,YAAY,EAAG,YAAY,CAAC;IAC5B,KAAK,EAAG,aAAa,CAAC;IACtB,YAAY,EAAG,YAAY,CAAC;IAC5B,WAAW,EAAG,aAAa,CAAC;IAC5B,kBAAkB,EAAG,YAAY,CAAC;gBAEtB,QAAQ,EAAE,MAAM;IAKtB,sBAAsB;IAQ5B;;;;OAIG;IACG,kBAAkB;IAoElB,KAAK;IAIX,QAAQ,GAAI,CAAC,EACX,MAAM,MAAM,EACZ,OAAO,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,CAAC,CAAC,EACjD,UAAS,CAAC,YAAY,EAAE,CAAC,EAAE,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAA2B,KAChG,OAAO,CAAC,IAAI,CAAC,CAAwD;IAElE,QAAQ;IAIR,yBAAyB,CAC7B,QAAQ,EAAE,sBAAsB,EAChC,SAAS,EAAE,YAAY,EACvB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,EAAE,EACd,MAAM,EAAE,MAAM;IAgBV,iBAAiB;CAqExB"}
@@ -1,8 +1,7 @@
1
1
  import { getSchnorrWallet } from '@aztec/accounts/schnorr';
2
2
  import { Fr, computeSecretHash, createLogger } from '@aztec/aztec.js';
3
- import { MAX_NOTE_HASHES_PER_TX } from '@aztec/constants';
4
- import { DocsExampleContract } from '@aztec/noir-contracts.js/DocsExample';
5
3
  import { TokenBlacklistContract } from '@aztec/noir-contracts.js/TokenBlacklist';
4
+ import { InvalidAccountContract } from '@aztec/noir-test-contracts.js/InvalidAccount';
6
5
  import { jest } from '@jest/globals';
7
6
  import { createSnapshotManager, deployAccounts, publicDeployAccounts } from '../fixtures/snapshot_manager.js';
8
7
  import { TokenSimulator } from '../simulators/token_simulator.js';
@@ -34,27 +33,31 @@ export class Role {
34
33
  }
35
34
  }
36
35
  export class BlacklistTokenContractTest {
37
- // A low delay is really poor ux, but we need to keep it low for the tests to run "quickly".
38
36
  // This value MUST match the same value that we have in the contract
39
- static DELAY = 2;
37
+ static CHANGE_ROLES_DELAY = 86400;
40
38
  snapshotManager;
41
39
  logger;
42
40
  wallets = [];
41
+ pxe;
43
42
  accounts = [];
44
43
  asset;
45
44
  tokenSim;
46
45
  badAccount;
46
+ cheatCodes;
47
+ sequencer;
48
+ aztecNode;
47
49
  admin;
50
+ adminAddress;
48
51
  other;
52
+ otherAddress;
49
53
  blacklisted;
54
+ blacklistedAddress;
50
55
  constructor(testName){
51
56
  this.logger = createLogger(`e2e:e2e_blacklist_token_contract:${testName}`);
52
57
  this.snapshotManager = createSnapshotManager(`e2e_blacklist_token_contract/${testName}`, dataPath);
53
58
  }
54
- async mineBlocks(amount = BlacklistTokenContractTest.DELAY) {
55
- for(let i = 0; i < amount; ++i){
56
- await this.asset.methods.get_roles(this.admin.getAddress()).send().wait();
57
- }
59
+ async crossTimestampOfChange() {
60
+ await this.cheatCodes.warpL2TimeAtLeastBy(this.sequencer, this.aztecNode, BlacklistTokenContractTest.CHANGE_ROLES_DELAY);
58
61
  }
59
62
  /**
60
63
  * Adds two state shifts to snapshot manager.
@@ -63,25 +66,36 @@ export class BlacklistTokenContractTest {
63
66
  */ async applyBaseSnapshots() {
64
67
  // Adding a timeout of 2 minutes in here such that it is propagated to the underlying tests
65
68
  jest.setTimeout(120_000);
66
- await this.snapshotManager.snapshot('3_accounts', deployAccounts(3, this.logger), async ({ deployedAccounts }, { pxe })=>{
69
+ await this.snapshotManager.snapshot('3_accounts', deployAccounts(3, this.logger), async ({ deployedAccounts }, { pxe, cheatCodes, aztecNode, sequencer })=>{
70
+ this.pxe = pxe;
71
+ this.cheatCodes = cheatCodes;
72
+ this.aztecNode = aztecNode;
73
+ this.sequencer = sequencer;
67
74
  this.wallets = await Promise.all(deployedAccounts.map((a)=>getSchnorrWallet(pxe, a.address, a.signingKey)));
68
75
  this.admin = this.wallets[0];
76
+ this.adminAddress = this.admin.getAddress();
69
77
  this.other = this.wallets[1];
78
+ this.otherAddress = this.other.getAddress();
70
79
  this.blacklisted = this.wallets[2];
80
+ this.blacklistedAddress = this.blacklisted.getAddress();
71
81
  this.accounts = this.wallets.map((w)=>w.getCompleteAddress());
72
82
  });
73
83
  await this.snapshotManager.snapshot('e2e_blacklist_token_contract', async ()=>{
74
84
  // Create the token contract state.
75
85
  // Move this account thing to addAccounts above?
76
86
  this.logger.verbose(`Public deploy accounts...`);
77
- await publicDeployAccounts(this.wallets[0], this.accounts.slice(0, 3));
87
+ await publicDeployAccounts(this.admin, this.accounts.slice(0, 3));
78
88
  this.logger.verbose(`Deploying TokenContract...`);
79
- this.asset = await TokenBlacklistContract.deploy(this.admin, this.admin.getAddress()).send().deployed();
89
+ this.asset = await TokenBlacklistContract.deploy(this.admin, this.adminAddress).send({
90
+ from: this.adminAddress
91
+ }).deployed();
80
92
  this.logger.verbose(`Token deployed to ${this.asset.address}`);
81
93
  this.logger.verbose(`Deploying bad account...`);
82
- this.badAccount = await DocsExampleContract.deploy(this.wallets[0]).send().deployed();
94
+ this.badAccount = await InvalidAccountContract.deploy(this.admin).send({
95
+ from: this.adminAddress
96
+ }).deployed();
83
97
  this.logger.verbose(`Deployed to ${this.badAccount.address}.`);
84
- await this.mineBlocks();
98
+ await this.crossTimestampOfChange();
85
99
  return {
86
100
  tokenContractAddress: this.asset.address,
87
101
  badAccountAddress: this.badAccount.address
@@ -90,10 +104,12 @@ export class BlacklistTokenContractTest {
90
104
  // Restore the token contract state.
91
105
  this.asset = await TokenBlacklistContract.at(tokenContractAddress, this.wallets[0]);
92
106
  this.logger.verbose(`Token contract address: ${this.asset.address}`);
93
- this.tokenSim = new TokenSimulator(this.asset, this.wallets[0], this.logger, this.accounts.map((a)=>a.address));
94
- this.badAccount = await DocsExampleContract.at(badAccountAddress, this.wallets[0]);
107
+ this.tokenSim = new TokenSimulator(this.asset, this.admin, this.adminAddress, this.logger, this.accounts.map((a)=>a.address));
108
+ this.badAccount = await InvalidAccountContract.at(badAccountAddress, this.wallets[0]);
95
109
  this.logger.verbose(`Bad account address: ${this.badAccount.address}`);
96
- expect(await this.asset.methods.get_roles(this.admin.getAddress()).simulate()).toEqual(new Role().withAdmin().toNoirStruct());
110
+ expect(await this.asset.methods.get_roles(this.adminAddress).simulate({
111
+ from: this.adminAddress
112
+ })).toEqual(new Role().withAdmin().toNoirStruct());
97
113
  });
98
114
  }
99
115
  async setup() {
@@ -103,37 +119,43 @@ export class BlacklistTokenContractTest {
103
119
  async teardown() {
104
120
  await this.snapshotManager.teardown();
105
121
  }
106
- #toBoundedVec(arr, maxLen) {
107
- return {
108
- len: arr.length,
109
- storage: arr.concat(new Array(maxLen - arr.length).fill(new Fr(0)))
110
- };
111
- }
112
- async addPendingShieldNoteToPXE(contract, wallet, amount, secretHash, txHash) {
113
- const txEffects = await wallet.getTxEffect(txHash);
114
- await contract.methods.deliver_transparent_note(contract.address, amount, secretHash, txHash.hash, this.#toBoundedVec(txEffects.data.noteHashes, MAX_NOTE_HASHES_PER_TX), txEffects.data.nullifiers[0], wallet.getAddress()).simulate();
122
+ async addPendingShieldNoteToPXE(contract, recipient, amount, secretHash, txHash) {
123
+ const txEffects = await this.pxe.getTxEffect(txHash);
124
+ await contract.methods.deliver_transparent_note(contract.address, amount, secretHash, txHash.hash, txEffects.data.noteHashes, txEffects.data.nullifiers[0], recipient).simulate({
125
+ from: recipient
126
+ });
115
127
  }
116
128
  async applyMintSnapshot() {
117
129
  await this.snapshotManager.snapshot('mint', async ()=>{
118
130
  const { asset, accounts, wallets } = this;
119
131
  const amount = 10000n;
120
132
  const adminMinterRole = new Role().withAdmin().withMinter();
121
- await this.asset.withWallet(this.admin).methods.update_roles(this.admin.getAddress(), adminMinterRole.toNoirStruct()).send().wait();
133
+ await this.asset.withWallet(this.admin).methods.update_roles(this.admin.getAddress(), adminMinterRole.toNoirStruct()).send({
134
+ from: this.adminAddress
135
+ }).wait();
122
136
  const blacklistRole = new Role().withBlacklisted();
123
- await this.asset.withWallet(this.admin).methods.update_roles(this.blacklisted.getAddress(), blacklistRole.toNoirStruct()).send().wait();
124
- await this.mineBlocks(); // This gets us past the block of change
125
- expect(await this.asset.methods.get_roles(this.admin.getAddress()).simulate()).toEqual(adminMinterRole.toNoirStruct());
137
+ await this.asset.withWallet(this.admin).methods.update_roles(this.blacklisted.getAddress(), blacklistRole.toNoirStruct()).send({
138
+ from: this.adminAddress
139
+ }).wait();
140
+ await this.crossTimestampOfChange();
141
+ expect(await this.asset.methods.get_roles(this.admin.getAddress()).simulate({
142
+ from: this.adminAddress
143
+ })).toEqual(adminMinterRole.toNoirStruct());
126
144
  this.logger.verbose(`Minting ${amount} publicly...`);
127
- await asset.methods.mint_public(accounts[0].address, amount).send().wait();
145
+ await asset.methods.mint_public(accounts[0].address, amount).send({
146
+ from: this.adminAddress
147
+ }).wait();
128
148
  this.logger.verbose(`Minting ${amount} privately...`);
129
149
  const secret = Fr.random();
130
150
  const secretHash = await computeSecretHash(secret);
131
- const receipt = await asset.methods.mint_private(amount, secretHash).send().wait();
132
- await this.addPendingShieldNoteToPXE(asset, wallets[0], amount, secretHash, receipt.txHash);
133
- const txClaim = asset.methods.redeem_shield(accounts[0].address, amount, secret).send();
134
- await txClaim.wait({
135
- debug: true
151
+ const receipt = await asset.methods.mint_private(amount, secretHash).send({
152
+ from: this.adminAddress
153
+ }).wait();
154
+ await this.addPendingShieldNoteToPXE(asset, wallets[0].getAddress(), amount, secretHash, receipt.txHash);
155
+ const txClaim = asset.methods.redeem_shield(accounts[0].address, amount, secret).send({
156
+ from: this.adminAddress
136
157
  });
158
+ await txClaim.wait();
137
159
  this.logger.verbose(`Minting complete.`);
138
160
  return {
139
161
  amount
@@ -141,14 +163,20 @@ export class BlacklistTokenContractTest {
141
163
  }, async ({ amount })=>{
142
164
  const { asset, accounts: [{ address }], tokenSim } = this;
143
165
  tokenSim.mintPublic(address, amount);
144
- const publicBalance = await asset.methods.balance_of_public(address).simulate();
166
+ const publicBalance = await asset.methods.balance_of_public(address).simulate({
167
+ from: address
168
+ });
145
169
  this.logger.verbose(`Public balance of wallet 0: ${publicBalance}`);
146
170
  expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(address));
147
171
  tokenSim.mintPrivate(address, amount);
148
- const privateBalance = await asset.methods.balance_of_private(address).simulate();
172
+ const privateBalance = await asset.methods.balance_of_private(address).simulate({
173
+ from: address
174
+ });
149
175
  this.logger.verbose(`Private balance of wallet 0: ${privateBalance}`);
150
176
  expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(address));
151
- const totalSupply = await asset.methods.total_supply().simulate();
177
+ const totalSupply = await asset.methods.total_supply().simulate({
178
+ from: address
179
+ });
152
180
  this.logger.verbose(`Total supply: ${totalSupply}`);
153
181
  expect(totalSupply).toEqual(tokenSim.totalSupply);
154
182
  return Promise.resolve();
@@ -1,47 +1,39 @@
1
1
  import type { AztecNodeConfig } from '@aztec/aztec-node';
2
- import { type AccountWallet, AztecAddress, type AztecNode, CheatCodes, type CompleteAddress, EthAddress, type Logger, type PXE } from '@aztec/aztec.js';
3
- import { type ViemPublicClient } from '@aztec/ethereum';
2
+ import { type AccountWallet, AztecAddress, type AztecNode, type CompleteAddress, EthAddress, type Logger, type PXE } from '@aztec/aztec.js';
3
+ import { CheatCodes } from '@aztec/aztec/testing';
4
+ import { type DeployL1ContractsReturnType, type ExtendedViemWalletClient } from '@aztec/ethereum';
4
5
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
5
6
  import { TokenBridgeContract } from '@aztec/noir-contracts.js/TokenBridge';
7
+ import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
6
8
  import { type SubsystemsContext } from '../fixtures/snapshot_manager.js';
7
9
  import { CrossChainTestHarness } from '../shared/cross_chain_test_harness.js';
8
10
  export declare class CrossChainMessagingTest {
9
11
  private snapshotManager;
10
12
  logger: Logger;
11
- wallets: AccountWallet[];
12
13
  accounts: CompleteAddress[];
13
14
  aztecNode: AztecNode;
14
15
  pxe: PXE;
15
16
  aztecNodeConfig: AztecNodeConfig;
16
- publicClient: ViemPublicClient | undefined;
17
+ aztecNodeAdmin: AztecNodeAdmin;
18
+ l1Client: ExtendedViemWalletClient | undefined;
17
19
  user1Wallet: AccountWallet;
20
+ user1Address: AztecAddress;
18
21
  user2Wallet: AccountWallet;
22
+ user2Address: AztecAddress;
19
23
  crossChainTestHarness: CrossChainTestHarness;
20
24
  ethAccount: EthAddress;
21
25
  ownerAddress: AztecAddress;
22
26
  l2Token: TokenContract;
23
27
  l2Bridge: TokenBridgeContract;
24
- rollup: any;
25
28
  inbox: any;
26
29
  outbox: any;
27
- cheatcodes: CheatCodes;
30
+ cheatCodes: CheatCodes;
31
+ deployL1ContractsValues: DeployL1ContractsReturnType;
28
32
  constructor(testName: string);
29
33
  assumeProven(): Promise<void>;
30
34
  setup(): Promise<void>;
31
35
  snapshot: <T>(name: string, apply: (context: SubsystemsContext) => Promise<T>, restore?: (snapshotData: T, context: SubsystemsContext) => Promise<void>) => Promise<void>;
32
36
  teardown(): Promise<void>;
33
37
  applyBaseSnapshots(): Promise<void>;
34
- toCrossChainContext(): CrossChainContext;
35
38
  }
36
- type CrossChainContext = {
37
- l2Token: AztecAddress;
38
- l2Bridge: AztecAddress;
39
- tokenPortal: EthAddress;
40
- underlying: EthAddress;
41
- ethAccount: EthAddress;
42
- ownerAddress: AztecAddress;
43
- inbox: EthAddress;
44
- outbox: EthAddress;
45
- };
46
- export {};
47
39
  //# sourceMappingURL=cross_chain_messaging_test.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cross_chain_messaging_test.d.ts","sourceRoot":"","sources":["../../src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EACL,KAAK,aAAa,EAClB,YAAY,EACZ,KAAK,SAAS,EACd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E,QAAQ,IAAI,CAAC,CAAwD;IAElE,QAAQ;IAIR,kBAAkB;IAiHxB,mBAAmB,IAAI,iBAAiB;CAYzC;AAED,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE,YAAY,CAAC;IACtB,QAAQ,EAAE,YAAY,CAAC;IACvB,WAAW,EAAE,UAAU,CAAC;IACxB,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,YAAY,EAAE,YAAY,CAAC;IAC3B,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,UAAU,CAAC;CACpB,CAAC"}
1
+ {"version":3,"file":"cross_chain_messaging_test.d.ts","sourceRoot":"","sources":["../../src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EACL,KAAK,aAAa,EAClB,YAAY,EACZ,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,UAAU,EACV,KAAK,MAAM,EACX,KAAK,GAAG,EAET,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAG9B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAKtE,OAAO,EAEL,KAAK,iBAAiB,EAIvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAI9E,qBAAa,uBAAuB;IAClC,OAAO,CAAC,eAAe,CAAmB;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,eAAe,EAAE,CAAM;IACjC,SAAS,EAAG,SAAS,CAAC;IACtB,GAAG,EAAG,GAAG,CAAC;IACV,eAAe,EAAG,eAAe,CAAC;IAClC,cAAc,EAAG,cAAc,CAAC;IAEhC,QAAQ,EAAG,wBAAwB,GAAG,SAAS,CAAC;IAEhD,WAAW,EAAG,aAAa,CAAC;IAC5B,YAAY,EAAG,YAAY,CAAC;IAC5B,WAAW,EAAG,aAAa,CAAC;IAC5B,YAAY,EAAG,YAAY,CAAC;IAC5B,qBAAqB,EAAG,qBAAqB,CAAC;IAC9C,UAAU,EAAG,UAAU,CAAC;IACxB,YAAY,EAAG,YAAY,CAAC;IAC5B,OAAO,EAAG,aAAa,CAAC;IACxB,QAAQ,EAAG,mBAAmB,CAAC;IAE/B,KAAK,EAAG,GAAG,CAAC;IACZ,MAAM,EAAG,GAAG,CAAC;IACb,UAAU,EAAG,UAAU,CAAC;IAExB,uBAAuB,EAAG,2BAA2B,CAAC;gBAE1C,QAAQ,EAAE,MAAM;IAKtB,YAAY;IAIZ,KAAK;IAUX,QAAQ,GAAI,CAAC,EACX,MAAM,MAAM,EACZ,OAAO,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,CAAC,CAAC,EACjD,UAAS,CAAC,YAAY,EAAE,CAAC,EAAE,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAA2B,KAChG,OAAO,CAAC,IAAI,CAAC,CAAwD;IAElE,QAAQ;IAIR,kBAAkB;CAiGzB"}
@@ -1,7 +1,8 @@
1
1
  import { getSchnorrWallet } from '@aztec/accounts/schnorr';
2
- import { AztecAddress, CheatCodes, EthAddress, createLogger } from '@aztec/aztec.js';
3
- import { createL1Clients, deployL1Contract } from '@aztec/ethereum';
4
- import { InboxAbi, OutboxAbi, RollupAbi, TestERC20Abi, TestERC20Bytecode } from '@aztec/l1-artifacts';
2
+ import { AztecAddress, EthAddress, createLogger } from '@aztec/aztec.js';
3
+ import { CheatCodes } from '@aztec/aztec/testing';
4
+ import { createExtendedL1Client, deployL1Contract } from '@aztec/ethereum';
5
+ import { InboxAbi, OutboxAbi, TestERC20Abi, TestERC20Bytecode } from '@aztec/l1-artifacts';
5
6
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
6
7
  import { TokenBridgeContract } from '@aztec/noir-contracts.js/TokenBridge';
7
8
  import { getContract } from 'viem';
@@ -12,36 +13,40 @@ const { E2E_DATA_PATH: dataPath } = process.env;
12
13
  export class CrossChainMessagingTest {
13
14
  snapshotManager;
14
15
  logger;
15
- wallets = [];
16
16
  accounts = [];
17
17
  aztecNode;
18
18
  pxe;
19
19
  aztecNodeConfig;
20
- publicClient;
20
+ aztecNodeAdmin;
21
+ l1Client;
21
22
  user1Wallet;
23
+ user1Address;
22
24
  user2Wallet;
25
+ user2Address;
23
26
  crossChainTestHarness;
24
27
  ethAccount;
25
28
  ownerAddress;
26
29
  l2Token;
27
30
  l2Bridge;
28
- rollup;
29
31
  inbox;
30
32
  outbox;
31
- cheatcodes;
33
+ cheatCodes;
34
+ deployL1ContractsValues;
32
35
  constructor(testName){
33
36
  this.logger = createLogger(`e2e:e2e_cross_chain_messaging:${testName}`);
34
37
  this.snapshotManager = createSnapshotManager(`e2e_cross_chain_messaging/${testName}`, dataPath);
35
38
  }
36
39
  async assumeProven() {
37
- await this.cheatcodes.rollup.markAsProven(await this.rollup.read.getPendingBlockNumber());
40
+ await this.cheatCodes.rollup.markAsProven();
38
41
  }
39
42
  async setup() {
40
- const { aztecNode, pxe, aztecNodeConfig } = await this.snapshotManager.setup();
43
+ const { aztecNode, pxe, aztecNodeConfig, deployL1ContractsValues } = await this.snapshotManager.setup();
41
44
  this.aztecNode = aztecNode;
42
45
  this.pxe = pxe;
43
46
  this.aztecNodeConfig = aztecNodeConfig;
44
- this.cheatcodes = await CheatCodes.create(this.aztecNodeConfig.l1RpcUrls, this.pxe);
47
+ this.cheatCodes = await CheatCodes.create(this.aztecNodeConfig.l1RpcUrls, this.pxe);
48
+ this.deployL1ContractsValues = deployL1ContractsValues;
49
+ this.aztecNodeAdmin = aztecNode;
45
50
  }
46
51
  snapshot = (name, apply, restore = ()=>Promise.resolve())=>this.snapshotManager.snapshot(name, apply, restore);
47
52
  async teardown() {
@@ -50,17 +55,14 @@ export class CrossChainMessagingTest {
50
55
  async applyBaseSnapshots() {
51
56
  // Note that we are using the same `pxe`, `aztecNodeConfig` and `aztecNode` across all snapshots.
52
57
  // This is to not have issues with different networks.
53
- await this.snapshotManager.snapshot('3_accounts', deployAccounts(3, this.logger), async ({ deployedAccounts }, { pxe, aztecNodeConfig, aztecNode, deployL1ContractsValues })=>{
54
- this.wallets = await Promise.all(deployedAccounts.map((a)=>getSchnorrWallet(pxe, a.address, a.signingKey)));
55
- this.accounts = this.wallets.map((w)=>w.getCompleteAddress());
56
- this.wallets.forEach((w, i)=>this.logger.verbose(`Wallet ${i} address: ${w.getAddress()}`));
57
- this.rollup = getContract({
58
- address: deployL1ContractsValues.l1ContractAddresses.rollupAddress.toString(),
59
- abi: RollupAbi,
60
- client: deployL1ContractsValues.walletClient
61
- });
62
- this.user1Wallet = this.wallets[0];
63
- this.user2Wallet = this.wallets[1];
58
+ await this.snapshotManager.snapshot('3_accounts', deployAccounts(3, this.logger), async ({ deployedAccounts }, { pxe, aztecNodeConfig, aztecNode })=>{
59
+ const wallets = await Promise.all(deployedAccounts.map((a)=>getSchnorrWallet(pxe, a.address, a.signingKey)));
60
+ this.accounts = wallets.map((w)=>w.getCompleteAddress());
61
+ wallets.forEach((w, i)=>this.logger.verbose(`Wallet ${i} address: ${w.getAddress()}`));
62
+ this.user1Wallet = wallets[0];
63
+ this.user1Address = this.user1Wallet.getAddress();
64
+ this.user2Wallet = wallets[1];
65
+ this.user2Address = this.user2Wallet.getAddress();
64
66
  this.pxe = pxe;
65
67
  this.aztecNode = aztecNode;
66
68
  this.aztecNodeConfig = aztecNodeConfig;
@@ -69,26 +71,17 @@ export class CrossChainMessagingTest {
69
71
  // Create the token contract state.
70
72
  // Move this account thing to addAccounts above?
71
73
  this.logger.verbose(`Public deploy accounts...`);
72
- await publicDeployAccounts(this.wallets[0], this.accounts.slice(0, 3));
73
- const { publicClient, walletClient } = createL1Clients(this.aztecNodeConfig.l1RpcUrls, MNEMONIC);
74
- const underlyingERC20Address = await deployL1Contract(walletClient, publicClient, TestERC20Abi, TestERC20Bytecode, [
74
+ await publicDeployAccounts(this.user1Wallet, this.accounts.slice(0, 3));
75
+ this.l1Client = createExtendedL1Client(this.aztecNodeConfig.l1RpcUrls, MNEMONIC);
76
+ const underlyingERC20Address = await deployL1Contract(this.l1Client, TestERC20Abi, TestERC20Bytecode, [
75
77
  'Underlying',
76
78
  'UND',
77
- walletClient.account.address
79
+ this.l1Client.account.address
78
80
  ]).then(({ address })=>address);
79
- const underlyingERC20 = getContract({
80
- address: underlyingERC20Address.toString(),
81
- abi: TestERC20Abi,
82
- client: walletClient
83
- });
84
- // allow anyone to mint
85
- await underlyingERC20.write.setFreeForAll([
86
- true
87
- ], {});
88
81
  this.logger.verbose(`Setting up cross chain harness...`);
89
- this.crossChainTestHarness = await CrossChainTestHarness.new(this.aztecNode, this.pxe, publicClient, walletClient, this.wallets[0], this.logger, underlyingERC20Address);
82
+ this.crossChainTestHarness = await CrossChainTestHarness.new(this.aztecNode, this.pxe, this.l1Client, this.user1Wallet, this.user1Address, this.logger, underlyingERC20Address);
90
83
  this.logger.verbose(`L2 token deployed to: ${this.crossChainTestHarness.l2Token.address}`);
91
- return this.toCrossChainContext();
84
+ return this.crossChainTestHarness.toCrossChainContext();
92
85
  }, async (crossChainContext)=>{
93
86
  this.l2Token = await TokenContract.at(crossChainContext.l2Token, this.user1Wallet);
94
87
  this.l2Bridge = await TokenBridgeContract.at(crossChainContext.l2Bridge, this.user1Wallet);
@@ -96,33 +89,21 @@ export class CrossChainMessagingTest {
96
89
  this.ethAccount = EthAddress.fromString(crossChainContext.ethAccount.toString());
97
90
  this.ownerAddress = AztecAddress.fromString(crossChainContext.ownerAddress.toString());
98
91
  const tokenPortalAddress = EthAddress.fromString(crossChainContext.tokenPortal.toString());
99
- const { publicClient, walletClient } = createL1Clients(this.aztecNodeConfig.l1RpcUrls, MNEMONIC);
92
+ const l1Client = createExtendedL1Client(this.aztecNodeConfig.l1RpcUrls, MNEMONIC);
100
93
  const inbox = getContract({
101
94
  address: this.aztecNodeConfig.l1Contracts.inboxAddress.toString(),
102
95
  abi: InboxAbi,
103
- client: walletClient
96
+ client: l1Client
104
97
  });
105
98
  const outbox = getContract({
106
99
  address: this.aztecNodeConfig.l1Contracts.outboxAddress.toString(),
107
100
  abi: OutboxAbi,
108
- client: walletClient
101
+ client: l1Client
109
102
  });
110
- this.crossChainTestHarness = new CrossChainTestHarness(this.aztecNode, this.pxe, this.logger, this.l2Token, this.l2Bridge, this.ethAccount, tokenPortalAddress, crossChainContext.underlying, publicClient, walletClient, this.aztecNodeConfig.l1Contracts, this.user1Wallet);
111
- this.publicClient = publicClient;
103
+ this.crossChainTestHarness = new CrossChainTestHarness(this.aztecNode, this.pxe, this.logger, this.l2Token, this.l2Bridge, this.ethAccount, tokenPortalAddress, crossChainContext.underlying, l1Client, this.aztecNodeConfig.l1Contracts, this.user1Wallet, this.user1Address);
104
+ this.l1Client = l1Client;
112
105
  this.inbox = inbox;
113
106
  this.outbox = outbox;
114
107
  });
115
108
  }
116
- toCrossChainContext() {
117
- return {
118
- l2Token: this.crossChainTestHarness.l2Token.address,
119
- l2Bridge: this.crossChainTestHarness.l2Bridge.address,
120
- tokenPortal: this.crossChainTestHarness.tokenPortalAddress,
121
- underlying: this.crossChainTestHarness.underlyingERC20Address,
122
- ethAccount: this.crossChainTestHarness.ethAccount,
123
- ownerAddress: this.crossChainTestHarness.ownerAddress,
124
- inbox: this.crossChainTestHarness.l1ContractAddresses.inboxAddress,
125
- outbox: this.crossChainTestHarness.l1ContractAddresses.outboxAddress
126
- };
127
- }
128
109
  }
@@ -1,12 +1,14 @@
1
1
  import { type AccountWallet, type AztecAddress, type AztecNode, type ContractArtifact, type ContractBase, Fr, type Logger, type PXE, type PublicKeys, type Wallet } from '@aztec/aztec.js';
2
- import type { StatefulTestContract } from '@aztec/noir-contracts.js/StatefulTest';
2
+ import type { StatefulTestContract } from '@aztec/noir-test-contracts.js/StatefulTest';
3
+ import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
3
4
  export declare class DeployTest {
4
5
  private snapshotManager;
5
- private wallets;
6
6
  logger: Logger;
7
7
  pxe: PXE;
8
8
  wallet: AccountWallet;
9
+ defaultAccountAddress: AztecAddress;
9
10
  aztecNode: AztecNode;
11
+ aztecNodeAdmin: AztecNodeAdmin;
10
12
  constructor(testName: string);
11
13
  setup(): Promise<this>;
12
14
  teardown(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"deploy_test.d.ts","sourceRoot":"","sources":["../../src/e2e_deploy_contract/deploy_test.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,EAAE,EACF,KAAK,MAAM,EACX,KAAK,GAAG,EACR,KAAK,UAAU,EACf,KAAK,MAAM,EAGZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAMlF,qBAAa,UAAU;IACrB,OAAO,CAAC,eAAe,CAAmB;IAC1C,OAAO,CAAC,OAAO,CAAuB;IAE/B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAG,GAAG,CAAC;IACV,MAAM,EAAG,aAAa,CAAC;IACvB,SAAS,EAAG,SAAS,CAAC;gBAEjB,QAAQ,EAAE,MAAM;IAKtB,KAAK;IAOL,QAAQ;YAIA,2BAA2B;IAYnC,gBAAgB,CAAC,CAAC,SAAS,YAAY,EAC3C,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,qBAAqB,CAAC,CAAC,CAAC,EAC1C,IAAI,GAAE;QACJ,IAAI,CAAC,EAAE,EAAE,CAAC;QACV,UA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