@aztec/end-to-end 3.0.0-nightly.20250924 → 3.0.0-nightly.20250926
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.
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +4 -7
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +1 -1
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +1 -1
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.d.ts +1 -1
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.d.ts +1 -1
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.d.ts +1 -1
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.d.ts +2 -8
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +15 -21
- package/dest/e2e_token_contract/token_contract_test.d.ts +1 -1
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.d.ts +1 -1
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.d.ts +4 -7
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +37 -20
- package/dest/fixtures/snapshot_manager.d.ts +1 -1
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +4 -6
- package/dest/fixtures/utils.d.ts +1 -1
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +16 -28
- package/dest/fixtures/web3signer.d.ts +5 -0
- package/dest/fixtures/web3signer.d.ts.map +1 -0
- package/dest/fixtures/web3signer.js +42 -0
- package/dest/shared/submit-transactions.d.ts +1 -1
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.d.ts +3 -3
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +17 -19
- package/package.json +37 -37
- package/src/bench/client_flows/client_flows_benchmark.ts +3 -6
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +1 -1
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +1 -1
- package/src/e2e_deploy_contract/deploy_test.ts +1 -1
- package/src/e2e_fees/bridging_race.notest.ts +1 -1
- package/src/e2e_fees/fees_test.ts +1 -1
- package/src/e2e_p2p/p2p_network.ts +1 -1
- package/src/e2e_p2p/shared.ts +19 -17
- package/src/e2e_token_contract/token_contract_test.ts +1 -1
- package/src/fixtures/e2e_prover_test.ts +1 -1
- package/src/fixtures/setup_p2p_test.ts +53 -24
- package/src/fixtures/snapshot_manager.ts +4 -6
- package/src/fixtures/utils.ts +17 -30
- package/src/fixtures/web3signer.ts +46 -0
- package/src/shared/submit-transactions.ts +1 -1
- package/src/shared/uniswap_l1_l2.ts +1 -1
- package/src/spartan/setup_test_wallets.ts +17 -26
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
* Test fixtures and utilities to set up and run a test using multiple validators
|
|
3
3
|
*/
|
|
4
4
|
import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
|
|
5
|
-
import type { SentTx } from '@aztec/aztec.js';
|
|
6
5
|
import { SecretValue } from '@aztec/foundation/config';
|
|
7
6
|
import { addLogNameHandler, removeLogNameHandler } from '@aztec/foundation/log';
|
|
8
7
|
import { bufferToHex } from '@aztec/foundation/string';
|
|
9
8
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
10
9
|
import type { ProverNodeConfig, ProverNodeDeps } from '@aztec/prover-node';
|
|
11
|
-
import type { PXEService } from '@aztec/pxe/server';
|
|
12
10
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
13
11
|
|
|
14
12
|
import getPort from 'get-port';
|
|
@@ -23,12 +21,6 @@ import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
|
|
|
23
21
|
// to avoid running validators with the same key
|
|
24
22
|
export const ATTESTER_PRIVATE_KEYS_START_INDEX = 3;
|
|
25
23
|
|
|
26
|
-
export interface NodeContext {
|
|
27
|
-
node: AztecNodeService;
|
|
28
|
-
pxeService: PXEService;
|
|
29
|
-
txs: SentTx[];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
24
|
export function generatePrivateKeys(startIndex: number, numberOfKeys: number): `0x${string}`[] {
|
|
33
25
|
const privateKeys: `0x${string}`[] = [];
|
|
34
26
|
// Do not start from 0 as it is used during setup
|
|
@@ -86,7 +78,7 @@ export async function createNodes(
|
|
|
86
78
|
return nodes;
|
|
87
79
|
}
|
|
88
80
|
|
|
89
|
-
|
|
81
|
+
/** Creates a P2P enabled instance of Aztec Node Service with a validator */
|
|
90
82
|
export async function createNode(
|
|
91
83
|
config: AztecNodeConfig & { dontStartSequencer?: boolean },
|
|
92
84
|
dateProvider: DateProvider,
|
|
@@ -110,6 +102,31 @@ export async function createNode(
|
|
|
110
102
|
return loggerIdStorage ? await loggerIdStorage.run(tcpPort.toString(), createNode) : createNode();
|
|
111
103
|
}
|
|
112
104
|
|
|
105
|
+
/** Creates a P2P enabled instance of Aztec Node Service without a validator */
|
|
106
|
+
export async function createNonValidatorNode(
|
|
107
|
+
baseConfig: AztecNodeConfig,
|
|
108
|
+
dateProvider: DateProvider,
|
|
109
|
+
tcpPort: number,
|
|
110
|
+
bootstrapNode: string | undefined,
|
|
111
|
+
prefilledPublicData?: PublicDataTreeLeaf[],
|
|
112
|
+
dataDirectory?: string,
|
|
113
|
+
metricsPort?: number,
|
|
114
|
+
loggerIdStorage?: AsyncLocalStorage<string>,
|
|
115
|
+
) {
|
|
116
|
+
const createNode = async () => {
|
|
117
|
+
const p2pConfig = await createP2PConfig(baseConfig, bootstrapNode, tcpPort, dataDirectory);
|
|
118
|
+
const config: AztecNodeConfig = {
|
|
119
|
+
...p2pConfig,
|
|
120
|
+
disableValidator: true,
|
|
121
|
+
validatorPrivateKeys: undefined,
|
|
122
|
+
publisherPrivateKeys: [],
|
|
123
|
+
};
|
|
124
|
+
const telemetry = getEndToEndTestTelemetryClient(metricsPort);
|
|
125
|
+
return await AztecNodeService.createAndSync(config, { telemetry, dateProvider }, { prefilledPublicData });
|
|
126
|
+
};
|
|
127
|
+
return loggerIdStorage ? await loggerIdStorage.run(tcpPort.toString(), createNode) : createNode();
|
|
128
|
+
}
|
|
129
|
+
|
|
113
130
|
export async function createProverNode(
|
|
114
131
|
config: AztecNodeConfig,
|
|
115
132
|
tcpPort: number,
|
|
@@ -125,14 +142,13 @@ export async function createProverNode(
|
|
|
125
142
|
const proverNodePrivateKey = getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex)!;
|
|
126
143
|
const telemetry = getEndToEndTestTelemetryClient(metricsPort);
|
|
127
144
|
|
|
128
|
-
const proverConfig: Partial<ProverNodeConfig> =
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
};
|
|
145
|
+
const proverConfig: Partial<ProverNodeConfig> = await createP2PConfig(
|
|
146
|
+
config,
|
|
147
|
+
bootstrapNode,
|
|
148
|
+
tcpPort,
|
|
149
|
+
dataDirectory,
|
|
150
|
+
);
|
|
151
|
+
|
|
136
152
|
const aztecNodeRpcTxProvider = undefined;
|
|
137
153
|
return await createAndSyncProverNode(
|
|
138
154
|
bufferToHex(proverNodePrivateKey),
|
|
@@ -146,20 +162,14 @@ export async function createProverNode(
|
|
|
146
162
|
return loggerIdStorage ? await loggerIdStorage.run(tcpPort.toString(), createProverNode) : createProverNode();
|
|
147
163
|
}
|
|
148
164
|
|
|
149
|
-
export async function
|
|
165
|
+
export async function createP2PConfig(
|
|
150
166
|
config: AztecNodeConfig,
|
|
151
167
|
bootstrapNodeEnr?: string,
|
|
152
168
|
port?: number,
|
|
153
|
-
addressIndex: number = 1,
|
|
154
169
|
dataDirectory?: string,
|
|
155
170
|
) {
|
|
156
171
|
port = port ?? (await getPort());
|
|
157
172
|
|
|
158
|
-
const attesterPrivateKey = bufferToHex(getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex)!);
|
|
159
|
-
|
|
160
|
-
config.validatorPrivateKeys = new SecretValue([attesterPrivateKey]);
|
|
161
|
-
config.publisherPrivateKeys = [new SecretValue(attesterPrivateKey)];
|
|
162
|
-
|
|
163
173
|
const nodeConfig: AztecNodeConfig = {
|
|
164
174
|
...config,
|
|
165
175
|
p2pIp: `127.0.0.1`,
|
|
@@ -173,3 +183,22 @@ export async function createValidatorConfig(
|
|
|
173
183
|
|
|
174
184
|
return nodeConfig;
|
|
175
185
|
}
|
|
186
|
+
|
|
187
|
+
export async function createValidatorConfig(
|
|
188
|
+
config: AztecNodeConfig,
|
|
189
|
+
bootstrapNodeEnr?: string,
|
|
190
|
+
port?: number,
|
|
191
|
+
addressIndex: number = 1,
|
|
192
|
+
dataDirectory?: string,
|
|
193
|
+
) {
|
|
194
|
+
const attesterPrivateKey = bufferToHex(getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex)!);
|
|
195
|
+
const p2pConfig = await createP2PConfig(config, bootstrapNodeEnr, port, dataDirectory);
|
|
196
|
+
const nodeConfig: AztecNodeConfig = {
|
|
197
|
+
...config,
|
|
198
|
+
...p2pConfig,
|
|
199
|
+
validatorPrivateKeys: new SecretValue([attesterPrivateKey]),
|
|
200
|
+
publisherPrivateKeys: [new SecretValue(attesterPrivateKey)],
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
return nodeConfig;
|
|
204
|
+
}
|
|
@@ -31,11 +31,11 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
31
31
|
import { resolver, reviver } from '@aztec/foundation/serialize';
|
|
32
32
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
33
33
|
import type { ProverNode } from '@aztec/prover-node';
|
|
34
|
-
import {
|
|
34
|
+
import { getPXEServiceConfig } from '@aztec/pxe/server';
|
|
35
35
|
import type { SequencerClient } from '@aztec/sequencer-client';
|
|
36
36
|
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
37
37
|
import { getConfigEnvVars as getTelemetryConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
38
|
-
import { TestWallet } from '@aztec/test-wallet';
|
|
38
|
+
import { TestWallet } from '@aztec/test-wallet/server';
|
|
39
39
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
40
40
|
|
|
41
41
|
import type { Anvil } from '@viem/anvil';
|
|
@@ -446,8 +446,7 @@ async function setupFromFresh(
|
|
|
446
446
|
pxeConfig.dataDirectory = statePath ?? path.join(directoryToCleanup, randomBytes(8).toString('hex'));
|
|
447
447
|
// Only enable proving if specifically requested.
|
|
448
448
|
pxeConfig.proverEnabled = !!opts.realProofs;
|
|
449
|
-
const
|
|
450
|
-
const wallet = new TestWallet(pxe, aztecNode);
|
|
449
|
+
const wallet = await TestWallet.create(aztecNode, pxeConfig);
|
|
451
450
|
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, wallet, aztecNode, dateProvider);
|
|
452
451
|
|
|
453
452
|
if (statePath) {
|
|
@@ -575,8 +574,7 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
575
574
|
logger.verbose('Creating pxe...');
|
|
576
575
|
const pxeConfig = getPXEServiceConfig();
|
|
577
576
|
pxeConfig.dataDirectory = statePath;
|
|
578
|
-
const
|
|
579
|
-
const wallet = new TestWallet(pxe, aztecNode);
|
|
577
|
+
const wallet = await TestWallet.create(aztecNode, pxeConfig);
|
|
580
578
|
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, wallet, aztecNode, dateProvider);
|
|
581
579
|
|
|
582
580
|
return {
|
package/src/fixtures/utils.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
|
|
2
|
-
import { type InitialAccountData, generateSchnorrAccounts,
|
|
2
|
+
import { type InitialAccountData, generateSchnorrAccounts, getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
3
3
|
import { type Archiver, createArchiver } from '@aztec/archiver';
|
|
4
4
|
import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
|
|
5
5
|
import {
|
|
@@ -11,10 +11,8 @@ import {
|
|
|
11
11
|
type Wallet,
|
|
12
12
|
createAztecNodeClient,
|
|
13
13
|
createLogger,
|
|
14
|
-
createPXEClient,
|
|
15
|
-
makeFetch,
|
|
16
14
|
sleep,
|
|
17
|
-
|
|
15
|
+
waitForNode,
|
|
18
16
|
} from '@aztec/aztec.js';
|
|
19
17
|
import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
|
|
20
18
|
import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
|
|
@@ -56,11 +54,9 @@ import type { P2PClientDeps } from '@aztec/p2p';
|
|
|
56
54
|
import { MockGossipSubNetwork, getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
|
|
57
55
|
import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
58
56
|
import { type ProverNode, type ProverNodeConfig, type ProverNodeDeps, createProverNode } from '@aztec/prover-node';
|
|
59
|
-
import { type PXEServiceConfig,
|
|
57
|
+
import { type PXEServiceConfig, getPXEServiceConfig } from '@aztec/pxe/server';
|
|
60
58
|
import type { SequencerClient } from '@aztec/sequencer-client';
|
|
61
59
|
import type { TestSequencerClient } from '@aztec/sequencer-client/test';
|
|
62
|
-
import { MemoryCircuitRecorder, SimulatorRecorderWrapper, WASMSimulator } from '@aztec/simulator/client';
|
|
63
|
-
import { FileCircuitRecorder } from '@aztec/simulator/testing';
|
|
64
60
|
import {
|
|
65
61
|
type ContractInstanceWithAddress,
|
|
66
62
|
getContractClassFromArtifact,
|
|
@@ -77,7 +73,7 @@ import {
|
|
|
77
73
|
initTelemetryClient,
|
|
78
74
|
} from '@aztec/telemetry-client';
|
|
79
75
|
import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
|
|
80
|
-
import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet';
|
|
76
|
+
import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet/server';
|
|
81
77
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
82
78
|
|
|
83
79
|
import type { Anvil } from '@viem/anvil';
|
|
@@ -97,8 +93,8 @@ import { isMetricsLoggingRequested, setupMetricsLogger } from './logging.js';
|
|
|
97
93
|
export { deployAndInitializeTokenAndBridgeContracts } from '../shared/cross_chain_test_harness.js';
|
|
98
94
|
export { startAnvil };
|
|
99
95
|
|
|
100
|
-
const {
|
|
101
|
-
const getAztecUrl = () =>
|
|
96
|
+
const { AZTEC_NODE_URL = '' } = process.env;
|
|
97
|
+
const getAztecUrl = () => AZTEC_NODE_URL;
|
|
102
98
|
|
|
103
99
|
let telemetry: TelemetryClient | undefined = undefined;
|
|
104
100
|
function getTelemetryClient(partialConfig: Partial<TelemetryClientConfig> & { benchmark?: boolean } = {}) {
|
|
@@ -178,18 +174,11 @@ export async function setupPXEServiceAndGetWallet(
|
|
|
178
174
|
pxeServiceConfig.dataDirectory = path.join(tmpdir(), randomBytes(8).toString('hex'));
|
|
179
175
|
}
|
|
180
176
|
|
|
181
|
-
const simulator = new WASMSimulator();
|
|
182
|
-
const recorder = process.env.CIRCUIT_RECORD_DIR
|
|
183
|
-
? new FileCircuitRecorder(process.env.CIRCUIT_RECORD_DIR)
|
|
184
|
-
: new MemoryCircuitRecorder();
|
|
185
|
-
const simulatorWithRecorder = new SimulatorRecorderWrapper(simulator, recorder);
|
|
186
|
-
const pxe = await createPXEServiceWithSimulator(aztecNode, simulatorWithRecorder, pxeServiceConfig, {
|
|
187
|
-
useLogSuffix,
|
|
188
|
-
});
|
|
189
|
-
|
|
190
177
|
const teardown = configuredDataDirectory ? () => Promise.resolve() : () => tryRmDir(pxeServiceConfig.dataDirectory!);
|
|
191
178
|
|
|
192
|
-
const wallet =
|
|
179
|
+
const wallet = await TestWallet.create(aztecNode, pxeServiceConfig, {
|
|
180
|
+
useLogSuffix,
|
|
181
|
+
});
|
|
193
182
|
|
|
194
183
|
return {
|
|
195
184
|
wallet,
|
|
@@ -217,11 +206,9 @@ async function setupWithRemoteEnvironment(
|
|
|
217
206
|
const aztecNodeUrl = getAztecUrl();
|
|
218
207
|
logger.verbose(`Creating Aztec Node client to remote host ${aztecNodeUrl}`);
|
|
219
208
|
const aztecNode = createAztecNodeClient(aztecNodeUrl);
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
logger.verbose('JSON RPC client connected to PXE');
|
|
224
|
-
logger.verbose(`Retrieving contract addresses from ${PXE_URL}`);
|
|
209
|
+
await waitForNode(aztecNode, logger);
|
|
210
|
+
logger.verbose('JSON RPC client connected to Aztec Node');
|
|
211
|
+
logger.verbose(`Retrieving contract addresses from ${aztecNodeUrl}`);
|
|
225
212
|
const { l1ContractAddresses, rollupVersion } = await aztecNode.getNodeInfo();
|
|
226
213
|
|
|
227
214
|
const l1Client = createExtendedL1Client(config.l1RpcUrls, account, foundry);
|
|
@@ -232,12 +219,12 @@ async function setupWithRemoteEnvironment(
|
|
|
232
219
|
rollupVersion,
|
|
233
220
|
};
|
|
234
221
|
const ethCheatCodes = new EthCheatCodes(config.l1RpcUrls, new DateProvider());
|
|
235
|
-
const wallet =
|
|
222
|
+
const wallet = await TestWallet.create(aztecNode);
|
|
236
223
|
const cheatCodes = await CheatCodes.create(config.l1RpcUrls, wallet, aztecNode, new DateProvider());
|
|
237
224
|
const teardown = () => Promise.resolve();
|
|
238
225
|
|
|
239
226
|
logger.verbose('Populating wallet from already registered accounts...');
|
|
240
|
-
const initialFundedAccounts = await
|
|
227
|
+
const initialFundedAccounts = await getInitialTestAccountsData();
|
|
241
228
|
|
|
242
229
|
if (initialFundedAccounts.length < numberOfAccounts) {
|
|
243
230
|
throw new Error(`Required ${numberOfAccounts} accounts. Found ${initialFundedAccounts.length}.`);
|
|
@@ -404,9 +391,9 @@ export async function setup(
|
|
|
404
391
|
if (!isAnvilTestChain(chain.id)) {
|
|
405
392
|
throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
|
|
406
393
|
}
|
|
407
|
-
if (
|
|
394
|
+
if (AZTEC_NODE_URL) {
|
|
408
395
|
throw new Error(
|
|
409
|
-
`
|
|
396
|
+
`AZTEC_NODE_URL provided but no ETHEREUM_HOSTS set. Refusing to run, please set both variables so tests can deploy L1 contracts to the same Anvil instance`,
|
|
410
397
|
);
|
|
411
398
|
}
|
|
412
399
|
|
|
@@ -459,7 +446,7 @@ export async function setup(
|
|
|
459
446
|
|
|
460
447
|
config.coinbase = EthAddress.fromString(publisherHdAccount.address);
|
|
461
448
|
|
|
462
|
-
if (
|
|
449
|
+
if (AZTEC_NODE_URL) {
|
|
463
450
|
// we are setting up against a remote environment, l1 contracts are assumed to already be deployed
|
|
464
451
|
return await setupWithRemoteEnvironment(publisherHdAccount!, config, logger, numberOfAccounts);
|
|
465
452
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { sleep } from '@aztec/aztec.js';
|
|
2
|
+
import { randomBytes } from '@aztec/foundation/crypto';
|
|
3
|
+
|
|
4
|
+
import { mkdirSync } from 'node:fs';
|
|
5
|
+
import { writeFile } from 'node:fs/promises';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
|
|
8
|
+
export async function createWeb3SignerKeystore(dir: string, ...privateKeys: string[]) {
|
|
9
|
+
const yaml = privateKeys
|
|
10
|
+
.map(
|
|
11
|
+
pk => `\
|
|
12
|
+
type: file-raw
|
|
13
|
+
keyType: SECP256K1
|
|
14
|
+
privateKey: ${pk}`,
|
|
15
|
+
)
|
|
16
|
+
.join('\n---\n');
|
|
17
|
+
|
|
18
|
+
// NOTE: nodejs stdlib can only create temp directories, not temp files!
|
|
19
|
+
// this write uses wx (write-exclusive) so it'll throw if the file already exists
|
|
20
|
+
const path = join(dir, `keystore-${randomBytes(4).toString('hex')}.yaml`);
|
|
21
|
+
await writeFile(path, yaml, { flag: 'wx' });
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function refreshWeb3Signer(url: string) {
|
|
25
|
+
await fetch(new URL('reload', url), { method: 'POST' });
|
|
26
|
+
// give the service a chance to load up the new files
|
|
27
|
+
// 1s might not be enough if there are a lot of files to scan
|
|
28
|
+
await sleep(1000);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function getWeb3SignerTestKeystoreDir(): string {
|
|
32
|
+
if (process.env.WEB3_SIGNER_TEST_KEYSTORE_DIR) {
|
|
33
|
+
mkdirSync(process.env.WEB3_SIGNER_TEST_KEYSTORE_DIR, { recursive: true });
|
|
34
|
+
return process.env.WEB3_SIGNER_TEST_KEYSTORE_DIR;
|
|
35
|
+
} else {
|
|
36
|
+
throw new Error('Web3signer not running');
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function getWeb3SignerUrl(): string {
|
|
41
|
+
if (process.env.WEB3_SIGNER_URL) {
|
|
42
|
+
return process.env.WEB3_SIGNER_URL;
|
|
43
|
+
} else {
|
|
44
|
+
throw new Error('Web3signer not running');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AztecAddress, Fr, GrumpkinScalar, type Logger, type SentTx, TxStatus } from '@aztec/aztec.js';
|
|
2
2
|
import { times } from '@aztec/foundation/collection';
|
|
3
|
-
import type { TestWallet } from '@aztec/test-wallet';
|
|
3
|
+
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
4
4
|
|
|
5
5
|
// submits a set of transactions to the provided Wallet
|
|
6
6
|
export const submitTxsTo = async (
|
|
@@ -20,7 +20,7 @@ import { InboxAbi, UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-art
|
|
|
20
20
|
import { UniswapContract } from '@aztec/noir-contracts.js/Uniswap';
|
|
21
21
|
import { computeL2ToL1MessageHash } from '@aztec/stdlib/hash';
|
|
22
22
|
import { computeL2ToL1MembershipWitness } from '@aztec/stdlib/messaging';
|
|
23
|
-
import type { TestWallet } from '@aztec/test-wallet';
|
|
23
|
+
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
24
24
|
|
|
25
25
|
import { jest } from '@jest/globals';
|
|
26
26
|
import { type GetContractReturnType, getContract, parseEther, toFunctionSelector } from 'viem';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { generateSchnorrAccounts
|
|
1
|
+
import { generateSchnorrAccounts } from '@aztec/accounts/testing';
|
|
2
2
|
import {
|
|
3
3
|
type AztecAddress,
|
|
4
4
|
type AztecNode,
|
|
@@ -9,15 +9,14 @@ import {
|
|
|
9
9
|
SponsoredFeePaymentMethod,
|
|
10
10
|
type Wallet,
|
|
11
11
|
createAztecNodeClient,
|
|
12
|
-
createCompatibleClient,
|
|
13
12
|
retryUntil,
|
|
14
13
|
} from '@aztec/aztec.js';
|
|
15
14
|
import { createEthereumChain, createExtendedL1Client } from '@aztec/ethereum';
|
|
16
15
|
import type { Logger } from '@aztec/foundation/log';
|
|
17
16
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
18
|
-
import { createPXEService } from '@aztec/pxe/server';
|
|
19
17
|
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
20
|
-
import {
|
|
18
|
+
import { registerInitialSandboxAccountsInWallet } from '@aztec/test-wallet';
|
|
19
|
+
import { TestWallet } from '@aztec/test-wallet/server';
|
|
21
20
|
|
|
22
21
|
import { getACVMConfig } from '../fixtures/get_acvm_config.js';
|
|
23
22
|
import { getBBConfig } from '../fixtures/get_bb_config.js';
|
|
@@ -39,39 +38,33 @@ const TOKEN_SYMBOL = 'USD';
|
|
|
39
38
|
const TOKEN_DECIMALS = 18n;
|
|
40
39
|
|
|
41
40
|
export async function setupTestAccountsWithTokens(
|
|
42
|
-
pxeUrl: string,
|
|
43
41
|
nodeUrl: string,
|
|
44
42
|
mintAmount: bigint,
|
|
45
43
|
logger: Logger,
|
|
46
44
|
): Promise<TestAccounts> {
|
|
47
45
|
const ACCOUNT_COUNT = 1; // TODO fix this to allow for 16 wallets again
|
|
48
46
|
|
|
49
|
-
const pxe = await createCompatibleClient(pxeUrl, logger);
|
|
50
47
|
const aztecNode = createAztecNodeClient(nodeUrl);
|
|
51
|
-
const wallet =
|
|
48
|
+
const wallet = await TestWallet.create(aztecNode);
|
|
52
49
|
|
|
53
|
-
const [recipientAccount, ...accounts] = (await
|
|
50
|
+
const [recipientAccount, ...accounts] = (await registerInitialSandboxAccountsInWallet(wallet)).slice(
|
|
51
|
+
0,
|
|
52
|
+
ACCOUNT_COUNT + 1,
|
|
53
|
+
);
|
|
54
54
|
|
|
55
55
|
const tokenAdmin = accounts[0];
|
|
56
|
-
const tokenAddress = await deployTokenAndMint(
|
|
57
|
-
wallet,
|
|
58
|
-
accounts.map(acc => acc.address),
|
|
59
|
-
tokenAdmin.address,
|
|
60
|
-
mintAmount,
|
|
61
|
-
undefined,
|
|
62
|
-
logger,
|
|
63
|
-
);
|
|
56
|
+
const tokenAddress = await deployTokenAndMint(wallet, accounts, tokenAdmin, mintAmount, undefined, logger);
|
|
64
57
|
const tokenContract = await TokenContract.at(tokenAddress, wallet);
|
|
65
58
|
|
|
66
59
|
return {
|
|
67
60
|
aztecNode,
|
|
68
|
-
accounts
|
|
61
|
+
accounts,
|
|
69
62
|
wallet,
|
|
70
|
-
tokenAdminAddress: tokenAdmin
|
|
63
|
+
tokenAdminAddress: tokenAdmin,
|
|
71
64
|
tokenName: TOKEN_NAME,
|
|
72
65
|
tokenAddress,
|
|
73
66
|
tokenContract,
|
|
74
|
-
recipientAddress: recipientAccount
|
|
67
|
+
recipientAddress: recipientAccount,
|
|
75
68
|
};
|
|
76
69
|
}
|
|
77
70
|
|
|
@@ -121,7 +114,6 @@ export async function deploySponsoredTestAccounts(
|
|
|
121
114
|
}
|
|
122
115
|
|
|
123
116
|
export async function deployTestAccountsWithTokens(
|
|
124
|
-
pxeUrl: string,
|
|
125
117
|
nodeUrl: string,
|
|
126
118
|
l1RpcUrls: string[],
|
|
127
119
|
mnemonicOrPrivateKey: string,
|
|
@@ -129,9 +121,8 @@ export async function deployTestAccountsWithTokens(
|
|
|
129
121
|
logger: Logger,
|
|
130
122
|
numberOfFundedWallets = 1,
|
|
131
123
|
): Promise<TestAccounts> {
|
|
132
|
-
const pxe = await createCompatibleClient(pxeUrl, logger);
|
|
133
124
|
const aztecNode = createAztecNodeClient(nodeUrl);
|
|
134
|
-
const wallet =
|
|
125
|
+
const wallet = await TestWallet.create(aztecNode);
|
|
135
126
|
|
|
136
127
|
const [recipient, ...funded] = await generateSchnorrAccounts(numberOfFundedWallets + 1);
|
|
137
128
|
const recipientAccount = await wallet.createSchnorrAccount(recipient.secret, recipient.salt);
|
|
@@ -294,20 +285,20 @@ export async function createWalletAndAztecNodeClient(
|
|
|
294
285
|
): Promise<{ wallet: TestWallet; aztecNode: AztecNode; cleanup: () => Promise<void> }> {
|
|
295
286
|
const aztecNode = createAztecNodeClient(nodeUrl);
|
|
296
287
|
const [bbConfig, acvmConfig] = await Promise.all([getBBConfig(logger), getACVMConfig(logger)]);
|
|
297
|
-
const
|
|
288
|
+
const pxeConfig = {
|
|
298
289
|
dataDirectory: undefined,
|
|
299
290
|
dataStoreMapSizeKB: 1024 * 1024,
|
|
300
291
|
...bbConfig,
|
|
301
292
|
...acvmConfig,
|
|
302
293
|
proverEnabled,
|
|
303
|
-
}
|
|
304
|
-
const wallet =
|
|
294
|
+
};
|
|
295
|
+
const wallet = await TestWallet.create(aztecNode, pxeConfig);
|
|
305
296
|
|
|
306
297
|
return {
|
|
307
298
|
wallet,
|
|
308
299
|
aztecNode,
|
|
309
300
|
async cleanup() {
|
|
310
|
-
await
|
|
301
|
+
await wallet.stop();
|
|
311
302
|
await bbConfig?.cleanup();
|
|
312
303
|
await acvmConfig?.cleanup();
|
|
313
304
|
},
|