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

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 +100 -303
  113. package/dest/spartan/utils.d.ts.map +1 -1
  114. package/dest/spartan/utils.js +407 -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 +458 -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,39 +1,183 @@
1
- import { getSchnorrAccount } from '@aztec/accounts/schnorr';
2
- import { TxStatus } from '@aztec/aztec.js';
3
- import { createPXEService, getPXEServiceConfig as getRpcConfig } from '@aztec/pxe/server';
1
+ import { getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
2
+ import { Fr } from '@aztec/aztec.js/fields';
3
+ import { TxStatus } from '@aztec/aztec.js/tx';
4
+ import { timesAsync, unique } from '@aztec/foundation/collection';
5
+ import { retryUntil } from '@aztec/foundation/retry';
6
+ import { pluralize } from '@aztec/foundation/string';
7
+ import { TestContract, TestContractArtifact } from '@aztec/noir-test-contracts.js/Test';
8
+ import { getPXEConfig, getPXEConfig as getRpcConfig } from '@aztec/pxe/server';
9
+ import { getRoundForOffense } from '@aztec/slasher';
10
+ import { TestWallet, proveInteraction } from '@aztec/test-wallet/server';
4
11
  import { submitTxsTo } from '../shared/submit-transactions.js';
5
12
  // submits a set of transactions to the provided Private eXecution Environment (PXE)
6
- export const submitComplexTxsTo = async (logger, spamContract, numTxs, opts = {})=>{
13
+ export const submitComplexTxsTo = async (logger, from, spamContract, numTxs, opts = {})=>{
7
14
  const txs = [];
8
15
  const seed = 1234n;
9
16
  const spamCount = 15;
10
17
  for(let i = 0; i < numTxs; i++){
11
18
  const tx = spamContract.methods.spam(seed + BigInt(i * spamCount), spamCount, !!opts.callPublic).send({
12
- skipPublicSimulation: true
19
+ from
13
20
  });
14
21
  const txHash = await tx.getTxHash();
15
- logger.info(`Tx sent with hash ${txHash}`);
22
+ logger.info(`Tx sent with hash ${txHash.toString()}`);
16
23
  const receipt = await tx.getReceipt();
17
24
  expect(receipt).toEqual(expect.objectContaining({
18
25
  status: TxStatus.PENDING,
19
26
  error: ''
20
27
  }));
21
- logger.info(`Receipt received for ${txHash}`);
28
+ logger.info(`Receipt received for ${txHash.toString()}`);
22
29
  txs.push(tx);
23
30
  }
24
31
  return txs;
25
32
  };
26
- // creates an instance of the PXE and submit a given number of transactions to it.
27
- export const createPXEServiceAndSubmitTransactions = async (logger, node, numTxs, fundedAccount)=>{
33
+ // creates a wallet and submit a given number of transactions through it.
34
+ export const submitTransactions = async (logger, node, numTxs, fundedAccount)=>{
28
35
  const rpcConfig = getRpcConfig();
29
- const pxeService = await createPXEService(node, rpcConfig, true);
30
- const account = await getSchnorrAccount(pxeService, fundedAccount.secret, fundedAccount.signingKey, fundedAccount.salt);
31
- await account.register();
32
- const wallet = await account.getWallet();
33
- const txs = await submitTxsTo(pxeService, numTxs, wallet, logger);
34
- return {
35
- txs,
36
- pxeService,
37
- node
38
- };
36
+ rpcConfig.proverEnabled = false;
37
+ const wallet = await TestWallet.create(node, {
38
+ ...getPXEConfig(),
39
+ proverEnabled: false
40
+ }, {
41
+ useLogSuffix: true
42
+ });
43
+ const fundedAccountManager = await wallet.createSchnorrAccount(fundedAccount.secret, fundedAccount.salt);
44
+ return submitTxsTo(wallet, fundedAccountManager.address, numTxs, logger);
39
45
  };
46
+ export async function prepareTransactions(logger, node, numTxs, fundedAccount) {
47
+ const rpcConfig = getRpcConfig();
48
+ rpcConfig.proverEnabled = false;
49
+ const wallet = await TestWallet.create(node, {
50
+ ...getPXEConfig(),
51
+ proverEnabled: false
52
+ }, {
53
+ useLogSuffix: true
54
+ });
55
+ const fundedAccountManager = await wallet.createSchnorrAccount(fundedAccount.secret, fundedAccount.salt);
56
+ const testContractInstance = await getContractInstanceFromInstantiationParams(TestContractArtifact, {
57
+ salt: Fr.random()
58
+ });
59
+ await wallet.registerContract(testContractInstance, TestContractArtifact);
60
+ const contract = await TestContract.at(testContractInstance.address, wallet);
61
+ return timesAsync(numTxs, async ()=>{
62
+ const tx = await proveInteraction(wallet, contract.methods.emit_nullifier(Fr.random()), {
63
+ from: fundedAccountManager.address
64
+ });
65
+ const txHash = tx.getTxHash();
66
+ logger.info(`Tx prepared with hash ${txHash}`);
67
+ return tx;
68
+ });
69
+ }
70
+ export function awaitProposalExecution(slashingProposer, timeoutSeconds, logger) {
71
+ return new Promise((resolve, reject)=>{
72
+ const timeout = setTimeout(()=>{
73
+ logger.warn(`Timed out waiting for proposal execution`);
74
+ reject(new Error(`Timeout waiting for proposal execution after ${timeoutSeconds}s`));
75
+ }, timeoutSeconds * 1000);
76
+ if (slashingProposer.type === 'empire') {
77
+ const unwatch = slashingProposer.listenToPayloadSubmitted((args)=>{
78
+ logger.warn(`Proposal ${args.payload} from round ${args.round} executed`);
79
+ clearTimeout(timeout);
80
+ unwatch();
81
+ resolve(args.round);
82
+ });
83
+ } else if (slashingProposer.type === 'tally') {
84
+ const unwatch = slashingProposer.listenToRoundExecuted((args)=>{
85
+ logger.warn(`Slash from round ${args.round} executed`);
86
+ clearTimeout(timeout);
87
+ unwatch();
88
+ resolve(args.round);
89
+ });
90
+ } else {
91
+ clearTimeout(timeout);
92
+ reject(new Error(`Unknown slashing proposer type: ${slashingProposer.type}`));
93
+ }
94
+ });
95
+ }
96
+ export async function awaitCommitteeExists({ rollup, logger }) {
97
+ logger.info(`Waiting for committee to be set`);
98
+ let committee;
99
+ await retryUntil(async ()=>{
100
+ committee = await rollup.getCurrentEpochCommittee();
101
+ return committee && committee.length > 0;
102
+ }, 'non-empty committee', 60);
103
+ return committee;
104
+ }
105
+ export async function awaitOffenseDetected({ logger, nodeAdmin, slashingRoundSize, epochDuration, waitUntilOffenseCount, timeoutSeconds = 120 }) {
106
+ const targetOffenseCount = waitUntilOffenseCount ?? 1;
107
+ logger.warn(`Waiting for ${pluralize('offense', targetOffenseCount)} to be detected`);
108
+ const offenses = await retryUntil(async ()=>{
109
+ const offenses = await nodeAdmin.getSlashOffenses('all');
110
+ if (offenses.length >= targetOffenseCount) {
111
+ return offenses;
112
+ }
113
+ }, 'non-empty offenses', timeoutSeconds);
114
+ logger.info(`Hit ${offenses.length} offenses on rounds ${unique(offenses.map((o)=>getRoundForOffense(o, {
115
+ slashingRoundSize,
116
+ epochDuration
117
+ })))}`, {
118
+ offenses
119
+ });
120
+ return offenses;
121
+ }
122
+ /**
123
+ * Await the committee to be slashed out of the validator set.
124
+ * Currently assumes that the committee is the same size as the validator set.
125
+ */ export async function awaitCommitteeKicked({ rollup, cheatCodes, committee, slashFactory, slashingProposer, slashingRoundSize, aztecSlotDuration, aztecEpochDuration, logger, offenseEpoch }) {
126
+ if (!slashingProposer) {
127
+ throw new Error('No slashing proposer configured. Cannot test slashing.');
128
+ }
129
+ await cheatCodes.debugRollup();
130
+ if (slashingProposer.type === 'empire') {
131
+ // Await for the slash payload to be created if empire (no payload is created on tally until execution time)
132
+ const targetEpoch = await cheatCodes.getEpoch() + await rollup.getLagInEpochs() + 1n;
133
+ logger.info(`Advancing to epoch ${targetEpoch} so we start slashing`);
134
+ await cheatCodes.advanceToEpoch(targetEpoch);
135
+ const slashPayloadEvents = await retryUntil(async ()=>{
136
+ const events = await slashFactory.getSlashPayloadCreatedEvents();
137
+ return events.length > 0 ? events : undefined;
138
+ }, 'slash payload created', 120, 1);
139
+ expect(slashPayloadEvents.length).toBe(1);
140
+ // The uniqueness check is needed since a validator may be slashed more than once on the same round (eg because they let two epochs be pruned)
141
+ expect(unique(slashPayloadEvents[0].slashes.map((slash)=>slash.validator.toString()))).toHaveLength(committee.length);
142
+ } else {
143
+ // Use the slash offset to ensure we are in the right epoch for tally
144
+ const slashOffsetInRounds = await slashingProposer.getSlashOffsetInRounds();
145
+ const slashingRoundSizeInEpochs = slashingRoundSize / aztecEpochDuration;
146
+ const slashingOffsetInEpochs = Number(slashOffsetInRounds) * slashingRoundSizeInEpochs;
147
+ const firstEpochInOffenseRound = offenseEpoch - offenseEpoch % slashingRoundSizeInEpochs;
148
+ const targetEpoch = firstEpochInOffenseRound + slashingOffsetInEpochs;
149
+ logger.info(`Advancing to epoch ${targetEpoch} so we start slashing`);
150
+ await cheatCodes.advanceToEpoch(targetEpoch, {
151
+ offset: -aztecSlotDuration / 2
152
+ });
153
+ }
154
+ const attestersPre = await rollup.getAttesters();
155
+ expect(attestersPre.length).toBe(committee.length);
156
+ for (const attester of attestersPre){
157
+ const attesterInfo = await rollup.getAttesterView(attester);
158
+ expect(attesterInfo.status).toEqual(1); // Validating
159
+ }
160
+ const timeout = slashingRoundSize * 2 * aztecSlotDuration + 30;
161
+ logger.info(`Waiting for slash to be executed (timeout ${timeout}s)`);
162
+ await awaitProposalExecution(slashingProposer, timeout, logger);
163
+ // The attesters should still form the committee but they should be reduced to the "living" status
164
+ await cheatCodes.debugRollup();
165
+ const committeePostSlashing = await rollup.getCurrentEpochCommittee();
166
+ expect(committeePostSlashing?.length).toBe(attestersPre.length);
167
+ const attestersPostSlashing = await rollup.getAttesters();
168
+ expect(attestersPostSlashing.length).toBe(0);
169
+ for (const attester of attestersPre){
170
+ const attesterInfo = await rollup.getAttesterView(attester);
171
+ expect(attesterInfo.status).toEqual(2); // Living
172
+ }
173
+ logger.info(`Advancing to check current committee`);
174
+ await cheatCodes.debugRollup();
175
+ await cheatCodes.advanceToEpoch(await cheatCodes.getEpoch() + await rollup.getLagInEpochs() + 1n);
176
+ await cheatCodes.debugRollup();
177
+ const committeeNextEpoch = await rollup.getCurrentEpochCommittee();
178
+ // The committee should be undefined, since the validator set is empty
179
+ // and the tests currently using this helper always set a target committee size.
180
+ expect(committeeNextEpoch).toBeUndefined();
181
+ const attestersNextEpoch = await rollup.getAttesters();
182
+ expect(attestersNextEpoch.length).toBe(0);
183
+ }
@@ -1,6 +1,9 @@
1
- import { type AccountWallet, type CompleteAddress, type Logger } from '@aztec/aztec.js';
2
- import { DocsExampleContract } from '@aztec/noir-contracts.js/DocsExample';
1
+ import { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import { type Logger } from '@aztec/aztec.js/log';
3
+ import type { AztecNode } from '@aztec/aztec.js/node';
3
4
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
5
+ import { InvalidAccountContract } from '@aztec/noir-test-contracts.js/InvalidAccount';
6
+ import type { TestWallet } from '@aztec/test-wallet/server';
4
7
  import { type SubsystemsContext } from '../fixtures/snapshot_manager.js';
5
8
  import { TokenSimulator } from '../simulators/token_simulator.js';
6
9
  export declare class TokenContractTest {
@@ -9,11 +12,14 @@ export declare class TokenContractTest {
9
12
  static TOKEN_DECIMALS: bigint;
10
13
  private snapshotManager;
11
14
  logger: Logger;
12
- wallets: AccountWallet[];
13
- accounts: CompleteAddress[];
14
15
  asset: TokenContract;
15
16
  tokenSim: TokenSimulator;
16
- badAccount: DocsExampleContract;
17
+ node: AztecNode;
18
+ badAccount: InvalidAccountContract;
19
+ wallet: TestWallet;
20
+ adminAddress: AztecAddress;
21
+ account1Address: AztecAddress;
22
+ account2Address: AztecAddress;
17
23
  constructor(testName: string);
18
24
  /**
19
25
  * Adds two state shifts to snapshot manager.
@@ -1 +1 @@
1
- {"version":3,"file":"token_contract_test.d.ts","sourceRoot":"","sources":["../../src/e2e_token_contract/token_contract_test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,KAAK,MAAM,EAAgB,MAAM,iBAAiB,CAAC;AACtG,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAI/D,OAAO,EAEL,KAAK,iBAAiB,EAIvB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAIlE,qBAAa,iBAAiB;IAC5B,MAAM,CAAC,UAAU,SAAU;IAC3B,MAAM,CAAC,YAAY,SAAS;IAC5B,MAAM,CAAC,cAAc,SAAO;IAC5B,OAAO,CAAC,eAAe,CAAmB;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,aAAa,EAAE,CAAM;IAC9B,QAAQ,EAAE,eAAe,EAAE,CAAM;IACjC,KAAK,EAAG,aAAa,CAAC;IACtB,QAAQ,EAAG,cAAc,CAAC;IAC1B,UAAU,EAAG,mBAAmB,CAAC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C/B,eAAe,EAAG,YAAY,CAAC;gBAEnB,QAAQ,EAAE,MAAM;IAO5B;;;;OAIG;IACG,kBAAkB;IAkElB,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,iBAAiB;CAqCxB"}
@@ -1,7 +1,6 @@
1
- import { getSchnorrWallet } from '@aztec/accounts/schnorr';
2
- import { createLogger } from '@aztec/aztec.js';
3
- import { DocsExampleContract } from '@aztec/noir-contracts.js/DocsExample';
1
+ import { createLogger } from '@aztec/aztec.js/log';
4
2
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
3
+ import { InvalidAccountContract } from '@aztec/noir-test-contracts.js/InvalidAccount';
5
4
  import { jest } from '@jest/globals';
6
5
  import { createSnapshotManager, deployAccounts, publicDeployAccounts } from '../fixtures/snapshot_manager.js';
7
6
  import { mintTokensToPrivate } from '../fixtures/token_utils.js';
@@ -13,11 +12,14 @@ export class TokenContractTest {
13
12
  static TOKEN_DECIMALS = 18n;
14
13
  snapshotManager;
15
14
  logger;
16
- wallets = [];
17
- accounts = [];
18
15
  asset;
19
16
  tokenSim;
17
+ node;
20
18
  badAccount;
19
+ wallet;
20
+ adminAddress;
21
+ account1Address;
22
+ account2Address;
21
23
  constructor(testName){
22
24
  this.logger = createLogger(`e2e:e2e_token_contract:${testName}`);
23
25
  this.snapshotManager = createSnapshotManager(`e2e_token_contract/${testName}`, dataPath, {
@@ -31,20 +33,29 @@ export class TokenContractTest {
31
33
  */ async applyBaseSnapshots() {
32
34
  // Adding a timeout of 2 minutes in here such that it is propagated to the underlying tests
33
35
  jest.setTimeout(120_000);
34
- await this.snapshotManager.snapshot('3_accounts', deployAccounts(3, this.logger), async ({ deployedAccounts }, { pxe })=>{
35
- this.wallets = await Promise.all(deployedAccounts.map((a)=>getSchnorrWallet(pxe, a.address, a.signingKey)));
36
- this.accounts = this.wallets.map((w)=>w.getCompleteAddress());
36
+ await this.snapshotManager.snapshot('3_accounts', deployAccounts(3, this.logger), ({ deployedAccounts }, { wallet, aztecNode })=>{
37
+ this.node = aztecNode;
38
+ this.wallet = wallet;
39
+ [this.adminAddress, this.account1Address, this.account2Address] = deployedAccounts.map((acc)=>acc.address);
40
+ return Promise.resolve();
37
41
  });
38
42
  await this.snapshotManager.snapshot('e2e_token_contract', async ()=>{
39
43
  // Create the token contract state.
40
44
  // Move this account thing to addAccounts above?
41
45
  this.logger.verbose(`Public deploy accounts...`);
42
- await publicDeployAccounts(this.wallets[0], this.accounts.slice(0, 2));
46
+ await publicDeployAccounts(this.wallet, [
47
+ this.adminAddress,
48
+ this.account1Address
49
+ ]);
43
50
  this.logger.verbose(`Deploying TokenContract...`);
44
- const asset = await TokenContract.deploy(this.wallets[0], this.accounts[0], TokenContractTest.TOKEN_NAME, TokenContractTest.TOKEN_SYMBOL, TokenContractTest.TOKEN_DECIMALS).send().deployed();
51
+ const asset = await TokenContract.deploy(this.wallet, this.adminAddress, TokenContractTest.TOKEN_NAME, TokenContractTest.TOKEN_SYMBOL, TokenContractTest.TOKEN_DECIMALS).send({
52
+ from: this.adminAddress
53
+ }).deployed();
45
54
  this.logger.verbose(`Token deployed to ${asset.address}`);
46
55
  this.logger.verbose(`Deploying bad account...`);
47
- this.badAccount = await DocsExampleContract.deploy(this.wallets[0]).send().deployed();
56
+ this.badAccount = await InvalidAccountContract.deploy(this.wallet).send({
57
+ from: this.adminAddress
58
+ }).deployed();
48
59
  this.logger.verbose(`Deployed to ${this.badAccount.address}.`);
49
60
  return {
50
61
  tokenContractAddress: asset.address,
@@ -52,12 +63,17 @@ export class TokenContractTest {
52
63
  };
53
64
  }, async ({ tokenContractAddress, badAccountAddress })=>{
54
65
  // Restore the token contract state.
55
- this.asset = await TokenContract.at(tokenContractAddress, this.wallets[0]);
66
+ this.asset = await TokenContract.at(tokenContractAddress, this.wallet);
56
67
  this.logger.verbose(`Token contract address: ${this.asset.address}`);
57
- this.tokenSim = new TokenSimulator(this.asset, this.wallets[0], this.logger, this.accounts.map((a)=>a.address));
58
- this.badAccount = await DocsExampleContract.at(badAccountAddress, this.wallets[0]);
68
+ this.tokenSim = new TokenSimulator(this.asset, this.wallet, this.adminAddress, this.logger, [
69
+ this.adminAddress,
70
+ this.account1Address
71
+ ]);
72
+ this.badAccount = await InvalidAccountContract.at(badAccountAddress, this.wallet);
59
73
  this.logger.verbose(`Bad account address: ${this.badAccount.address}`);
60
- expect(await this.asset.methods.get_admin().simulate()).toBe(this.accounts[0].address.toBigInt());
74
+ expect(await this.asset.methods.get_admin().simulate({
75
+ from: this.adminAddress
76
+ })).toBe(this.adminAddress.toBigInt());
61
77
  });
62
78
  // TokenContract.artifact.functions.forEach(fn => {
63
79
  // const sig = decodeFunctionSignature(fn.name, fn.parameters);
@@ -73,27 +89,35 @@ export class TokenContractTest {
73
89
  }
74
90
  async applyMintSnapshot() {
75
91
  await this.snapshotManager.snapshot('mint', async ()=>{
76
- const { asset, wallets } = this;
92
+ const { asset, adminAddress } = this;
77
93
  const amount = 10000n;
78
94
  this.logger.verbose(`Minting ${amount} publicly...`);
79
- await asset.methods.mint_to_public(wallets[0].getAddress(), amount).send().wait();
95
+ await asset.methods.mint_to_public(adminAddress, amount).send({
96
+ from: adminAddress
97
+ }).wait();
80
98
  this.logger.verbose(`Minting ${amount} privately...`);
81
- await mintTokensToPrivate(asset, wallets[0], wallets[0].getAddress(), amount);
99
+ await mintTokensToPrivate(asset, adminAddress, adminAddress, amount);
82
100
  this.logger.verbose(`Minting complete.`);
83
101
  return {
84
102
  amount
85
103
  };
86
104
  }, async ({ amount })=>{
87
- const { asset, accounts: [{ address }], tokenSim } = this;
88
- tokenSim.mintPublic(address, amount);
89
- const publicBalance = await asset.methods.balance_of_public(address).simulate();
105
+ const { asset, adminAddress, tokenSim } = this;
106
+ tokenSim.mintPublic(adminAddress, amount);
107
+ const publicBalance = await asset.methods.balance_of_public(adminAddress).simulate({
108
+ from: adminAddress
109
+ });
90
110
  this.logger.verbose(`Public balance of wallet 0: ${publicBalance}`);
91
- expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(address));
92
- tokenSim.mintPrivate(address, amount);
93
- const privateBalance = await asset.methods.balance_of_private(address).simulate();
111
+ expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(adminAddress));
112
+ tokenSim.mintPrivate(adminAddress, amount);
113
+ const privateBalance = await asset.methods.balance_of_private(adminAddress).simulate({
114
+ from: adminAddress
115
+ });
94
116
  this.logger.verbose(`Private balance of wallet 0: ${privateBalance}`);
95
- expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(address));
96
- const totalSupply = await asset.methods.total_supply().simulate();
117
+ expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(adminAddress));
118
+ const totalSupply = await asset.methods.total_supply().simulate({
119
+ from: adminAddress
120
+ });
97
121
  this.logger.verbose(`Total supply: ${totalSupply}`);
98
122
  expect(totalSupply).toEqual(tokenSim.totalSupply);
99
123
  return Promise.resolve();
@@ -1,11 +1,16 @@
1
1
  import type { InitialAccountData } from '@aztec/accounts/testing';
2
- import { type AccountWalletWithSecretKey, type AztecNode, type CheatCodes, type CompleteAddress, type DeployL1ContractsReturnType, EthAddress, type Logger } from '@aztec/aztec.js';
2
+ import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
3
+ import { type Logger } from '@aztec/aztec.js/log';
4
+ import type { AztecNode } from '@aztec/aztec.js/node';
5
+ import { CheatCodes } from '@aztec/aztec/testing';
3
6
  import { type ClientProtocolCircuitVerifier } from '@aztec/bb-prover';
4
7
  import type { BlobSinkServer } from '@aztec/blob-sink/server';
8
+ import type { DeployL1ContractsReturnType } from '@aztec/ethereum';
5
9
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
6
- import type { PXEService } from '@aztec/pxe/server';
7
- import { type SubsystemsContext } from '../fixtures/snapshot_manager.js';
10
+ import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
11
+ import { TestWallet } from '@aztec/test-wallet/server';
8
12
  import { TokenSimulator } from '../simulators/token_simulator.js';
13
+ import { type SubsystemsContext } from './snapshot_manager.js';
9
14
  /**
10
15
  * Largely taken from the e2e_token_contract test file. We deploy 2 accounts and a token contract.
11
16
  * However, we then setup a second PXE with a full prover instance.
@@ -20,20 +25,21 @@ export declare class FullProverTest {
20
25
  static TOKEN_DECIMALS: bigint;
21
26
  private snapshotManager;
22
27
  logger: Logger;
28
+ wallet: TestWallet;
29
+ provenWallet: TestWallet;
30
+ accounts: AztecAddress[];
23
31
  deployedAccounts: InitialAccountData[];
24
- wallets: AccountWalletWithSecretKey[];
25
- accounts: CompleteAddress[];
26
32
  fakeProofsAsset: TokenContract;
27
33
  tokenSim: TokenSimulator;
28
34
  aztecNode: AztecNode;
29
- pxe: PXEService;
35
+ aztecNodeAdmin: AztecNodeAdmin;
30
36
  cheatCodes: CheatCodes;
31
37
  blobSink: BlobSinkServer;
32
38
  private provenComponents;
33
39
  private bbConfigCleanup?;
34
40
  private acvmConfigCleanup?;
35
41
  circuitProofVerifier?: ClientProtocolCircuitVerifier;
36
- provenAssets: TokenContract[];
42
+ provenAsset: TokenContract;
37
43
  private context;
38
44
  private proverNode;
39
45
  private simulatedProverNode;
@@ -47,10 +53,9 @@ export declare class FullProverTest {
47
53
  */
48
54
  applyBaseSnapshots(): Promise<void>;
49
55
  setup(): Promise<this>;
50
- private mintL1ERC20;
56
+ private mintFeeJuice;
51
57
  snapshot: <T>(name: string, apply: (context: SubsystemsContext) => Promise<T>, restore?: (snapshotData: T, context: SubsystemsContext) => Promise<void>) => Promise<void>;
52
58
  teardown(): Promise<void>;
53
59
  applyMintSnapshot(): Promise<void>;
54
- deployVerifier(): Promise<void>;
55
60
  }
56
61
  //# sourceMapping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