@maci-protocol/coordinator 0.0.0-ci.a577366 → 0.0.0-ci.a73cfa9
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 +9 -3
- package/build/hardhat.config.cjs.map +1 -1
- package/build/hardhat.config.d.cts +9 -4
- 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 +182 -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 +47 -16
- 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 +343 -468
- 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 +83 -46
- 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/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 +45 -38
- 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,184 @@
|
|
|
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
|
+
});
|
|
77
|
+
getDeployedPolicyProxyFactories.mockResolvedValue({ checker: undefined, policy: undefined });
|
|
78
|
+
});
|
|
15
79
|
afterEach(() => {
|
|
16
80
|
jest.clearAllMocks();
|
|
17
81
|
});
|
|
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();
|
|
82
|
+
describe("deployAndSavePolicy", () => {
|
|
83
|
+
test("should throw when the policy is not existent", async () => {
|
|
84
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
85
|
+
await expect(deployerService.deployAndSavePolicy(signer, chain, {
|
|
86
|
+
policyType: "NonExistent",
|
|
87
|
+
checkerType: "NonExistent",
|
|
88
|
+
})).rejects.toThrow(ErrorCodes.UNSUPPORTED_POLICY.toString());
|
|
38
89
|
});
|
|
39
|
-
test("should
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
args: ["50"],
|
|
90
|
+
test("should deploy policy if none is stored", async () => {
|
|
91
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
92
|
+
const policy = await deployerService.deployAndSavePolicy(signer, chain, {
|
|
93
|
+
policyType: EPolicies.FreeForAll,
|
|
94
|
+
checkerType: ECheckers.FreeForAll,
|
|
45
95
|
});
|
|
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());
|
|
96
|
+
expect(policy).toBeDefined();
|
|
97
|
+
expect(await policy.getAddress()).not.toBe(zeroAddress);
|
|
68
98
|
});
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
expect(policyData.abi).toBeDefined();
|
|
75
|
-
expect(policyData.bytecode).toBeDefined();
|
|
99
|
+
test("should save factories (policy and checker) after deploying policy", async () => {
|
|
100
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
101
|
+
await deployerService.deployAndSavePolicy(signer, chain, {
|
|
102
|
+
policyType: EPolicies.FreeForAll,
|
|
103
|
+
checkerType: ECheckers.FreeForAll,
|
|
76
104
|
});
|
|
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();
|
|
105
|
+
expect(mockStorage.register).toHaveBeenCalledTimes(4);
|
|
106
|
+
expect(mockStorage.register).toHaveBeenNthCalledWith(1, {
|
|
107
|
+
id: EPolicies.FreeForAll,
|
|
108
|
+
name: EPolicies.FreeForAll,
|
|
109
|
+
contract: mockContract,
|
|
110
|
+
args: [await mockContract.getAddress()],
|
|
111
|
+
network: chain,
|
|
89
112
|
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
expect(policyData.abi).toBeDefined();
|
|
97
|
-
expect(policyData.bytecode).toBeDefined();
|
|
113
|
+
expect(mockStorage.register).toHaveBeenNthCalledWith(2, {
|
|
114
|
+
id: ECheckers.FreeForAll,
|
|
115
|
+
name: ECheckers.FreeForAll,
|
|
116
|
+
contract: mockContract,
|
|
117
|
+
args: [],
|
|
118
|
+
network: chain,
|
|
98
119
|
});
|
|
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();
|
|
120
|
+
expect(mockStorage.register).toHaveBeenNthCalledWith(3, {
|
|
121
|
+
id: EPolicyFactories.FreeForAll,
|
|
122
|
+
name: EPolicyFactories.FreeForAll,
|
|
123
|
+
contract: mockContract,
|
|
124
|
+
network: chain,
|
|
115
125
|
});
|
|
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();
|
|
126
|
+
expect(mockStorage.register).toHaveBeenNthCalledWith(4, {
|
|
127
|
+
id: ECheckerFactories.FreeForAll,
|
|
128
|
+
name: ECheckerFactories.FreeForAll,
|
|
129
|
+
contract: mockContract,
|
|
130
|
+
network: chain,
|
|
132
131
|
});
|
|
133
132
|
});
|
|
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();
|
|
133
|
+
test("should reuse policy factories if already stored", async () => {
|
|
134
|
+
getDeployedPolicyProxyFactories.mockResolvedValue({
|
|
135
|
+
checker: mockContract,
|
|
136
|
+
policy: mockContract,
|
|
146
137
|
});
|
|
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();
|
|
138
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
139
|
+
await deployerService.deployAndSavePolicy(signer, chain, {
|
|
140
|
+
policyType: EPolicies.FreeForAll,
|
|
141
|
+
checkerType: ECheckers.FreeForAll,
|
|
164
142
|
});
|
|
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();
|
|
143
|
+
await deployerService.deployAndSavePolicy(signer, chain, {
|
|
144
|
+
policyType: EPolicies.FreeForAll,
|
|
145
|
+
checkerType: ECheckers.FreeForAll,
|
|
182
146
|
});
|
|
147
|
+
expect(mockStorage.register).toHaveBeenCalledTimes(4);
|
|
183
148
|
});
|
|
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
|
-
});
|
|
149
|
+
});
|
|
150
|
+
describe("deployAndSaveVoiceCreditProxyFactory", () => {
|
|
151
|
+
test("should throw when the voice credit proxy factory is not existent", async () => {
|
|
152
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
153
|
+
await expect(deployerService.deployAndSaveVoiceCreditProxyFactory(signer, "NonExistent", chain)).rejects.toThrow(ErrorCodes.UNSUPPORTED_VOICE_CREDIT_PROXY_FACTORY.toString());
|
|
227
154
|
});
|
|
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
|
-
});
|
|
155
|
+
test("should deploy voice credit proxy factory if none is stored", async () => {
|
|
156
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
157
|
+
const constantInitialVoiceCreditProxyFactory = await deployerService.deployAndSaveVoiceCreditProxyFactory(signer, EInitialVoiceCreditProxiesFactories.Constant, chain);
|
|
158
|
+
expect(constantInitialVoiceCreditProxyFactory).toBeDefined();
|
|
159
|
+
expect(await constantInitialVoiceCreditProxyFactory.getAddress()).not.toBe(zeroAddress);
|
|
271
160
|
});
|
|
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
|
-
});
|
|
161
|
+
});
|
|
162
|
+
describe("deployAndSaveVoiceCreditProxy", () => {
|
|
163
|
+
test("should throw when the voice credit proxy is not existent", async () => {
|
|
164
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
165
|
+
const constantInitialVoiceCreditProxyFactory = await deployerService.deployAndSaveVoiceCreditProxyFactory(signer, EInitialVoiceCreditProxiesFactories.Constant, chain);
|
|
166
|
+
await expect(deployerService.deployAndSaveVoiceCreditProxy(signer, "NonExistent", chain, constantInitialVoiceCreditProxyFactory)).rejects.toThrow(ErrorCodes.UNSUPPORTED_VOICE_CREDIT_PROXY.toString());
|
|
167
|
+
});
|
|
168
|
+
test("should deploy voice credit proxy if none is stored", async () => {
|
|
169
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
170
|
+
const constantInitialVoiceCreditProxyFactory = await deployerService.deployAndSaveVoiceCreditProxyFactory(signer, EInitialVoiceCreditProxiesFactories.Constant, chain);
|
|
171
|
+
const voiceCreditProxy = await deployerService.deployAndSaveVoiceCreditProxy(signer, EInitialVoiceCreditProxies.Constant, chain, constantInitialVoiceCreditProxyFactory, { amount: 100 });
|
|
172
|
+
expect(voiceCreditProxy).toBeDefined();
|
|
173
|
+
expect(await voiceCreditProxy.getAddress()).not.toBe(zeroAddress);
|
|
315
174
|
});
|
|
316
175
|
});
|
|
317
176
|
describe("deployMaci", () => {
|
|
318
177
|
test("should throw when passing a non existent session key address", async () => {
|
|
178
|
+
sessionKeyService.getCoordinatorSigner = jest
|
|
179
|
+
.fn()
|
|
180
|
+
.mockRejectedValue(new Error(ErrorCodes.SESSION_KEY_NOT_FOUND.toString()));
|
|
181
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
319
182
|
await expect(deployerService.deployMaci({
|
|
320
183
|
config: testMaciDeploymentConfig,
|
|
321
184
|
chain,
|
|
@@ -324,44 +187,37 @@ describe("DeployerService", () => {
|
|
|
324
187
|
})).rejects.toThrow(ErrorCodes.SESSION_KEY_NOT_FOUND.toString());
|
|
325
188
|
});
|
|
326
189
|
test("should throw when the approval is not valid", async () => {
|
|
190
|
+
sessionKeyService.getCoordinatorSigner = jest
|
|
191
|
+
.fn()
|
|
192
|
+
.mockRejectedValue(new Error(ErrorCodes.INVALID_APPROVAL.toString()));
|
|
193
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
327
194
|
await expect(deployerService.deployMaci({
|
|
328
195
|
config: testMaciDeploymentConfig,
|
|
329
196
|
chain,
|
|
330
|
-
approval: "
|
|
197
|
+
approval: "0x123",
|
|
331
198
|
sessionKeyAddress,
|
|
332
199
|
})).rejects.toThrow(ErrorCodes.INVALID_APPROVAL.toString());
|
|
333
200
|
});
|
|
334
201
|
test("should deploy all new contracts", async () => {
|
|
335
|
-
const
|
|
336
|
-
jest.spyOn(DeployerService.prototype, "deployMaci").mockImplementation(mockDeployMaci);
|
|
202
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
337
203
|
const { address: maciAddress } = await deployerService.deployMaci({
|
|
338
204
|
config: testMaciDeploymentConfig,
|
|
339
205
|
chain,
|
|
340
206
|
approval,
|
|
341
207
|
sessionKeyAddress,
|
|
342
208
|
});
|
|
343
|
-
expect(maciAddress).toBe(zeroAddress);
|
|
209
|
+
expect(maciAddress).toBe(zeroAddress.replace("0x0", "0x1"));
|
|
344
210
|
});
|
|
345
211
|
});
|
|
346
212
|
describe("deployPoll", () => {
|
|
347
|
-
afterEach(() => {
|
|
348
|
-
storageInstance.cleanup(chain);
|
|
349
|
-
});
|
|
350
213
|
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: [],
|
|
214
|
+
ContractStorage.getInstance.mockReturnValue({
|
|
215
|
+
...mockStorage,
|
|
216
|
+
getAddress: jest
|
|
217
|
+
.fn()
|
|
218
|
+
.mockImplementation((key) => (key !== EContracts.MACI ? zeroAddress : undefined)),
|
|
364
219
|
});
|
|
220
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
365
221
|
await expect(deployerService.deployPoll({
|
|
366
222
|
approval,
|
|
367
223
|
sessionKeyAddress,
|
|
@@ -369,13 +225,14 @@ describe("DeployerService", () => {
|
|
|
369
225
|
config: testPollDeploymentConfig,
|
|
370
226
|
})).rejects.toThrow(ErrorCodes.MACI_NOT_DEPLOYED.toString());
|
|
371
227
|
});
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
228
|
+
test("should throw when there is no verifier deployed", async () => {
|
|
229
|
+
ContractStorage.getInstance.mockReturnValue({
|
|
230
|
+
...mockStorage,
|
|
231
|
+
getAddress: jest
|
|
232
|
+
.fn()
|
|
233
|
+
.mockImplementation((key) => (key !== EContracts.Verifier ? zeroAddress : undefined)),
|
|
378
234
|
});
|
|
235
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
379
236
|
await expect(deployerService.deployPoll({
|
|
380
237
|
approval,
|
|
381
238
|
sessionKeyAddress,
|
|
@@ -383,29 +240,23 @@ describe("DeployerService", () => {
|
|
|
383
240
|
config: testPollDeploymentConfig,
|
|
384
241
|
})).rejects.toThrow(ErrorCodes.VERIFIER_NOT_DEPLOYED.toString());
|
|
385
242
|
});
|
|
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: [],
|
|
243
|
+
test("should throw when there is no verifying keys registry deployed", async () => {
|
|
244
|
+
ContractStorage.getInstance.mockReturnValue({
|
|
245
|
+
...mockStorage,
|
|
246
|
+
getAddress: jest
|
|
247
|
+
.fn()
|
|
248
|
+
.mockImplementation((key) => key !== EContracts.VerifyingKeysRegistry ? zeroAddress : undefined),
|
|
398
249
|
});
|
|
250
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
399
251
|
await expect(deployerService.deployPoll({
|
|
400
252
|
approval,
|
|
401
253
|
sessionKeyAddress,
|
|
402
254
|
chain,
|
|
403
255
|
config: testPollDeploymentConfig,
|
|
404
|
-
})).rejects.toThrow(ErrorCodes.
|
|
256
|
+
})).rejects.toThrow(ErrorCodes.VERIFYING_KEYS_REGISTRY_NOT_DEPLOYED.toString());
|
|
405
257
|
});
|
|
406
258
|
test("should deploy a poll", async () => {
|
|
407
|
-
const
|
|
408
|
-
jest.spyOn(DeployerService.prototype, "deployPoll").mockImplementation(mockDeployPoll);
|
|
259
|
+
const deployerService = new DeployerService(sessionKeyService, fileService);
|
|
409
260
|
const { pollId } = await deployerService.deployPoll({
|
|
410
261
|
config: testPollDeploymentConfig,
|
|
411
262
|
chain,
|
|
@@ -415,11 +266,5 @@ describe("DeployerService", () => {
|
|
|
415
266
|
expect(pollId).toBe("0");
|
|
416
267
|
});
|
|
417
268
|
});
|
|
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
269
|
});
|
|
425
270
|
//# sourceMappingURL=deployer.service.test.js.map
|