@maci-protocol/coordinator 0.0.0-ci.8a288fb → 0.0.0-ci.8bb6ea8
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/LICENSE +1 -2
- package/README.md +71 -10
- package/build/hardhat.config.cjs +17 -9
- package/build/hardhat.config.cjs.map +1 -1
- package/build/hardhat.config.d.cts +15 -12
- package/build/hardhat.config.d.cts.map +1 -1
- package/build/scripts/generateKeypair.js +2 -2
- package/build/scripts/generateKeypair.js.map +1 -1
- package/build/scripts/generateMaciKeyPair.js +2 -2
- package/build/scripts/generateMaciKeyPair.js.map +1 -1
- package/build/tests/constants.d.ts +3 -4
- package/build/tests/constants.d.ts.map +1 -1
- package/build/tests/constants.js +5 -4
- package/build/tests/constants.js.map +1 -1
- package/build/tests/e2e.deploy.test.js +132 -102
- package/build/tests/e2e.deploy.test.js.map +1 -1
- package/build/tests/e2e.redis.test.d.ts +2 -0
- package/build/tests/e2e.redis.test.d.ts.map +1 -0
- package/build/tests/e2e.redis.test.js +118 -0
- package/build/tests/e2e.redis.test.js.map +1 -0
- package/build/tests/utils.d.ts +7 -1
- package/build/tests/utils.d.ts.map +1 -1
- package/build/tests/utils.js +17 -6
- package/build/tests/utils.js.map +1 -1
- package/build/ts/app.module.d.ts.map +1 -1
- package/build/ts/app.module.js +6 -0
- package/build/ts/app.module.js.map +1 -1
- package/build/ts/common/__tests__/common.test.js +44 -46
- package/build/ts/common/__tests__/common.test.js.map +1 -1
- package/build/ts/common/accountAbstraction.d.ts +7 -24
- package/build/ts/common/accountAbstraction.d.ts.map +1 -1
- package/build/ts/common/accountAbstraction.js +22 -49
- package/build/ts/common/accountAbstraction.js.map +1 -1
- package/build/ts/common/chain.d.ts +22 -0
- package/build/ts/common/chain.d.ts.map +1 -0
- package/build/ts/common/chain.js +37 -0
- package/build/ts/common/chain.js.map +1 -0
- package/build/ts/common/coordinatorKeypair.d.ts +7 -0
- package/build/ts/common/coordinatorKeypair.d.ts.map +1 -0
- package/build/ts/common/coordinatorKeypair.js +14 -0
- package/build/ts/common/coordinatorKeypair.js.map +1 -0
- package/build/ts/common/errors.d.ts +13 -10
- package/build/ts/common/errors.d.ts.map +1 -1
- package/build/ts/common/errors.js +12 -9
- package/build/ts/common/errors.js.map +1 -1
- package/build/ts/common/http.d.ts +6 -0
- package/build/ts/common/http.d.ts.map +1 -0
- package/build/ts/common/http.js +49 -0
- package/build/ts/common/http.js.map +1 -0
- package/build/ts/common/index.d.ts +3 -1
- package/build/ts/common/index.d.ts.map +1 -1
- package/build/ts/common/index.js +3 -1
- package/build/ts/common/index.js.map +1 -1
- package/build/ts/common/networks.d.ts +2 -21
- package/build/ts/common/networks.d.ts.map +1 -1
- package/build/ts/common/networks.js +39 -48
- package/build/ts/common/networks.js.map +1 -1
- package/build/ts/common/types.d.ts +3 -4
- package/build/ts/common/types.d.ts.map +1 -1
- package/build/ts/deployer/__tests__/deployer.controller.test.js +23 -25
- package/build/ts/deployer/__tests__/deployer.controller.test.js.map +1 -1
- package/build/ts/deployer/__tests__/deployer.service.test.js +184 -337
- package/build/ts/deployer/__tests__/deployer.service.test.js.map +1 -1
- package/build/ts/deployer/__tests__/utils.d.ts +31 -6
- package/build/ts/deployer/__tests__/utils.d.ts.map +1 -1
- package/build/ts/deployer/__tests__/utils.js +48 -22
- package/build/ts/deployer/__tests__/utils.js.map +1 -1
- package/build/ts/deployer/deployer.controller.d.ts.map +1 -1
- package/build/ts/deployer/deployer.controller.js +19 -6
- package/build/ts/deployer/deployer.controller.js.map +1 -1
- package/build/ts/deployer/deployer.service.d.ts +26 -53
- package/build/ts/deployer/deployer.service.d.ts.map +1 -1
- package/build/ts/deployer/deployer.service.js +345 -454
- package/build/ts/deployer/deployer.service.js.map +1 -1
- package/build/ts/deployer/dto.d.ts +7 -7
- package/build/ts/deployer/dto.d.ts.map +1 -1
- package/build/ts/deployer/dto.js +14 -6
- package/build/ts/deployer/dto.js.map +1 -1
- package/build/ts/deployer/types.d.ts +103 -45
- package/build/ts/deployer/types.d.ts.map +1 -1
- package/build/ts/file/__tests__/file.service.test.js +12 -11
- package/build/ts/file/__tests__/file.service.test.js.map +1 -1
- package/build/ts/file/file.service.d.ts +4 -3
- package/build/ts/file/file.service.d.ts.map +1 -1
- package/build/ts/file/file.service.js +16 -10
- package/build/ts/file/file.service.js.map +1 -1
- package/build/ts/file/types.d.ts +2 -2
- package/build/ts/file/types.d.ts.map +1 -1
- package/build/ts/health/__tests__/health.controller.test.d.ts +2 -0
- package/build/ts/health/__tests__/health.controller.test.d.ts.map +1 -0
- package/build/ts/health/__tests__/health.controller.test.js +52 -0
- package/build/ts/health/__tests__/health.controller.test.js.map +1 -0
- package/build/ts/health/__tests__/health.service.test.d.ts +2 -0
- package/build/ts/health/__tests__/health.service.test.d.ts.map +1 -0
- package/build/ts/health/__tests__/health.service.test.js +101 -0
- package/build/ts/health/__tests__/health.service.test.js.map +1 -0
- package/build/ts/health/health.controller.d.ts +16 -0
- package/build/ts/health/health.controller.d.ts.map +1 -0
- package/build/ts/health/health.controller.js +43 -0
- package/build/ts/health/health.controller.js.map +1 -0
- package/build/ts/health/health.module.d.ts +3 -0
- package/build/ts/health/health.module.d.ts.map +1 -0
- package/build/ts/health/health.module.js +22 -0
- package/build/ts/health/health.module.js.map +1 -0
- package/build/ts/health/health.service.d.ts +42 -0
- package/build/ts/health/health.service.d.ts.map +1 -0
- package/build/ts/health/health.service.js +176 -0
- package/build/ts/health/health.service.js.map +1 -0
- package/build/ts/health/types.d.ts +87 -0
- package/build/ts/health/types.d.ts.map +1 -0
- package/build/ts/health/types.js +2 -0
- package/build/ts/health/types.js.map +1 -0
- package/build/ts/jest/__mocks__/@openzeppelin/merkle-tree.d.ts +11 -0
- package/build/ts/jest/__mocks__/@openzeppelin/merkle-tree.d.ts.map +1 -0
- package/build/ts/jest/__mocks__/@openzeppelin/merkle-tree.js +12 -0
- package/build/ts/jest/__mocks__/@openzeppelin/merkle-tree.js.map +1 -0
- package/build/ts/main.js +1 -1
- package/build/ts/proof/__tests__/proof.controller.test.js +8 -7
- package/build/ts/proof/__tests__/proof.controller.test.js.map +1 -1
- package/build/ts/proof/__tests__/proof.gateway.test.js +5 -3
- package/build/ts/proof/__tests__/proof.gateway.test.js.map +1 -1
- package/build/ts/proof/__tests__/proof.service.test.js +31 -75
- package/build/ts/proof/__tests__/proof.service.test.js.map +1 -1
- package/build/ts/proof/dto.d.ts +15 -18
- package/build/ts/proof/dto.d.ts.map +1 -1
- package/build/ts/proof/dto.js +55 -49
- package/build/ts/proof/dto.js.map +1 -1
- package/build/ts/proof/proof.controller.d.ts +3 -2
- package/build/ts/proof/proof.controller.d.ts.map +1 -1
- package/build/ts/proof/proof.controller.js +38 -15
- package/build/ts/proof/proof.controller.js.map +1 -1
- package/build/ts/proof/proof.module.d.ts.map +1 -1
- package/build/ts/proof/proof.module.js +1 -0
- package/build/ts/proof/proof.module.js.map +1 -1
- package/build/ts/proof/proof.service.d.ts +4 -6
- package/build/ts/proof/proof.service.d.ts.map +1 -1
- package/build/ts/proof/proof.service.js +48 -130
- package/build/ts/proof/proof.service.js.map +1 -1
- package/build/ts/proof/types.d.ts +21 -17
- package/build/ts/proof/types.d.ts.map +1 -1
- package/build/ts/proof/types.js.map +1 -1
- package/build/ts/redis/__tests__/redis.service.test.d.ts +2 -0
- package/build/ts/redis/__tests__/redis.service.test.d.ts.map +1 -0
- package/build/ts/redis/__tests__/redis.service.test.js +148 -0
- package/build/ts/redis/__tests__/redis.service.test.js.map +1 -0
- package/build/ts/redis/redis.module.d.ts +3 -0
- package/build/ts/redis/redis.module.d.ts.map +1 -0
- package/build/ts/redis/redis.module.js +18 -0
- package/build/ts/redis/redis.module.js.map +1 -0
- package/build/ts/redis/redis.service.d.ts +53 -0
- package/build/ts/redis/redis.service.d.ts.map +1 -0
- package/build/ts/redis/redis.service.js +99 -0
- package/build/ts/redis/redis.service.js.map +1 -0
- package/build/ts/redis/types.d.ts +66 -0
- package/build/ts/redis/types.d.ts.map +1 -0
- package/build/ts/redis/types.js +2 -0
- package/build/ts/redis/types.js.map +1 -0
- package/build/ts/redis/utils.d.ts +20 -0
- package/build/ts/redis/utils.d.ts.map +1 -0
- package/build/ts/redis/utils.js +27 -0
- package/build/ts/redis/utils.js.map +1 -0
- package/build/ts/scheduler/__tests__/scheduler.controller.test.d.ts +2 -0
- package/build/ts/scheduler/__tests__/scheduler.controller.test.d.ts.map +1 -0
- package/build/ts/scheduler/__tests__/scheduler.controller.test.js +62 -0
- package/build/ts/scheduler/__tests__/scheduler.controller.test.js.map +1 -0
- package/build/ts/scheduler/__tests__/scheduler.service.test.d.ts +2 -0
- package/build/ts/scheduler/__tests__/scheduler.service.test.d.ts.map +1 -0
- package/build/ts/scheduler/__tests__/scheduler.service.test.js +369 -0
- package/build/ts/scheduler/__tests__/scheduler.service.test.js.map +1 -0
- package/build/ts/scheduler/dto.d.ts +41 -0
- package/build/ts/scheduler/dto.d.ts.map +1 -0
- package/build/ts/scheduler/dto.js +115 -0
- package/build/ts/scheduler/dto.js.map +1 -0
- package/build/ts/scheduler/scheduler.controller.d.ts +32 -0
- package/build/ts/scheduler/scheduler.controller.d.ts.map +1 -0
- package/build/ts/scheduler/scheduler.controller.js +118 -0
- package/build/ts/scheduler/scheduler.controller.js.map +1 -0
- package/build/ts/scheduler/scheduler.module.d.ts +3 -0
- package/build/ts/scheduler/scheduler.module.d.ts.map +1 -0
- package/build/ts/scheduler/scheduler.module.js +24 -0
- package/build/ts/scheduler/scheduler.module.js.map +1 -0
- package/build/ts/scheduler/scheduler.service.d.ts +71 -0
- package/build/ts/scheduler/scheduler.service.d.ts.map +1 -0
- package/build/ts/scheduler/scheduler.service.js +297 -0
- package/build/ts/scheduler/scheduler.service.js.map +1 -0
- package/build/ts/scheduler/types.d.ts +65 -0
- package/build/ts/scheduler/types.d.ts.map +1 -0
- package/build/ts/scheduler/types.js +2 -0
- package/build/ts/scheduler/types.js.map +1 -0
- package/build/ts/sessionKeys/__tests__/sessionKeys.controller.test.js +2 -2
- package/build/ts/sessionKeys/__tests__/sessionKeys.controller.test.js.map +1 -1
- package/build/ts/sessionKeys/__tests__/sessionKeys.service.test.js +34 -19
- package/build/ts/sessionKeys/__tests__/sessionKeys.service.test.js.map +1 -1
- package/build/ts/sessionKeys/__tests__/utils.d.ts +1 -1
- package/build/ts/sessionKeys/__tests__/utils.d.ts.map +1 -1
- package/build/ts/sessionKeys/__tests__/utils.js +7 -6
- package/build/ts/sessionKeys/__tests__/utils.js.map +1 -1
- package/build/ts/sessionKeys/provider/KernelEIP1193Provider.d.ts +53 -0
- package/build/ts/sessionKeys/provider/KernelEIP1193Provider.d.ts.map +1 -0
- package/build/ts/sessionKeys/provider/KernelEIP1193Provider.js +105 -0
- package/build/ts/sessionKeys/provider/KernelEIP1193Provider.js.map +1 -0
- package/build/ts/sessionKeys/sessionKeys.service.d.ts +16 -4
- package/build/ts/sessionKeys/sessionKeys.service.d.ts.map +1 -1
- package/build/ts/sessionKeys/sessionKeys.service.js +23 -6
- package/build/ts/sessionKeys/sessionKeys.service.js.map +1 -1
- package/build/ts/subgraph/__tests__/subgraph.controller.test.js +3 -3
- package/build/ts/subgraph/__tests__/subgraph.controller.test.js.map +1 -1
- package/build/ts/subgraph/__tests__/subgraph.gateway.test.js +2 -2
- package/build/ts/subgraph/__tests__/subgraph.gateway.test.js.map +1 -1
- package/build/ts/subgraph/__tests__/subgraph.service.test.js +5 -5
- package/build/ts/subgraph/__tests__/subgraph.service.test.js.map +1 -1
- package/build/ts/subgraph/dto.d.ts +2 -2
- package/build/ts/subgraph/dto.d.ts.map +1 -1
- package/build/ts/subgraph/dto.js +3 -3
- package/build/ts/subgraph/dto.js.map +1 -1
- package/build/ts/subgraph/subgraph.controller.d.ts.map +1 -1
- package/build/ts/subgraph/subgraph.controller.js +8 -3
- package/build/ts/subgraph/subgraph.controller.js.map +1 -1
- package/build/ts/subgraph/subgraph.service.d.ts +4 -0
- package/build/ts/subgraph/subgraph.service.d.ts.map +1 -1
- package/build/ts/subgraph/subgraph.service.js +23 -10
- package/build/ts/subgraph/subgraph.service.js.map +1 -1
- package/build/ts/subgraph/types.d.ts +2 -2
- package/build/ts/subgraph/types.d.ts.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +46 -39
- package/build/tests/e2e.aa.test.d.ts +0 -2
- package/build/tests/e2e.aa.test.d.ts.map +0 -1
- package/build/tests/e2e.aa.test.js +0 -103
- package/build/tests/e2e.aa.test.js.map +0 -1
- package/build/ts/deployer/utils.d.ts +0 -8
- package/build/ts/deployer/utils.d.ts.map +0 -1
- package/build/ts/deployer/utils.js +0 -9
- package/build/ts/deployer/utils.js.map +0 -1
|
@@ -1,321 +1,186 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ContractStorage, deployFreeForAllSignUpPolicy, deployPoll, deployVerifier, deployVerifyingKeysRegistryContract, deployMaci, deployConstantInitialVoiceCreditProxyFactory, deployConstantInitialVoiceCreditProxy, getDeployedPolicyProxyFactories, ECheckerFactories, EContracts, EInitialVoiceCreditProxies, EInitialVoiceCreditProxiesFactories, EPolicies, EPolicyFactories, ESupportedChains, ECheckers, } from "@maci-protocol/sdk";
|
|
2
2
|
import dotenv from "dotenv";
|
|
3
|
-
import { BaseContract, zeroPadBytes } from "ethers";
|
|
4
3
|
import { zeroAddress } from "viem";
|
|
5
|
-
import
|
|
6
|
-
import { ErrorCodes, ESupportedNetworks } from "../../common";
|
|
7
|
-
import { FileService } from "../../file/file.service";
|
|
8
|
-
import { generateApproval } from "../../sessionKeys/__tests__/utils";
|
|
9
|
-
import { SessionKeysService } from "../../sessionKeys/sessionKeys.service";
|
|
4
|
+
import { ErrorCodes } from "../../common";
|
|
10
5
|
import { DeployerService } from "../deployer.service";
|
|
11
|
-
import { estimateExtraGasLimit } from "../utils";
|
|
12
6
|
import { testMaciDeploymentConfig, testPollDeploymentConfig } from "./utils";
|
|
13
7
|
dotenv.config();
|
|
8
|
+
jest.mock("@maci-protocol/sdk", () => ({
|
|
9
|
+
...jest.requireActual("@maci-protocol/sdk"),
|
|
10
|
+
ContractStorage: {
|
|
11
|
+
getInstance: jest.fn(),
|
|
12
|
+
},
|
|
13
|
+
deployFreeForAllSignUpPolicy: jest.fn(),
|
|
14
|
+
deployPoll: jest.fn(),
|
|
15
|
+
deployVerifyingKeysRegistryContract: jest.fn(),
|
|
16
|
+
deployVerifier: jest.fn(),
|
|
17
|
+
getDeployedPolicyProxyFactories: jest.fn(),
|
|
18
|
+
setVerifyingKeys: jest.fn(),
|
|
19
|
+
deployMaci: jest.fn(),
|
|
20
|
+
deployConstantInitialVoiceCreditProxyFactory: jest.fn(),
|
|
21
|
+
deployConstantInitialVoiceCreditProxy: jest.fn(),
|
|
22
|
+
}));
|
|
14
23
|
describe("DeployerService", () => {
|
|
24
|
+
const chain = ESupportedChains.OptimismSepolia;
|
|
25
|
+
const signer = {
|
|
26
|
+
getAddress: jest.fn().mockResolvedValue(zeroAddress),
|
|
27
|
+
};
|
|
28
|
+
const approval = "approval";
|
|
29
|
+
const sessionKeyAddress = zeroAddress;
|
|
30
|
+
const mockStorage = {
|
|
31
|
+
register: jest.fn(),
|
|
32
|
+
getAddress: jest.fn(),
|
|
33
|
+
};
|
|
34
|
+
const mockContract = {
|
|
35
|
+
deploymentTransaction: jest.fn(),
|
|
36
|
+
getAddress: jest.fn().mockResolvedValue(zeroAddress.replace("0x0", "0x1")),
|
|
37
|
+
};
|
|
38
|
+
const fileService = {
|
|
39
|
+
getZkeyFilePaths: jest.fn(),
|
|
40
|
+
};
|
|
41
|
+
const sessionKeyService = {
|
|
42
|
+
getCoordinatorSigner: jest.fn().mockResolvedValue(signer),
|
|
43
|
+
};
|
|
44
|
+
beforeEach(() => {
|
|
45
|
+
mockStorage.getAddress = jest.fn().mockReturnValue(zeroAddress);
|
|
46
|
+
sessionKeyService.getCoordinatorSigner = jest.fn().mockResolvedValue(signer);
|
|
47
|
+
fileService.getZkeyFilePaths = jest.fn().mockReturnValue({ zkey: "" });
|
|
48
|
+
ContractStorage.getInstance.mockReturnValue(mockStorage);
|
|
49
|
+
deployFreeForAllSignUpPolicy.mockResolvedValue([
|
|
50
|
+
mockContract,
|
|
51
|
+
mockContract,
|
|
52
|
+
mockContract,
|
|
53
|
+
mockContract,
|
|
54
|
+
]);
|
|
55
|
+
deployVerifier.mockResolvedValue(mockContract);
|
|
56
|
+
deployVerifyingKeysRegistryContract.mockResolvedValue(mockContract);
|
|
57
|
+
deployConstantInitialVoiceCreditProxyFactory.mockResolvedValue(mockContract);
|
|
58
|
+
deployConstantInitialVoiceCreditProxy.mockResolvedValue(mockContract);
|
|
59
|
+
deployPoll.mockResolvedValue({
|
|
60
|
+
pollContractAddress: zeroAddress,
|
|
61
|
+
messageProcessorContractAddress: zeroAddress,
|
|
62
|
+
tallyContractAddress: zeroAddress,
|
|
63
|
+
pollId: 0n,
|
|
64
|
+
});
|
|
65
|
+
deployMaci.mockResolvedValue({
|
|
66
|
+
maciContractAddress: zeroAddress.replace("0x0", "0x1"),
|
|
67
|
+
pollFactoryContractAddress: zeroAddress,
|
|
68
|
+
messageProcessorFactoryContractAddress: zeroAddress,
|
|
69
|
+
tallyFactoryContractAddress: zeroAddress,
|
|
70
|
+
poseidonAddresses: {
|
|
71
|
+
poseidonT3: zeroAddress,
|
|
72
|
+
poseidonT4: zeroAddress,
|
|
73
|
+
poseidonT5: zeroAddress,
|
|
74
|
+
poseidonT6: zeroAddress,
|
|
75
|
+
},
|
|
76
|
+
verifierContractAddress: zeroAddress,
|
|
77
|
+
verifyingKeysRegistryContractAddress: zeroAddress,
|
|
78
|
+
});
|
|
79
|
+
getDeployedPolicyProxyFactories.mockResolvedValue({ checker: undefined, policy: undefined });
|
|
80
|
+
});
|
|
15
81
|
afterEach(() => {
|
|
16
82
|
jest.clearAllMocks();
|
|
17
83
|
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
beforeAll(async () => {
|
|
26
|
-
approval = await generateApproval(sessionKeyAddress);
|
|
27
|
-
sessionKeyAddress = (await sessionKeyService.generateSessionKey()).sessionKeyAddress;
|
|
28
|
-
});
|
|
29
|
-
describe("getVoiceCreditProxyData", () => {
|
|
30
|
-
test("should return the voice credit proxy data", () => {
|
|
31
|
-
const voiceCreditProxyData = deployerService.getVoiceCreditProxyData(EInitialVoiceCreditProxies.Constant, chain, {
|
|
32
|
-
amount: "50",
|
|
33
|
-
});
|
|
34
|
-
expect(voiceCreditProxyData).toBeDefined();
|
|
35
|
-
expect(voiceCreditProxyData.alreadyDeployed).toBe(false);
|
|
36
|
-
expect(voiceCreditProxyData.abi).toBeDefined();
|
|
37
|
-
expect(voiceCreditProxyData.bytecode).toBeDefined();
|
|
84
|
+
describe("deployAndSavePolicy", () => {
|
|
85
|
+
test("should throw when the policy is not existent", async () => {
|
|
86
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
87
|
+
await expect(deployerService.deployAndSavePolicy(signer, chain, {
|
|
88
|
+
policyType: "NonExistent",
|
|
89
|
+
checkerType: "NonExistent",
|
|
90
|
+
})).rejects.toThrow(ErrorCodes.UNSUPPORTED_POLICY.toString());
|
|
38
91
|
});
|
|
39
|
-
test("should
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
args: ["50"],
|
|
92
|
+
test("should deploy policy if none is stored", async () => {
|
|
93
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
94
|
+
const policy = await deployerService.deployAndSavePolicy(signer, chain, {
|
|
95
|
+
policyType: EPolicies.FreeForAll,
|
|
96
|
+
checkerType: ECheckers.FreeForAll,
|
|
45
97
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
49
|
-
expect(voiceCreditProxyData).toBeDefined();
|
|
50
|
-
expect(voiceCreditProxyData.alreadyDeployed).toBe(true);
|
|
51
|
-
expect(voiceCreditProxyData.abi).toBeDefined();
|
|
52
|
-
expect(voiceCreditProxyData.bytecode).toBeDefined();
|
|
53
|
-
storageInstance.cleanup(chain);
|
|
54
|
-
});
|
|
55
|
-
it("should throw when the voice credits proxy is not existent", () => {
|
|
56
|
-
expect(() => deployerService.getVoiceCreditProxyData("NotExistent", chain, {
|
|
57
|
-
amount: "50",
|
|
58
|
-
})).toThrow(ErrorCodes.UNSUPPORTED_VOICE_CREDIT_PROXY.toString());
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
describe("getPolicyData", () => {
|
|
62
|
-
// we cleanup after each test so we don't have leftover saved contracts
|
|
63
|
-
afterEach(() => {
|
|
64
|
-
storageInstance.cleanup(chain);
|
|
65
|
-
});
|
|
66
|
-
it("should throw when the policy is not existent", () => {
|
|
67
|
-
expect(() => deployerService.getPolicyData("NotExistent", chain)).toThrow(ErrorCodes.UNSUPPORTED_POLICY.toString());
|
|
98
|
+
expect(policy).toBeDefined();
|
|
99
|
+
expect(await policy.getAddress()).not.toBe(zeroAddress);
|
|
68
100
|
});
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
expect(policyData.abi).toBeDefined();
|
|
75
|
-
expect(policyData.bytecode).toBeDefined();
|
|
101
|
+
test("should save factories (policy and checker) after deploying policy", async () => {
|
|
102
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
103
|
+
await deployerService.deployAndSavePolicy(signer, chain, {
|
|
104
|
+
policyType: EPolicies.FreeForAll,
|
|
105
|
+
checkerType: ECheckers.FreeForAll,
|
|
76
106
|
});
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const policyData = deployerService.getPolicyData(EPolicies.FreeForAll, chain);
|
|
85
|
-
expect(policyData).toBeDefined();
|
|
86
|
-
expect(policyData.alreadyDeployed).toBe(true);
|
|
87
|
-
expect(policyData.abi).toBeDefined();
|
|
88
|
-
expect(policyData.bytecode).toBeDefined();
|
|
107
|
+
expect(mockStorage.register).toHaveBeenCalledTimes(4);
|
|
108
|
+
expect(mockStorage.register).toHaveBeenNthCalledWith(1, {
|
|
109
|
+
id: EPolicies.FreeForAll,
|
|
110
|
+
name: EPolicies.FreeForAll,
|
|
111
|
+
contract: mockContract,
|
|
112
|
+
args: [await mockContract.getAddress()],
|
|
113
|
+
network: chain,
|
|
89
114
|
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
expect(policyData.abi).toBeDefined();
|
|
97
|
-
expect(policyData.bytecode).toBeDefined();
|
|
115
|
+
expect(mockStorage.register).toHaveBeenNthCalledWith(2, {
|
|
116
|
+
id: ECheckers.FreeForAll,
|
|
117
|
+
name: ECheckers.FreeForAll,
|
|
118
|
+
contract: mockContract,
|
|
119
|
+
args: [],
|
|
120
|
+
network: chain,
|
|
98
121
|
});
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
args: [zeroAddress, zeroPadBytes("0x", 32), zeroAddress],
|
|
105
|
-
});
|
|
106
|
-
const policyData = deployerService.getPolicyData(EPolicies.EAS, chain, {
|
|
107
|
-
easAddress: zeroAddress,
|
|
108
|
-
schema: zeroPadBytes("0x", 32),
|
|
109
|
-
attester: zeroAddress,
|
|
110
|
-
});
|
|
111
|
-
expect(policyData).toBeDefined();
|
|
112
|
-
expect(policyData.alreadyDeployed).toBe(true);
|
|
113
|
-
expect(policyData.abi).toBeDefined();
|
|
114
|
-
expect(policyData.bytecode).toBeDefined();
|
|
122
|
+
expect(mockStorage.register).toHaveBeenNthCalledWith(3, {
|
|
123
|
+
id: EPolicyFactories.FreeForAll,
|
|
124
|
+
name: EPolicyFactories.FreeForAll,
|
|
125
|
+
contract: mockContract,
|
|
126
|
+
network: chain,
|
|
115
127
|
});
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
args: [zeroAddress, zeroPadBytes("0x", 32), zeroAddress.replace("0x0", "0x1")],
|
|
122
|
-
});
|
|
123
|
-
const policyData = deployerService.getPolicyData(EPolicies.EAS, chain, {
|
|
124
|
-
easAddress: zeroAddress,
|
|
125
|
-
schema: zeroPadBytes("0x", 32),
|
|
126
|
-
attester: zeroAddress,
|
|
127
|
-
});
|
|
128
|
-
expect(policyData).toBeDefined();
|
|
129
|
-
expect(policyData.alreadyDeployed).toBe(false);
|
|
130
|
-
expect(policyData.abi).toBeDefined();
|
|
131
|
-
expect(policyData.bytecode).toBeDefined();
|
|
128
|
+
expect(mockStorage.register).toHaveBeenNthCalledWith(4, {
|
|
129
|
+
id: ECheckerFactories.FreeForAll,
|
|
130
|
+
name: ECheckerFactories.FreeForAll,
|
|
131
|
+
contract: mockContract,
|
|
132
|
+
network: chain,
|
|
132
133
|
});
|
|
133
134
|
});
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
signer2: zeroAddress,
|
|
139
|
-
eventId: "0x",
|
|
140
|
-
zupassVerifier: zeroAddress,
|
|
141
|
-
});
|
|
142
|
-
expect(policyData).toBeDefined();
|
|
143
|
-
expect(policyData.alreadyDeployed).toBe(false);
|
|
144
|
-
expect(policyData.abi).toBeDefined();
|
|
145
|
-
expect(policyData.bytecode).toBeDefined();
|
|
135
|
+
test("should reuse policy factories if already stored", async () => {
|
|
136
|
+
getDeployedPolicyProxyFactories.mockResolvedValue({
|
|
137
|
+
checker: mockContract,
|
|
138
|
+
policy: mockContract,
|
|
146
139
|
});
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
network: chain,
|
|
152
|
-
args: [zeroAddress, zeroAddress, "0x", zeroAddress],
|
|
153
|
-
});
|
|
154
|
-
const policyData = deployerService.getPolicyData(EPolicies.Zupass, chain, {
|
|
155
|
-
signer1: zeroAddress,
|
|
156
|
-
signer2: zeroAddress,
|
|
157
|
-
eventId: "0x",
|
|
158
|
-
zupassVerifier: zeroAddress,
|
|
159
|
-
});
|
|
160
|
-
expect(policyData).toBeDefined();
|
|
161
|
-
expect(policyData.alreadyDeployed).toBe(true);
|
|
162
|
-
expect(policyData.abi).toBeDefined();
|
|
163
|
-
expect(policyData.bytecode).toBeDefined();
|
|
140
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
141
|
+
await deployerService.deployAndSavePolicy(signer, chain, {
|
|
142
|
+
policyType: EPolicies.FreeForAll,
|
|
143
|
+
checkerType: ECheckers.FreeForAll,
|
|
164
144
|
});
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
contract: new BaseContract("0x", ZupassPolicyFactory.abi),
|
|
169
|
-
network: chain,
|
|
170
|
-
args: [zeroAddress, zeroAddress, "0x", zeroAddress.replace("0x0", "0x1")],
|
|
171
|
-
});
|
|
172
|
-
const policyData = deployerService.getPolicyData(EPolicies.Zupass, chain, {
|
|
173
|
-
signer1: zeroAddress,
|
|
174
|
-
signer2: zeroAddress,
|
|
175
|
-
eventId: "0x",
|
|
176
|
-
zupassVerifier: zeroAddress,
|
|
177
|
-
});
|
|
178
|
-
expect(policyData).toBeDefined();
|
|
179
|
-
expect(policyData.alreadyDeployed).toBe(false);
|
|
180
|
-
expect(policyData.abi).toBeDefined();
|
|
181
|
-
expect(policyData.bytecode).toBeDefined();
|
|
145
|
+
await deployerService.deployAndSavePolicy(signer, chain, {
|
|
146
|
+
policyType: EPolicies.FreeForAll,
|
|
147
|
+
checkerType: ECheckers.FreeForAll,
|
|
182
148
|
});
|
|
149
|
+
expect(mockStorage.register).toHaveBeenCalledTimes(4);
|
|
183
150
|
});
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
});
|
|
190
|
-
expect(policyData).toBeDefined();
|
|
191
|
-
expect(policyData.alreadyDeployed).toBe(false);
|
|
192
|
-
expect(policyData.abi).toBeDefined();
|
|
193
|
-
expect(policyData.bytecode).toBeDefined();
|
|
194
|
-
});
|
|
195
|
-
it("should return the policy data and that the policy is already deployed", async () => {
|
|
196
|
-
await storageInstance.register({
|
|
197
|
-
id: EPolicies.Semaphore,
|
|
198
|
-
contract: new BaseContract("0x", SemaphorePolicyFactory.abi),
|
|
199
|
-
network: chain,
|
|
200
|
-
args: [zeroAddress, "0"],
|
|
201
|
-
});
|
|
202
|
-
const policyData = deployerService.getPolicyData(EPolicies.Semaphore, chain, {
|
|
203
|
-
semaphoreContract: zeroAddress,
|
|
204
|
-
groupId: "0",
|
|
205
|
-
});
|
|
206
|
-
expect(policyData).toBeDefined();
|
|
207
|
-
expect(policyData.alreadyDeployed).toBe(true);
|
|
208
|
-
expect(policyData.abi).toBeDefined();
|
|
209
|
-
expect(policyData.bytecode).toBeDefined();
|
|
210
|
-
});
|
|
211
|
-
it("should return that the policy is not deployed when the args are different", async () => {
|
|
212
|
-
await storageInstance.register({
|
|
213
|
-
id: EPolicies.Semaphore,
|
|
214
|
-
contract: new BaseContract("0x", SemaphorePolicyFactory.abi),
|
|
215
|
-
network: chain,
|
|
216
|
-
args: [zeroAddress, "0"],
|
|
217
|
-
});
|
|
218
|
-
const policyData = deployerService.getPolicyData(EPolicies.Semaphore, chain, {
|
|
219
|
-
semaphoreContract: zeroAddress,
|
|
220
|
-
groupId: "1",
|
|
221
|
-
});
|
|
222
|
-
expect(policyData).toBeDefined();
|
|
223
|
-
expect(policyData.alreadyDeployed).toBe(false);
|
|
224
|
-
expect(policyData.abi).toBeDefined();
|
|
225
|
-
expect(policyData.bytecode).toBeDefined();
|
|
226
|
-
});
|
|
151
|
+
});
|
|
152
|
+
describe("deployAndSaveVoiceCreditProxyFactory", () => {
|
|
153
|
+
test("should throw when the voice credit proxy factory is not existent", async () => {
|
|
154
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
155
|
+
await expect(deployerService.deployAndSaveVoiceCreditProxyFactory(signer, "NonExistent", chain)).rejects.toThrow(ErrorCodes.UNSUPPORTED_VOICE_CREDIT_PROXY_FACTORY.toString());
|
|
227
156
|
});
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
});
|
|
234
|
-
expect(policyData).toBeDefined();
|
|
235
|
-
expect(policyData.alreadyDeployed).toBe(false);
|
|
236
|
-
expect(policyData.abi).toBeDefined();
|
|
237
|
-
expect(policyData.bytecode).toBeDefined();
|
|
238
|
-
});
|
|
239
|
-
it("should return the policy data and that the policy is already deployed", async () => {
|
|
240
|
-
await storageInstance.register({
|
|
241
|
-
id: EPolicies.Hats,
|
|
242
|
-
contract: new BaseContract("0x", HatsPolicyFactory.abi),
|
|
243
|
-
network: chain,
|
|
244
|
-
args: [zeroAddress, [zeroAddress]],
|
|
245
|
-
});
|
|
246
|
-
const policyData = deployerService.getPolicyData(EPolicies.Hats, chain, {
|
|
247
|
-
hatsProtocolAddress: zeroAddress,
|
|
248
|
-
critrionHats: [zeroAddress],
|
|
249
|
-
});
|
|
250
|
-
expect(policyData).toBeDefined();
|
|
251
|
-
expect(policyData.alreadyDeployed).toBe(true);
|
|
252
|
-
expect(policyData.abi).toBeDefined();
|
|
253
|
-
expect(policyData.bytecode).toBeDefined();
|
|
254
|
-
});
|
|
255
|
-
it("should return that the policy is not deployed when the args are different", async () => {
|
|
256
|
-
await storageInstance.register({
|
|
257
|
-
id: EPolicies.Hats,
|
|
258
|
-
contract: new BaseContract("0x", HatsPolicyFactory.abi),
|
|
259
|
-
network: chain,
|
|
260
|
-
args: [zeroAddress, ["0x"]],
|
|
261
|
-
});
|
|
262
|
-
const policyData = deployerService.getPolicyData(EPolicies.Hats, chain, {
|
|
263
|
-
hatsProtocolAddress: zeroAddress,
|
|
264
|
-
critrionHats: ["0x1"],
|
|
265
|
-
});
|
|
266
|
-
expect(policyData).toBeDefined();
|
|
267
|
-
expect(policyData.alreadyDeployed).toBe(false);
|
|
268
|
-
expect(policyData.abi).toBeDefined();
|
|
269
|
-
expect(policyData.bytecode).toBeDefined();
|
|
270
|
-
});
|
|
157
|
+
test("should deploy voice credit proxy factory if none is stored", async () => {
|
|
158
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
159
|
+
const constantInitialVoiceCreditProxyFactory = await deployerService.deployAndSaveVoiceCreditProxyFactory(signer, EInitialVoiceCreditProxiesFactories.Constant, chain);
|
|
160
|
+
expect(constantInitialVoiceCreditProxyFactory).toBeDefined();
|
|
161
|
+
expect(await constantInitialVoiceCreditProxyFactory.getAddress()).not.toBe(zeroAddress);
|
|
271
162
|
});
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
id: EPolicies.GitcoinPassport,
|
|
286
|
-
contract: new BaseContract("0x", GitcoinPassportPolicyFactory.abi),
|
|
287
|
-
network: chain,
|
|
288
|
-
args: [zeroAddress, "0"],
|
|
289
|
-
});
|
|
290
|
-
const policyData = deployerService.getPolicyData(EPolicies.GitcoinPassport, chain, {
|
|
291
|
-
decoderAddress: zeroAddress,
|
|
292
|
-
passingScore: "0",
|
|
293
|
-
});
|
|
294
|
-
expect(policyData).toBeDefined();
|
|
295
|
-
expect(policyData.alreadyDeployed).toBe(true);
|
|
296
|
-
expect(policyData.abi).toBeDefined();
|
|
297
|
-
expect(policyData.bytecode).toBeDefined();
|
|
298
|
-
});
|
|
299
|
-
it("should return that the policy is not deployed when the args are different", async () => {
|
|
300
|
-
await storageInstance.register({
|
|
301
|
-
id: EPolicies.GitcoinPassport,
|
|
302
|
-
contract: new BaseContract("0x", GitcoinPassportPolicyFactory.abi),
|
|
303
|
-
network: chain,
|
|
304
|
-
args: [zeroAddress, "0"],
|
|
305
|
-
});
|
|
306
|
-
const policyData = deployerService.getPolicyData(EPolicies.GitcoinPassport, chain, {
|
|
307
|
-
decoderAddress: zeroAddress,
|
|
308
|
-
passingScore: "1",
|
|
309
|
-
});
|
|
310
|
-
expect(policyData).toBeDefined();
|
|
311
|
-
expect(policyData.alreadyDeployed).toBe(false);
|
|
312
|
-
expect(policyData.abi).toBeDefined();
|
|
313
|
-
expect(policyData.bytecode).toBeDefined();
|
|
314
|
-
});
|
|
163
|
+
});
|
|
164
|
+
describe("deployAndSaveVoiceCreditProxy", () => {
|
|
165
|
+
test("should throw when the voice credit proxy is not existent", async () => {
|
|
166
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
167
|
+
const constantInitialVoiceCreditProxyFactory = await deployerService.deployAndSaveVoiceCreditProxyFactory(signer, EInitialVoiceCreditProxiesFactories.Constant, chain);
|
|
168
|
+
await expect(deployerService.deployAndSaveVoiceCreditProxy(signer, "NonExistent", chain, constantInitialVoiceCreditProxyFactory)).rejects.toThrow(ErrorCodes.UNSUPPORTED_VOICE_CREDIT_PROXY.toString());
|
|
169
|
+
});
|
|
170
|
+
test("should deploy voice credit proxy if none is stored", async () => {
|
|
171
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
172
|
+
const constantInitialVoiceCreditProxyFactory = await deployerService.deployAndSaveVoiceCreditProxyFactory(signer, EInitialVoiceCreditProxiesFactories.Constant, chain);
|
|
173
|
+
const voiceCreditProxy = await deployerService.deployAndSaveVoiceCreditProxy(signer, EInitialVoiceCreditProxies.Constant, chain, constantInitialVoiceCreditProxyFactory, { amount: 100 });
|
|
174
|
+
expect(voiceCreditProxy).toBeDefined();
|
|
175
|
+
expect(await voiceCreditProxy.getAddress()).not.toBe(zeroAddress);
|
|
315
176
|
});
|
|
316
177
|
});
|
|
317
178
|
describe("deployMaci", () => {
|
|
318
179
|
test("should throw when passing a non existent session key address", async () => {
|
|
180
|
+
sessionKeyService.getCoordinatorSigner = jest
|
|
181
|
+
.fn()
|
|
182
|
+
.mockRejectedValue(new Error(ErrorCodes.SESSION_KEY_NOT_FOUND.toString()));
|
|
183
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
319
184
|
await expect(deployerService.deployMaci({
|
|
320
185
|
config: testMaciDeploymentConfig,
|
|
321
186
|
chain,
|
|
@@ -324,44 +189,37 @@ describe("DeployerService", () => {
|
|
|
324
189
|
})).rejects.toThrow(ErrorCodes.SESSION_KEY_NOT_FOUND.toString());
|
|
325
190
|
});
|
|
326
191
|
test("should throw when the approval is not valid", async () => {
|
|
192
|
+
sessionKeyService.getCoordinatorSigner = jest
|
|
193
|
+
.fn()
|
|
194
|
+
.mockRejectedValue(new Error(ErrorCodes.INVALID_APPROVAL.toString()));
|
|
195
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
327
196
|
await expect(deployerService.deployMaci({
|
|
328
197
|
config: testMaciDeploymentConfig,
|
|
329
198
|
chain,
|
|
330
|
-
approval: "
|
|
199
|
+
approval: "0x123",
|
|
331
200
|
sessionKeyAddress,
|
|
332
201
|
})).rejects.toThrow(ErrorCodes.INVALID_APPROVAL.toString());
|
|
333
202
|
});
|
|
334
203
|
test("should deploy all new contracts", async () => {
|
|
335
|
-
const
|
|
336
|
-
jest.spyOn(DeployerService.prototype, "deployMaci").mockImplementation(mockDeployMaci);
|
|
204
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
337
205
|
const { address: maciAddress } = await deployerService.deployMaci({
|
|
338
206
|
config: testMaciDeploymentConfig,
|
|
339
207
|
chain,
|
|
340
208
|
approval,
|
|
341
209
|
sessionKeyAddress,
|
|
342
210
|
});
|
|
343
|
-
expect(maciAddress).toBe(zeroAddress);
|
|
211
|
+
expect(maciAddress).toBe(zeroAddress.replace("0x0", "0x1"));
|
|
344
212
|
});
|
|
345
213
|
});
|
|
346
214
|
describe("deployPoll", () => {
|
|
347
|
-
afterEach(() => {
|
|
348
|
-
storageInstance.cleanup(chain);
|
|
349
|
-
});
|
|
350
215
|
test("should throw when there is no maci contract deployed", async () => {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
})).rejects.toThrow(ErrorCodes.MACI_NOT_DEPLOYED.toString());
|
|
357
|
-
});
|
|
358
|
-
test("should throw when there is no maci contract deployed to this specific chain", async () => {
|
|
359
|
-
await storageInstance.register({
|
|
360
|
-
id: EContracts.MACI,
|
|
361
|
-
contract: new BaseContract("0x", MACIFactory.abi),
|
|
362
|
-
network: ESupportedNetworks.ARBITRUM_ONE,
|
|
363
|
-
args: [],
|
|
216
|
+
ContractStorage.getInstance.mockReturnValue({
|
|
217
|
+
...mockStorage,
|
|
218
|
+
getAddress: jest
|
|
219
|
+
.fn()
|
|
220
|
+
.mockImplementation((key) => (key !== EContracts.MACI ? zeroAddress : undefined)),
|
|
364
221
|
});
|
|
222
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
365
223
|
await expect(deployerService.deployPoll({
|
|
366
224
|
approval,
|
|
367
225
|
sessionKeyAddress,
|
|
@@ -369,13 +227,14 @@ describe("DeployerService", () => {
|
|
|
369
227
|
config: testPollDeploymentConfig,
|
|
370
228
|
})).rejects.toThrow(ErrorCodes.MACI_NOT_DEPLOYED.toString());
|
|
371
229
|
});
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
230
|
+
test("should throw when there is no verifier deployed", async () => {
|
|
231
|
+
ContractStorage.getInstance.mockReturnValue({
|
|
232
|
+
...mockStorage,
|
|
233
|
+
getAddress: jest
|
|
234
|
+
.fn()
|
|
235
|
+
.mockImplementation((key) => (key !== EContracts.Verifier ? zeroAddress : undefined)),
|
|
378
236
|
});
|
|
237
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
379
238
|
await expect(deployerService.deployPoll({
|
|
380
239
|
approval,
|
|
381
240
|
sessionKeyAddress,
|
|
@@ -383,29 +242,23 @@ describe("DeployerService", () => {
|
|
|
383
242
|
config: testPollDeploymentConfig,
|
|
384
243
|
})).rejects.toThrow(ErrorCodes.VERIFIER_NOT_DEPLOYED.toString());
|
|
385
244
|
});
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
});
|
|
393
|
-
await storageInstance.register({
|
|
394
|
-
id: EContracts.Verifier,
|
|
395
|
-
contract: new BaseContract("0x", VerifierFactory.abi),
|
|
396
|
-
network: chain,
|
|
397
|
-
args: [],
|
|
245
|
+
test("should throw when there is no verifying keys registry deployed", async () => {
|
|
246
|
+
ContractStorage.getInstance.mockReturnValue({
|
|
247
|
+
...mockStorage,
|
|
248
|
+
getAddress: jest
|
|
249
|
+
.fn()
|
|
250
|
+
.mockImplementation((key) => key !== EContracts.VerifyingKeysRegistry ? zeroAddress : undefined),
|
|
398
251
|
});
|
|
252
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
399
253
|
await expect(deployerService.deployPoll({
|
|
400
254
|
approval,
|
|
401
255
|
sessionKeyAddress,
|
|
402
256
|
chain,
|
|
403
257
|
config: testPollDeploymentConfig,
|
|
404
|
-
})).rejects.toThrow(ErrorCodes.
|
|
258
|
+
})).rejects.toThrow(ErrorCodes.VERIFYING_KEYS_REGISTRY_NOT_DEPLOYED.toString());
|
|
405
259
|
});
|
|
406
260
|
test("should deploy a poll", async () => {
|
|
407
|
-
const
|
|
408
|
-
jest.spyOn(DeployerService.prototype, "deployPoll").mockImplementation(mockDeployPoll);
|
|
261
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
409
262
|
const { pollId } = await deployerService.deployPoll({
|
|
410
263
|
config: testPollDeploymentConfig,
|
|
411
264
|
chain,
|
|
@@ -415,11 +268,5 @@ describe("DeployerService", () => {
|
|
|
415
268
|
expect(pollId).toBe("0");
|
|
416
269
|
});
|
|
417
270
|
});
|
|
418
|
-
describe("estimateExtraGasLimit", () => {
|
|
419
|
-
it("should return the extra gas limit", () => {
|
|
420
|
-
const extraGasLimit = estimateExtraGasLimit(100n);
|
|
421
|
-
expect(extraGasLimit.toString()).toBe("5");
|
|
422
|
-
});
|
|
423
|
-
});
|
|
424
271
|
});
|
|
425
272
|
//# sourceMappingURL=deployer.service.test.js.map
|