@aztec/end-to-end 3.0.0-canary.a9708bd → 3.0.0-manual.20251030
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/benchmark.d.ts +3 -2
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/benchmark.js +2 -2
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +16 -12
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +54 -58
- package/dest/bench/client_flows/data_extractor.js +3 -3
- package/dest/bench/utils.d.ts +2 -11
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +10 -34
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +7 -7
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +42 -42
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +10 -8
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +31 -33
- package/dest/e2e_deploy_contract/deploy_test.d.ts +10 -4
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +9 -18
- package/dest/e2e_epochs/epochs_test.d.ts +9 -3
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +19 -13
- package/dest/e2e_fees/bridging_race.notest.js +12 -9
- package/dest/e2e_fees/fees_test.d.ts +5 -5
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +26 -33
- package/dest/e2e_l1_publisher/write_json.d.ts +3 -1
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
- package/dest/e2e_l1_publisher/write_json.js +5 -5
- package/dest/e2e_multi_validator/utils.d.ts +1 -1
- package/dest/e2e_multi_validator/utils.d.ts.map +1 -1
- package/dest/e2e_multi_validator/utils.js +3 -9
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +6 -3
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +7 -9
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
- package/dest/e2e_p2p/inactivity_slash_test.js +135 -0
- package/dest/e2e_p2p/p2p_network.d.ts +22 -8
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +36 -15
- package/dest/e2e_p2p/shared.d.ts +12 -13
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +54 -54
- package/dest/e2e_token_contract/token_contract_test.d.ts +5 -4
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +14 -17
- package/dest/fixtures/e2e_prover_test.d.ts +8 -6
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +42 -51
- package/dest/fixtures/get_acvm_config.d.ts +1 -1
- package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.d.ts +1 -1
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +2 -2
- package/dest/fixtures/setup_l1_contracts.d.ts +1 -1
- package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
- package/dest/fixtures/setup_l1_contracts.js +2 -2
- package/dest/fixtures/setup_p2p_test.d.ts +10 -9
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +38 -20
- package/dest/fixtures/snapshot_manager.d.ts +10 -7
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +60 -47
- package/dest/fixtures/token_utils.d.ts +6 -4
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +11 -15
- package/dest/fixtures/utils.d.ts +26 -28
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +83 -109
- package/dest/fixtures/web3signer.d.ts +5 -0
- package/dest/fixtures/web3signer.d.ts.map +1 -0
- package/dest/fixtures/web3signer.js +53 -0
- package/dest/quality_of_service/alert_checker.d.ts +1 -1
- package/dest/quality_of_service/alert_checker.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts +16 -10
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +13 -15
- package/dest/shared/gas_portal_test_harness.d.ts +9 -6
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +10 -7
- package/dest/shared/jest_setup.js +1 -1
- package/dest/shared/submit-transactions.d.ts +5 -3
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +8 -7
- package/dest/shared/uniswap_l1_l2.d.ts +9 -6
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +29 -45
- package/dest/simulators/lending_simulator.d.ts +2 -1
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +3 -2
- package/dest/simulators/token_simulator.d.ts +3 -1
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +2 -2
- package/dest/spartan/setup_test_wallets.d.ts +19 -13
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +108 -85
- package/dest/spartan/utils.d.ts +68 -3
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +312 -49
- package/package.json +39 -38
- package/src/bench/client_flows/benchmark.ts +8 -8
- package/src/bench/client_flows/client_flows_benchmark.ts +62 -82
- package/src/bench/client_flows/data_extractor.ts +4 -4
- package/src/bench/utils.ts +9 -37
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +46 -63
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +33 -47
- package/src/e2e_deploy_contract/deploy_test.ts +17 -35
- package/src/e2e_epochs/epochs_test.ts +22 -19
- package/src/e2e_fees/bridging_race.notest.ts +14 -9
- package/src/e2e_fees/fees_test.ts +29 -40
- package/src/e2e_l1_publisher/write_json.ts +8 -6
- package/src/e2e_multi_validator/utils.ts +4 -10
- package/src/e2e_nested_contract/nested_contract_test.ts +11 -10
- package/src/e2e_p2p/inactivity_slash_test.ts +178 -0
- package/src/e2e_p2p/p2p_network.ts +110 -71
- package/src/e2e_p2p/shared.ts +57 -56
- package/src/e2e_token_contract/token_contract_test.ts +17 -17
- package/src/fixtures/e2e_prover_test.ts +52 -88
- package/src/fixtures/get_acvm_config.ts +1 -1
- package/src/fixtures/get_bb_config.ts +3 -2
- package/src/fixtures/setup_l1_contracts.ts +3 -3
- package/src/fixtures/setup_p2p_test.ts +60 -27
- package/src/fixtures/snapshot_manager.ts +80 -72
- package/src/fixtures/token_utils.ts +13 -21
- package/src/fixtures/utils.ts +95 -145
- package/src/fixtures/web3signer.ts +63 -0
- package/src/guides/up_quick_start.sh +2 -10
- package/src/quality_of_service/alert_checker.ts +1 -1
- package/src/shared/cross_chain_test_harness.ts +18 -29
- package/src/shared/gas_portal_test_harness.ts +12 -19
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +12 -8
- package/src/shared/uniswap_l1_l2.ts +61 -67
- package/src/simulators/lending_simulator.ts +3 -2
- package/src/simulators/token_simulator.ts +5 -2
- package/src/spartan/DEVELOP.md +8 -3
- package/src/spartan/setup_test_wallets.ts +133 -126
- package/src/spartan/utils.ts +373 -48
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { InitialAccountData } from '@aztec/accounts/testing';
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
2
|
+
import type { AztecNodeService } from '@aztec/aztec-node';
|
|
3
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
4
4
|
import { type EmpireSlashingProposerContract, type Operator, RollupContract, type TallySlashingProposerContract, type ViemClient } from '@aztec/ethereum';
|
|
5
5
|
import { ChainMonitor } from '@aztec/ethereum/test';
|
|
6
6
|
import { type Logger } from '@aztec/foundation/log';
|
|
@@ -9,8 +9,10 @@ import { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
|
|
|
9
9
|
import type { BootstrapNode } from '@aztec/p2p/bootstrap';
|
|
10
10
|
import { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
|
|
11
11
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
12
|
+
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
12
13
|
import { type GetContractReturnType } from 'viem';
|
|
13
14
|
import { type SubsystemsContext } from '../fixtures/snapshot_manager.js';
|
|
15
|
+
import { type SetupOptions } from '../fixtures/utils.js';
|
|
14
16
|
export declare const WAIT_FOR_TX_TIMEOUT: number;
|
|
15
17
|
export declare const SHORTENED_BLOCK_TIME_CONFIG_NO_PRUNES: {
|
|
16
18
|
aztecSlotDuration: number;
|
|
@@ -18,6 +20,7 @@ export declare const SHORTENED_BLOCK_TIME_CONFIG_NO_PRUNES: {
|
|
|
18
20
|
aztecProofSubmissionWindow: number;
|
|
19
21
|
};
|
|
20
22
|
export declare class P2PNetworkTest {
|
|
23
|
+
readonly testName: string;
|
|
21
24
|
bootstrapNodeEnr: string;
|
|
22
25
|
bootNodePort: number;
|
|
23
26
|
numberOfValidators: number;
|
|
@@ -31,13 +34,13 @@ export declare class P2PNetworkTest {
|
|
|
31
34
|
sign: (parameters: {
|
|
32
35
|
hash: import("viem").Hash;
|
|
33
36
|
}) => Promise<import("viem").Hex>;
|
|
34
|
-
|
|
37
|
+
signAuthorization: (parameters: import("viem").AuthorizationRequest) => Promise<import("viem/accounts").SignAuthorizationReturnType>;
|
|
35
38
|
signMessage: ({ message }: {
|
|
36
39
|
message: import("viem").SignableMessage;
|
|
37
40
|
}) => Promise<import("viem").Hex>;
|
|
38
41
|
signTransaction: <serializer extends import("viem").SerializeTransactionFn<import("viem").TransactionSerializable> = import("viem").SerializeTransactionFn<import("viem").TransactionSerializable>, transaction extends Parameters<serializer>[0] = Parameters<serializer>[0]>(transaction: transaction, options?: {
|
|
39
42
|
serializer?: serializer | undefined;
|
|
40
|
-
} | undefined) => Promise<import("viem").
|
|
43
|
+
} | undefined) => Promise<import("viem").Hex>;
|
|
41
44
|
signTypedData: <const typedData extends import("viem").TypedData | Record<string, unknown>, primaryType extends keyof typedData | "EIP712Domain" = keyof typedData>(parameters: import("viem").TypedDataDefinition<typedData, primaryType>) => Promise<import("viem").Hex>;
|
|
42
45
|
publicKey: import("viem").Hex;
|
|
43
46
|
source: "privateKey";
|
|
@@ -52,18 +55,18 @@ export declare class P2PNetworkTest {
|
|
|
52
55
|
validators: Operator[];
|
|
53
56
|
deployedAccounts: InitialAccountData[];
|
|
54
57
|
prefilledPublicData: PublicDataTreeLeaf[];
|
|
55
|
-
wallet?:
|
|
58
|
+
wallet?: TestWallet;
|
|
56
59
|
defaultAccountAddress?: AztecAddress;
|
|
57
60
|
spamContract?: SpamContract;
|
|
58
61
|
bootstrapNode?: BootstrapNode;
|
|
59
|
-
constructor(testName: string, bootstrapNodeEnr: string, bootNodePort: number, numberOfValidators: number, initialValidatorConfig:
|
|
62
|
+
constructor(testName: string, bootstrapNodeEnr: string, bootNodePort: number, numberOfValidators: number, initialValidatorConfig: SetupOptions, numberOfNodes?: number, metricsPort?: number | undefined, startProverNode?: boolean, mockZkPassportVerifier?: boolean);
|
|
60
63
|
static create({ testName, numberOfNodes, numberOfValidators, basePort, metricsPort, initialConfig, startProverNode, mockZkPassportVerifier, }: {
|
|
61
64
|
testName: string;
|
|
62
65
|
numberOfNodes: number;
|
|
63
66
|
numberOfValidators: number;
|
|
64
67
|
basePort?: number;
|
|
65
68
|
metricsPort?: number;
|
|
66
|
-
initialConfig?:
|
|
69
|
+
initialConfig?: SetupOptions;
|
|
67
70
|
startProverNode?: boolean;
|
|
68
71
|
mockZkPassportVerifier?: boolean;
|
|
69
72
|
}): Promise<P2PNetworkTest>;
|
|
@@ -78,11 +81,22 @@ export declare class P2PNetworkTest {
|
|
|
78
81
|
removeInitialNode(): Promise<void>;
|
|
79
82
|
sendDummyTx(): Promise<{
|
|
80
83
|
receipt: import("viem").TransactionReceipt;
|
|
81
|
-
|
|
84
|
+
state: import("@aztec/ethereum").L1TxState;
|
|
82
85
|
}>;
|
|
83
86
|
private _sendDummyTx;
|
|
84
87
|
setup(): Promise<void>;
|
|
85
88
|
stopNodes(nodes: AztecNodeService[]): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Wait for P2P mesh to be fully formed across all nodes.
|
|
91
|
+
* This ensures that all nodes are connected to each other before proceeding,
|
|
92
|
+
* preventing race conditions where validators propose blocks before the network is ready.
|
|
93
|
+
*
|
|
94
|
+
* @param nodes - Array of nodes to check for P2P connectivity
|
|
95
|
+
* @param expectedNodeCount - Expected number of nodes in the network (defaults to nodes.length)
|
|
96
|
+
* @param timeoutSeconds - Maximum time to wait for connections (default: 30 seconds)
|
|
97
|
+
* @param checkIntervalSeconds - How often to check connectivity (default: 0.1 seconds)
|
|
98
|
+
*/
|
|
99
|
+
waitForP2PMeshConnectivity(nodes: AztecNodeService[], expectedNodeCount?: number, timeoutSeconds?: number, checkIntervalSeconds?: number): Promise<void>;
|
|
86
100
|
teardown(): Promise<void>;
|
|
87
101
|
getContracts(): Promise<{
|
|
88
102
|
rollup: RollupContract;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"p2p_network.d.ts","sourceRoot":"","sources":["../../src/e2e_p2p/p2p_network.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"p2p_network.d.ts","source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AAE,OAAO,CAAC;QAC1B,sBAAsB,CAAC,EAAE,OAAO,CAAC;KAClC;IAwBD,IAAI,aAAa,uBAKhB;IAEK,gBAAgB;IActB,aAAa;;;IAkBP,kBAAkB;IAsElB,YAAY;IAaZ,kBAAkB;IAsBlB,iBAAiB;IAgBjB,WAAW;;;;YAIH,YAAY;IAQpB,KAAK;IAcL,SAAS,CAAC,KAAK,EAAE,gBAAgB,EAAE;IAazC;;;;;;;;;OASG;IACG,0BAA0B,CAC9B,KAAK,EAAE,gBAAgB,EAAE,EACzB,iBAAiB,CAAC,EAAE,MAAM,EAC1B,cAAc,SAAK,EACnB,oBAAoB,SAAM;IA4BtB,QAAQ;IAMR,YAAY,IAAI,OAAO,CAAC;QAC5B,MAAM,EAAE,cAAc,CAAC;QACvB,eAAe,EAAE,qBAAqB,CAAC,OAAO,UAAU,EAAE,UAAU,CAAC,CAAC;QACtE,gBAAgB,EAAE,8BAA8B,GAAG,6BAA6B,GAAG,SAAS,CAAC;QAC7F,YAAY,EAAE,oBAAoB,CAAC;KACpC,CAAC;CA0BH"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
3
|
import { GSEContract, MultiAdderArtifact, RollupContract, createL1TxUtilsFromViemWallet, deployL1Contract, getL1ContractsConfigEnvVars } from '@aztec/ethereum';
|
|
4
4
|
import { ChainMonitor } from '@aztec/ethereum/test';
|
|
5
5
|
import { SecretValue } from '@aztec/foundation/config';
|
|
6
6
|
import { createLogger } from '@aztec/foundation/log';
|
|
7
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
7
8
|
import { RollupAbi, SlasherAbi, TestERC20Abi } from '@aztec/l1-artifacts';
|
|
8
9
|
import { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
|
|
9
10
|
import { createBootstrapNodeFromPrivateKey, getBootstrapNodeEnr } from '@aztec/p2p/test-helpers';
|
|
@@ -28,6 +29,7 @@ export const SHORTENED_BLOCK_TIME_CONFIG_NO_PRUNES = {
|
|
|
28
29
|
aztecProofSubmissionWindow: 640
|
|
29
30
|
};
|
|
30
31
|
export class P2PNetworkTest {
|
|
32
|
+
testName;
|
|
31
33
|
bootstrapNodeEnr;
|
|
32
34
|
bootNodePort;
|
|
33
35
|
numberOfValidators;
|
|
@@ -52,6 +54,7 @@ export class P2PNetworkTest {
|
|
|
52
54
|
bootstrapNode;
|
|
53
55
|
constructor(testName, bootstrapNodeEnr, bootNodePort, numberOfValidators, initialValidatorConfig, numberOfNodes = 0, // If set enable metrics collection
|
|
54
56
|
metricsPort, startProverNode, mockZkPassportVerifier){
|
|
57
|
+
this.testName = testName;
|
|
55
58
|
this.bootstrapNodeEnr = bootstrapNodeEnr;
|
|
56
59
|
this.bootNodePort = bootNodePort;
|
|
57
60
|
this.numberOfValidators = numberOfValidators;
|
|
@@ -139,7 +142,7 @@ export class P2PNetworkTest {
|
|
|
139
142
|
}
|
|
140
143
|
async applyBaseSnapshots() {
|
|
141
144
|
await this.addBootstrapNode();
|
|
142
|
-
await this.snapshotManager.snapshot('add-validators', async ({ deployL1ContractsValues,
|
|
145
|
+
await this.snapshotManager.snapshot('add-validators', async ({ deployL1ContractsValues, cheatCodes })=>{
|
|
143
146
|
const rollup = getContract({
|
|
144
147
|
address: deployL1ContractsValues.l1ContractAddresses.rollupAddress.toString(),
|
|
145
148
|
abi: RollupAbi,
|
|
@@ -160,7 +163,7 @@ export class P2PNetworkTest {
|
|
|
160
163
|
abi: MultiAdderArtifact.contractAbi,
|
|
161
164
|
client: deployL1ContractsValues.l1Client
|
|
162
165
|
});
|
|
163
|
-
const stakeNeeded =
|
|
166
|
+
const stakeNeeded = await rollup.read.getActivationThreshold() * BigInt(this.numberOfValidators);
|
|
164
167
|
await Promise.all([
|
|
165
168
|
await stakingAsset.write.mint([
|
|
166
169
|
multiAdder.address,
|
|
@@ -190,22 +193,17 @@ export class P2PNetworkTest {
|
|
|
190
193
|
validatorTuples
|
|
191
194
|
])
|
|
192
195
|
});
|
|
193
|
-
|
|
194
|
-
updateDateProvider: dateProvider
|
|
195
|
-
});
|
|
196
|
+
await cheatCodes.rollup.advanceToEpoch(await cheatCodes.rollup.getEpoch() + await rollup.read.getLagInEpochs() + 1n);
|
|
196
197
|
// Send and await a tx to make sure we mine a block for the warp to correctly progress.
|
|
197
198
|
await this._sendDummyTx(deployL1ContractsValues.l1Client);
|
|
198
|
-
// Set the system time in the node, only after we have warped the time and waited for a block
|
|
199
|
-
// Time is only set in the NEXT block
|
|
200
|
-
dateProvider.setTime(Number(timestamp) * 1000);
|
|
201
199
|
});
|
|
202
200
|
}
|
|
203
201
|
async setupAccount() {
|
|
204
|
-
await this.snapshotManager.snapshot('setup-account', deployAccounts(1, this.logger
|
|
202
|
+
await this.snapshotManager.snapshot('setup-account', deployAccounts(1, this.logger), ({ deployedAccounts }, { wallet })=>{
|
|
205
203
|
this.deployedAccounts = deployedAccounts;
|
|
206
|
-
|
|
207
|
-
this.wallet =
|
|
208
|
-
|
|
204
|
+
[{ address: this.defaultAccountAddress }] = deployedAccounts;
|
|
205
|
+
this.wallet = wallet;
|
|
206
|
+
return Promise.resolve();
|
|
209
207
|
});
|
|
210
208
|
}
|
|
211
209
|
async deploySpamContract() {
|
|
@@ -269,6 +267,29 @@ export class P2PNetworkTest {
|
|
|
269
267
|
await Promise.all(nodes.map((node)=>node.stop()));
|
|
270
268
|
this.logger.info('Nodes stopped');
|
|
271
269
|
}
|
|
270
|
+
/**
|
|
271
|
+
* Wait for P2P mesh to be fully formed across all nodes.
|
|
272
|
+
* This ensures that all nodes are connected to each other before proceeding,
|
|
273
|
+
* preventing race conditions where validators propose blocks before the network is ready.
|
|
274
|
+
*
|
|
275
|
+
* @param nodes - Array of nodes to check for P2P connectivity
|
|
276
|
+
* @param expectedNodeCount - Expected number of nodes in the network (defaults to nodes.length)
|
|
277
|
+
* @param timeoutSeconds - Maximum time to wait for connections (default: 30 seconds)
|
|
278
|
+
* @param checkIntervalSeconds - How often to check connectivity (default: 0.1 seconds)
|
|
279
|
+
*/ async waitForP2PMeshConnectivity(nodes, expectedNodeCount, timeoutSeconds = 30, checkIntervalSeconds = 0.1) {
|
|
280
|
+
const nodeCount = expectedNodeCount ?? nodes.length;
|
|
281
|
+
const minPeerCount = nodeCount - 1;
|
|
282
|
+
this.logger.warn(`Waiting for all ${nodeCount} nodes to connect to P2P mesh (at least ${minPeerCount} peers each)...`);
|
|
283
|
+
await Promise.all(nodes.map(async (node, index)=>{
|
|
284
|
+
const p2p = node.getP2P();
|
|
285
|
+
await retryUntil(async ()=>{
|
|
286
|
+
const peers = await p2p.getPeers();
|
|
287
|
+
// Each node should be connected to at least N-1 other nodes
|
|
288
|
+
return peers.length >= minPeerCount ? true : undefined;
|
|
289
|
+
}, `Node ${index} to connect to at least ${minPeerCount} peers`, timeoutSeconds, checkIntervalSeconds);
|
|
290
|
+
}));
|
|
291
|
+
this.logger.warn('All nodes connected to P2P mesh');
|
|
292
|
+
}
|
|
272
293
|
async teardown() {
|
|
273
294
|
await this.monitor.stop();
|
|
274
295
|
await tryStop(this.bootstrapNode, this.logger);
|
|
@@ -280,7 +301,7 @@ export class P2PNetworkTest {
|
|
|
280
301
|
}
|
|
281
302
|
const rollup = new RollupContract(this.ctx.deployL1ContractsValues.l1Client, this.ctx.deployL1ContractsValues.l1ContractAddresses.rollupAddress);
|
|
282
303
|
const slasherContract = getContract({
|
|
283
|
-
address: getAddress(await rollup.
|
|
304
|
+
address: getAddress(await rollup.getSlasherAddress()),
|
|
284
305
|
abi: SlasherAbi,
|
|
285
306
|
client: this.ctx.deployL1ContractsValues.l1Client
|
|
286
307
|
});
|
package/dest/e2e_p2p/shared.d.ts
CHANGED
|
@@ -1,39 +1,37 @@
|
|
|
1
1
|
import type { InitialAccountData } from '@aztec/accounts/testing';
|
|
2
2
|
import type { AztecNodeService } from '@aztec/aztec-node';
|
|
3
|
-
import { AztecAddress
|
|
3
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
4
|
+
import { type SentTx } from '@aztec/aztec.js/contracts';
|
|
5
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
6
|
+
import { Tx } from '@aztec/aztec.js/tx';
|
|
4
7
|
import type { RollupCheatCodes } from '@aztec/aztec/testing';
|
|
5
8
|
import type { EmpireSlashingProposerContract, RollupContract, TallySlashingProposerContract } from '@aztec/ethereum';
|
|
6
|
-
import type { TestDateProvider } from '@aztec/foundation/timer';
|
|
7
9
|
import type { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
|
|
8
|
-
import { PXEService } from '@aztec/pxe/server';
|
|
9
10
|
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
10
11
|
import type { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
|
|
11
|
-
import type { NodeContext } from '../fixtures/setup_p2p_test.js';
|
|
12
12
|
export declare const submitComplexTxsTo: (logger: Logger, from: AztecAddress, spamContract: SpamContract, numTxs: number, opts?: {
|
|
13
13
|
callPublic?: boolean;
|
|
14
14
|
}) => Promise<SentTx[]>;
|
|
15
|
-
export declare const
|
|
16
|
-
export declare function
|
|
17
|
-
pxeService: PXEService;
|
|
18
|
-
txs: ProvenTx[];
|
|
19
|
-
node: AztecNodeService;
|
|
20
|
-
}>;
|
|
15
|
+
export declare const submitTransactions: (logger: Logger, node: AztecNodeService, numTxs: number, fundedAccount: InitialAccountData) => Promise<SentTx[]>;
|
|
16
|
+
export declare function prepareTransactions(logger: Logger, node: AztecNodeService, numTxs: number, fundedAccount: InitialAccountData): Promise<Tx[]>;
|
|
21
17
|
export declare function awaitProposalExecution(slashingProposer: EmpireSlashingProposerContract | TallySlashingProposerContract, timeoutSeconds: number, logger: Logger): Promise<bigint>;
|
|
22
18
|
export declare function awaitCommitteeExists({ rollup, logger, }: {
|
|
23
19
|
rollup: RollupContract;
|
|
24
20
|
logger: Logger;
|
|
25
21
|
}): Promise<readonly `0x${string}`[]>;
|
|
26
|
-
export declare function awaitOffenseDetected({ logger, nodeAdmin, slashingRoundSize, epochDuration, }: {
|
|
22
|
+
export declare function awaitOffenseDetected({ logger, nodeAdmin, slashingRoundSize, epochDuration, waitUntilOffenseCount, timeoutSeconds, }: {
|
|
27
23
|
nodeAdmin: AztecNodeAdmin;
|
|
28
24
|
logger: Logger;
|
|
29
25
|
slashingRoundSize: number;
|
|
30
26
|
epochDuration: number;
|
|
27
|
+
waitUntilOffenseCount?: number;
|
|
28
|
+
timeoutSeconds?: number;
|
|
31
29
|
}): Promise<import("@aztec/slasher").Offense[]>;
|
|
32
30
|
/**
|
|
33
31
|
* Await the committee to be slashed out of the validator set.
|
|
34
32
|
* Currently assumes that the committee is the same size as the validator set.
|
|
35
33
|
*/
|
|
36
|
-
export declare function awaitCommitteeKicked({ rollup, cheatCodes, committee, slashFactory, slashingProposer, slashingRoundSize, aztecSlotDuration, logger,
|
|
34
|
+
export declare function awaitCommitteeKicked({ rollup, cheatCodes, committee, slashFactory, slashingProposer, slashingRoundSize, aztecSlotDuration, aztecEpochDuration, logger, offenseEpoch, }: {
|
|
37
35
|
rollup: RollupContract;
|
|
38
36
|
cheatCodes: RollupCheatCodes;
|
|
39
37
|
committee: readonly `0x${string}`[];
|
|
@@ -41,7 +39,8 @@ export declare function awaitCommitteeKicked({ rollup, cheatCodes, committee, sl
|
|
|
41
39
|
slashingProposer: EmpireSlashingProposerContract | TallySlashingProposerContract | undefined;
|
|
42
40
|
slashingRoundSize: number;
|
|
43
41
|
aztecSlotDuration: number;
|
|
44
|
-
|
|
42
|
+
aztecEpochDuration: number;
|
|
45
43
|
logger: Logger;
|
|
44
|
+
offenseEpoch: number;
|
|
46
45
|
}): Promise<void>;
|
|
47
46
|
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/e2e_p2p/shared.ts"],"names":[],"mapp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package/dest/e2e_p2p/shared.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Fr
|
|
1
|
+
import { getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
|
|
2
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
+
import { TxStatus } from '@aztec/aztec.js/tx';
|
|
3
4
|
import { timesAsync, unique } from '@aztec/foundation/collection';
|
|
5
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
6
|
+
import { pluralize } from '@aztec/foundation/string';
|
|
4
7
|
import { TestContract, TestContractArtifact } from '@aztec/noir-test-contracts.js/Test';
|
|
5
|
-
import {
|
|
8
|
+
import { getPXEConfig, getPXEConfig as getRpcConfig } from '@aztec/pxe/server';
|
|
6
9
|
import { getRoundForOffense } from '@aztec/slasher';
|
|
10
|
+
import { TestWallet, proveInteraction } from '@aztec/test-wallet/server';
|
|
7
11
|
import { submitTxsTo } from '../shared/submit-transactions.js';
|
|
8
12
|
// submits a set of transactions to the provided Private eXecution Environment (PXE)
|
|
9
13
|
export const submitComplexTxsTo = async (logger, from, spamContract, numTxs, opts = {})=>{
|
|
@@ -26,51 +30,42 @@ export const submitComplexTxsTo = async (logger, from, spamContract, numTxs, opt
|
|
|
26
30
|
}
|
|
27
31
|
return txs;
|
|
28
32
|
};
|
|
29
|
-
// creates
|
|
30
|
-
export const
|
|
33
|
+
// creates a wallet and submit a given number of transactions through it.
|
|
34
|
+
export const submitTransactions = async (logger, node, numTxs, fundedAccount)=>{
|
|
31
35
|
const rpcConfig = getRpcConfig();
|
|
32
36
|
rpcConfig.proverEnabled = false;
|
|
33
|
-
const
|
|
37
|
+
const wallet = await TestWallet.create(node, {
|
|
38
|
+
...getPXEConfig(),
|
|
39
|
+
proverEnabled: false
|
|
40
|
+
}, {
|
|
34
41
|
useLogSuffix: true
|
|
35
42
|
});
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
const wallet = await account.getWallet();
|
|
39
|
-
const txs = await submitTxsTo(pxeService, numTxs, wallet, logger);
|
|
40
|
-
return {
|
|
41
|
-
txs,
|
|
42
|
-
pxeService,
|
|
43
|
-
node
|
|
44
|
-
};
|
|
43
|
+
const fundedAccountManager = await wallet.createSchnorrAccount(fundedAccount.secret, fundedAccount.salt);
|
|
44
|
+
return submitTxsTo(wallet, fundedAccountManager.address, numTxs, logger);
|
|
45
45
|
};
|
|
46
|
-
export async function
|
|
46
|
+
export async function prepareTransactions(logger, node, numTxs, fundedAccount) {
|
|
47
47
|
const rpcConfig = getRpcConfig();
|
|
48
48
|
rpcConfig.proverEnabled = false;
|
|
49
|
-
const
|
|
49
|
+
const wallet = await TestWallet.create(node, {
|
|
50
|
+
...getPXEConfig(),
|
|
51
|
+
proverEnabled: false
|
|
52
|
+
}, {
|
|
50
53
|
useLogSuffix: true
|
|
51
54
|
});
|
|
52
|
-
const
|
|
53
|
-
await
|
|
54
|
-
|
|
55
|
-
const testContractInstance = await getContractInstanceFromInstantiationParams(TestContractArtifact, {});
|
|
56
|
-
await wallet.registerContract({
|
|
57
|
-
instance: testContractInstance,
|
|
58
|
-
artifact: TestContractArtifact
|
|
55
|
+
const fundedAccountManager = await wallet.createSchnorrAccount(fundedAccount.secret, fundedAccount.salt);
|
|
56
|
+
const testContractInstance = await getContractInstanceFromInstantiationParams(TestContractArtifact, {
|
|
57
|
+
salt: Fr.random()
|
|
59
58
|
});
|
|
59
|
+
await wallet.registerContract(testContractInstance, TestContractArtifact);
|
|
60
60
|
const contract = await TestContract.at(testContractInstance.address, wallet);
|
|
61
|
-
|
|
62
|
-
const tx = await contract.methods.emit_nullifier(Fr.random())
|
|
63
|
-
from:
|
|
61
|
+
return timesAsync(numTxs, async ()=>{
|
|
62
|
+
const tx = await proveInteraction(wallet, contract.methods.emit_nullifier(Fr.random()), {
|
|
63
|
+
from: fundedAccountManager.address
|
|
64
64
|
});
|
|
65
65
|
const txHash = tx.getTxHash();
|
|
66
66
|
logger.info(`Tx prepared with hash ${txHash}`);
|
|
67
67
|
return tx;
|
|
68
68
|
});
|
|
69
|
-
return {
|
|
70
|
-
txs,
|
|
71
|
-
pxeService: pxe,
|
|
72
|
-
node
|
|
73
|
-
};
|
|
74
69
|
}
|
|
75
70
|
export function awaitProposalExecution(slashingProposer, timeoutSeconds, logger) {
|
|
76
71
|
return new Promise((resolve, reject)=>{
|
|
@@ -107,37 +102,36 @@ export async function awaitCommitteeExists({ rollup, logger }) {
|
|
|
107
102
|
}, 'non-empty committee', 60);
|
|
108
103
|
return committee;
|
|
109
104
|
}
|
|
110
|
-
export async function awaitOffenseDetected({ logger, nodeAdmin, slashingRoundSize, epochDuration }) {
|
|
111
|
-
|
|
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`);
|
|
112
108
|
const offenses = await retryUntil(async ()=>{
|
|
113
109
|
const offenses = await nodeAdmin.getSlashOffenses('all');
|
|
114
|
-
if (offenses.length
|
|
110
|
+
if (offenses.length >= targetOffenseCount) {
|
|
115
111
|
return offenses;
|
|
116
112
|
}
|
|
117
|
-
}, 'non-empty offenses',
|
|
113
|
+
}, 'non-empty offenses', timeoutSeconds);
|
|
118
114
|
logger.info(`Hit ${offenses.length} offenses on rounds ${unique(offenses.map((o)=>getRoundForOffense(o, {
|
|
119
115
|
slashingRoundSize,
|
|
120
116
|
epochDuration
|
|
121
|
-
})))}`,
|
|
117
|
+
})))}`, {
|
|
118
|
+
offenses
|
|
119
|
+
});
|
|
122
120
|
return offenses;
|
|
123
121
|
}
|
|
124
122
|
/**
|
|
125
123
|
* Await the committee to be slashed out of the validator set.
|
|
126
124
|
* Currently assumes that the committee is the same size as the validator set.
|
|
127
|
-
*/ export async function awaitCommitteeKicked({ rollup, cheatCodes, committee, slashFactory, slashingProposer, slashingRoundSize, aztecSlotDuration, logger,
|
|
125
|
+
*/ export async function awaitCommitteeKicked({ rollup, cheatCodes, committee, slashFactory, slashingProposer, slashingRoundSize, aztecSlotDuration, aztecEpochDuration, logger, offenseEpoch }) {
|
|
128
126
|
if (!slashingProposer) {
|
|
129
127
|
throw new Error('No slashing proposer configured. Cannot test slashing.');
|
|
130
128
|
}
|
|
131
|
-
logger.info(`Advancing epochs so we start slashing`);
|
|
132
129
|
await cheatCodes.debugRollup();
|
|
133
|
-
await cheatCodes.advanceToNextEpoch({
|
|
134
|
-
updateDateProvider: dateProvider
|
|
135
|
-
});
|
|
136
|
-
await cheatCodes.advanceToNextEpoch({
|
|
137
|
-
updateDateProvider: dateProvider
|
|
138
|
-
});
|
|
139
|
-
// Await for the slash payload to be created if empire (no payload is created on tally until execution time)
|
|
140
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);
|
|
141
135
|
const slashPayloadEvents = await retryUntil(async ()=>{
|
|
142
136
|
const events = await slashFactory.getSlashPayloadCreatedEvents();
|
|
143
137
|
return events.length > 0 ? events : undefined;
|
|
@@ -145,6 +139,17 @@ export async function awaitOffenseDetected({ logger, nodeAdmin, slashingRoundSiz
|
|
|
145
139
|
expect(slashPayloadEvents.length).toBe(1);
|
|
146
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)
|
|
147
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
|
+
});
|
|
148
153
|
}
|
|
149
154
|
const attestersPre = await rollup.getAttesters();
|
|
150
155
|
expect(attestersPre.length).toBe(committee.length);
|
|
@@ -152,7 +157,7 @@ export async function awaitOffenseDetected({ logger, nodeAdmin, slashingRoundSiz
|
|
|
152
157
|
const attesterInfo = await rollup.getAttesterView(attester);
|
|
153
158
|
expect(attesterInfo.status).toEqual(1); // Validating
|
|
154
159
|
}
|
|
155
|
-
const timeout = slashingRoundSize * 2 * aztecSlotDuration;
|
|
160
|
+
const timeout = slashingRoundSize * 2 * aztecSlotDuration + 30;
|
|
156
161
|
logger.info(`Waiting for slash to be executed (timeout ${timeout}s)`);
|
|
157
162
|
await awaitProposalExecution(slashingProposer, timeout, logger);
|
|
158
163
|
// The attesters should still form the committee but they should be reduced to the "living" status
|
|
@@ -165,14 +170,9 @@ export async function awaitOffenseDetected({ logger, nodeAdmin, slashingRoundSiz
|
|
|
165
170
|
const attesterInfo = await rollup.getAttesterView(attester);
|
|
166
171
|
expect(attesterInfo.status).toEqual(2); // Living
|
|
167
172
|
}
|
|
168
|
-
logger.info(`Advancing
|
|
173
|
+
logger.info(`Advancing to check current committee`);
|
|
169
174
|
await cheatCodes.debugRollup();
|
|
170
|
-
await cheatCodes.
|
|
171
|
-
updateDateProvider: dateProvider
|
|
172
|
-
});
|
|
173
|
-
await cheatCodes.advanceToNextEpoch({
|
|
174
|
-
updateDateProvider: dateProvider
|
|
175
|
-
});
|
|
175
|
+
await cheatCodes.advanceToEpoch(await cheatCodes.getEpoch() + await rollup.getLagInEpochs() + 1n);
|
|
176
176
|
await cheatCodes.debugRollup();
|
|
177
177
|
const committeeNextEpoch = await rollup.getCurrentEpochCommittee();
|
|
178
178
|
// The committee should be undefined, since the validator set is empty
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
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';
|
|
2
4
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
3
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 {
|
|
@@ -13,11 +16,9 @@ export declare class TokenContractTest {
|
|
|
13
16
|
tokenSim: TokenSimulator;
|
|
14
17
|
node: AztecNode;
|
|
15
18
|
badAccount: InvalidAccountContract;
|
|
16
|
-
|
|
19
|
+
wallet: TestWallet;
|
|
17
20
|
adminAddress: AztecAddress;
|
|
18
|
-
account1: AccountWallet;
|
|
19
21
|
account1Address: AztecAddress;
|
|
20
|
-
account2: AccountWallet;
|
|
21
22
|
account2Address: AztecAddress;
|
|
22
23
|
constructor(testName: string);
|
|
23
24
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token_contract_test.d.ts","sourceRoot":"","sources":["../../src/e2e_token_contract/token_contract_test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"token_contract_test.d.ts","sourceRoot":"","sources":["../../src/e2e_token_contract/token_contract_test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY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-
import {
|
|
2
|
-
import { createLogger } from '@aztec/aztec.js';
|
|
1
|
+
import { createLogger } from '@aztec/aztec.js/log';
|
|
3
2
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
4
3
|
import { InvalidAccountContract } from '@aztec/noir-test-contracts.js/InvalidAccount';
|
|
5
4
|
import { jest } from '@jest/globals';
|
|
@@ -17,11 +16,9 @@ export class TokenContractTest {
|
|
|
17
16
|
tokenSim;
|
|
18
17
|
node;
|
|
19
18
|
badAccount;
|
|
20
|
-
|
|
19
|
+
wallet;
|
|
21
20
|
adminAddress;
|
|
22
|
-
account1;
|
|
23
21
|
account1Address;
|
|
24
|
-
account2;
|
|
25
22
|
account2Address;
|
|
26
23
|
constructor(testName){
|
|
27
24
|
this.logger = createLogger(`e2e:e2e_token_contract:${testName}`);
|
|
@@ -36,27 +33,27 @@ export class TokenContractTest {
|
|
|
36
33
|
*/ async applyBaseSnapshots() {
|
|
37
34
|
// Adding a timeout of 2 minutes in here such that it is propagated to the underlying tests
|
|
38
35
|
jest.setTimeout(120_000);
|
|
39
|
-
await this.snapshotManager.snapshot('3_accounts', deployAccounts(3, this.logger),
|
|
36
|
+
await this.snapshotManager.snapshot('3_accounts', deployAccounts(3, this.logger), ({ deployedAccounts }, { wallet, aztecNode })=>{
|
|
40
37
|
this.node = aztecNode;
|
|
41
|
-
|
|
42
|
-
[this.
|
|
43
|
-
|
|
38
|
+
this.wallet = wallet;
|
|
39
|
+
[this.adminAddress, this.account1Address, this.account2Address] = deployedAccounts.map((acc)=>acc.address);
|
|
40
|
+
return Promise.resolve();
|
|
44
41
|
});
|
|
45
42
|
await this.snapshotManager.snapshot('e2e_token_contract', async ()=>{
|
|
46
43
|
// Create the token contract state.
|
|
47
44
|
// Move this account thing to addAccounts above?
|
|
48
45
|
this.logger.verbose(`Public deploy accounts...`);
|
|
49
|
-
await publicDeployAccounts(this.
|
|
46
|
+
await publicDeployAccounts(this.wallet, [
|
|
50
47
|
this.adminAddress,
|
|
51
48
|
this.account1Address
|
|
52
49
|
]);
|
|
53
50
|
this.logger.verbose(`Deploying TokenContract...`);
|
|
54
|
-
const asset = await TokenContract.deploy(this.
|
|
51
|
+
const asset = await TokenContract.deploy(this.wallet, this.adminAddress, TokenContractTest.TOKEN_NAME, TokenContractTest.TOKEN_SYMBOL, TokenContractTest.TOKEN_DECIMALS).send({
|
|
55
52
|
from: this.adminAddress
|
|
56
53
|
}).deployed();
|
|
57
54
|
this.logger.verbose(`Token deployed to ${asset.address}`);
|
|
58
55
|
this.logger.verbose(`Deploying bad account...`);
|
|
59
|
-
this.badAccount = await InvalidAccountContract.deploy(this.
|
|
56
|
+
this.badAccount = await InvalidAccountContract.deploy(this.wallet).send({
|
|
60
57
|
from: this.adminAddress
|
|
61
58
|
}).deployed();
|
|
62
59
|
this.logger.verbose(`Deployed to ${this.badAccount.address}.`);
|
|
@@ -66,13 +63,13 @@ export class TokenContractTest {
|
|
|
66
63
|
};
|
|
67
64
|
}, async ({ tokenContractAddress, badAccountAddress })=>{
|
|
68
65
|
// Restore the token contract state.
|
|
69
|
-
this.asset = await TokenContract.at(tokenContractAddress, this.
|
|
66
|
+
this.asset = await TokenContract.at(tokenContractAddress, this.wallet);
|
|
70
67
|
this.logger.verbose(`Token contract address: ${this.asset.address}`);
|
|
71
|
-
this.tokenSim = new TokenSimulator(this.asset, this.
|
|
68
|
+
this.tokenSim = new TokenSimulator(this.asset, this.wallet, this.adminAddress, this.logger, [
|
|
72
69
|
this.adminAddress,
|
|
73
70
|
this.account1Address
|
|
74
71
|
]);
|
|
75
|
-
this.badAccount = await InvalidAccountContract.at(badAccountAddress, this.
|
|
72
|
+
this.badAccount = await InvalidAccountContract.at(badAccountAddress, this.wallet);
|
|
76
73
|
this.logger.verbose(`Bad account address: ${this.badAccount.address}`);
|
|
77
74
|
expect(await this.asset.methods.get_admin().simulate({
|
|
78
75
|
from: this.adminAddress
|
|
@@ -92,14 +89,14 @@ export class TokenContractTest {
|
|
|
92
89
|
}
|
|
93
90
|
async applyMintSnapshot() {
|
|
94
91
|
await this.snapshotManager.snapshot('mint', async ()=>{
|
|
95
|
-
const { asset,
|
|
92
|
+
const { asset, adminAddress } = this;
|
|
96
93
|
const amount = 10000n;
|
|
97
94
|
this.logger.verbose(`Minting ${amount} publicly...`);
|
|
98
95
|
await asset.methods.mint_to_public(adminAddress, amount).send({
|
|
99
96
|
from: adminAddress
|
|
100
97
|
}).wait();
|
|
101
98
|
this.logger.verbose(`Minting ${amount} privately...`);
|
|
102
|
-
await mintTokensToPrivate(asset, adminAddress,
|
|
99
|
+
await mintTokensToPrivate(asset, adminAddress, adminAddress, amount);
|
|
103
100
|
this.logger.verbose(`Minting complete.`);
|
|
104
101
|
return {
|
|
105
102
|
amount
|