@maci-protocol/testing 0.0.0-ci.cf26211 → 0.0.0-ci.cf2cc5b
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/build/hardhat.config.js +1 -1
- package/build/hardhat.config.js.map +1 -1
- package/build/ts/__tests__/e2e.full.test.d.ts +2 -0
- package/build/ts/__tests__/e2e.full.test.d.ts.map +1 -0
- package/build/ts/__tests__/e2e.full.test.js +842 -0
- package/build/ts/__tests__/e2e.full.test.js.map +1 -0
- package/build/ts/__tests__/e2e.nonQv.test.js +442 -42
- package/build/ts/__tests__/e2e.nonQv.test.js.map +1 -1
- package/build/ts/__tests__/e2e.test.js +337 -326
- package/build/ts/__tests__/e2e.test.js.map +1 -1
- package/build/ts/__tests__/integration.test.js +73 -75
- package/build/ts/__tests__/integration.test.js.map +1 -1
- package/build/ts/__tests__/keyChange.test.js +88 -86
- package/build/ts/__tests__/keyChange.test.js.map +1 -1
- package/build/ts/__tests__/maciKeys.test.js +41 -41
- package/build/ts/__tests__/maciKeys.test.js.map +1 -1
- package/build/ts/__tests__/stress/stress.full.test.d.ts +2 -0
- package/build/ts/__tests__/stress/stress.full.test.d.ts.map +1 -0
- package/build/ts/__tests__/stress/stress.full.test.js +189 -0
- package/build/ts/__tests__/stress/stress.full.test.js.map +1 -0
- package/build/ts/__tests__/unit/joinPoll.test.js +75 -37
- package/build/ts/__tests__/unit/joinPoll.test.js.map +1 -1
- package/build/ts/__tests__/unit/poll.test.js +9 -11
- package/build/ts/__tests__/unit/poll.test.js.map +1 -1
- package/build/ts/__tests__/unit/publish.test.js +12 -14
- package/build/ts/__tests__/unit/publish.test.js.map +1 -1
- package/build/ts/__tests__/unit/setVerifyingKeys.test.d.ts +2 -0
- package/build/ts/__tests__/unit/setVerifyingKeys.test.d.ts.map +1 -0
- package/build/ts/__tests__/unit/setVerifyingKeys.test.js +52 -0
- package/build/ts/__tests__/unit/setVerifyingKeys.test.js.map +1 -0
- package/build/ts/__tests__/unit/signup.test.js +11 -9
- package/build/ts/__tests__/unit/signup.test.js.map +1 -1
- package/build/ts/__tests__/unit/utils.test.js +12 -12
- package/build/ts/__tests__/unit/utils.test.js.map +1 -1
- package/build/ts/constants.d.ts +53 -55
- package/build/ts/constants.d.ts.map +1 -1
- package/build/ts/constants.js +113 -74
- package/build/ts/constants.js.map +1 -1
- package/build/ts/testingClass.d.ts +9 -9
- package/build/ts/testingClass.d.ts.map +1 -1
- package/build/ts/testingClass.js +39 -38
- package/build/ts/testingClass.js.map +1 -1
- package/build/ts/types.d.ts +12 -13
- package/build/ts/types.d.ts.map +1 -1
- package/build/ts/user.d.ts +2 -2
- package/build/ts/user.d.ts.map +1 -1
- package/build/ts/user.js +1 -1
- package/build/ts/user.js.map +1 -1
- package/build/ts/utils.d.ts +3 -3
- package/build/ts/utils.d.ts.map +1 -1
- package/build/ts/utils.js +12 -12
- package/build/ts/utils.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +20 -18
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const contracts_1 = require("@maci-protocol/contracts");
|
|
6
7
|
const core_1 = require("@maci-protocol/core");
|
|
7
8
|
const crypto_1 = require("@maci-protocol/crypto");
|
|
8
9
|
const domainobjs_1 = require("@maci-protocol/domainobjs");
|
|
@@ -27,38 +28,33 @@ describe("e2e tests", function test() {
|
|
|
27
28
|
const useWasm = (0, sdk_1.isArm)();
|
|
28
29
|
this.timeout(900000);
|
|
29
30
|
let maciAddresses;
|
|
30
|
-
let vkRegistryAddress;
|
|
31
31
|
let initialVoiceCreditProxyContractAddress;
|
|
32
|
-
let verifierContractAddress;
|
|
33
32
|
let signer;
|
|
33
|
+
let userSigners;
|
|
34
34
|
const generateProofsArgs = {
|
|
35
35
|
outputDir: constants_1.testProofsDirPath,
|
|
36
36
|
tallyFile: constants_1.testTallyFilePath,
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
voteTallyZkey: constants_1.testTallyVotesZkeyPath,
|
|
38
|
+
messageProcessorZkey: constants_1.testProcessMessageZkeyPath,
|
|
39
39
|
pollId: 0n,
|
|
40
40
|
rapidsnark: constants_1.testRapidsnarkPath,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
coordinatorPrivateKey: constants_1.
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
messageProcessorWitnessGenerator: constants_1.testProcessMessagesWitnessPath,
|
|
42
|
+
messageProcessorWitnessDatFile: constants_1.testProcessMessagesWitnessDatPath,
|
|
43
|
+
voteTallyWitnessGenerator: constants_1.testTallyVotesWitnessPath,
|
|
44
|
+
voteTallyWitnessDatFile: constants_1.testTallyVotesWitnessDatPath,
|
|
45
|
+
coordinatorPrivateKey: constants_1.coordinatorPrivateKey,
|
|
46
|
+
messageProcessorWasm: constants_1.testProcessMessagesWasmPath,
|
|
47
|
+
voteTallyWasm: constants_1.testTallyVotesWasmPath,
|
|
48
48
|
useWasm,
|
|
49
|
-
|
|
49
|
+
mode: core_1.EMode.QV,
|
|
50
50
|
};
|
|
51
|
-
// before all tests we deploy the
|
|
51
|
+
// before all tests we deploy the verifying keys registry contract and set the verifying keys
|
|
52
52
|
before(async () => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const
|
|
53
|
+
const signers = await (0, contracts_1.getSigners)();
|
|
54
|
+
[signer, ...userSigners] = signers;
|
|
55
|
+
const constantInitialVoiceCreditProxyFactory = await (0, sdk_1.deployConstantInitialVoiceCreditProxyFactory)(signer, true);
|
|
56
|
+
const initialVoiceCreditProxy = await (0, sdk_1.deployConstantInitialVoiceCreditProxy)({ amount: constants_1.DEFAULT_INITIAL_VOICE_CREDITS }, constantInitialVoiceCreditProxyFactory, signer);
|
|
57
57
|
initialVoiceCreditProxyContractAddress = await initialVoiceCreditProxy.getAddress();
|
|
58
|
-
const verifier = await (0, sdk_1.deployVerifier)(signer, true);
|
|
59
|
-
verifierContractAddress = await verifier.getAddress();
|
|
60
|
-
// we set the verifying keys
|
|
61
|
-
await (0, sdk_1.setVerifyingKeys)({ ...(await (0, constants_1.verifyingKeysArgs)(signer)), vkRegistryAddress });
|
|
62
58
|
});
|
|
63
59
|
describe("2 signups (1 after stateAq is merged and logs are fetched), 1 message", () => {
|
|
64
60
|
after(async () => {
|
|
@@ -76,6 +72,12 @@ describe("e2e tests", function test() {
|
|
|
76
72
|
signer,
|
|
77
73
|
signupPolicyAddress: signupPolicyContractAddress,
|
|
78
74
|
});
|
|
75
|
+
// we set the verifying keys
|
|
76
|
+
const { verifyingKeysRegistryContractAddress } = maciAddresses;
|
|
77
|
+
await (0, sdk_1.setVerifyingKeys)({
|
|
78
|
+
...(await (0, constants_1.verifyingKeysArgs)(signer)),
|
|
79
|
+
verifyingKeysRegistryAddress: verifyingKeysRegistryContractAddress,
|
|
80
|
+
});
|
|
79
81
|
const startDate = await (0, sdk_1.getBlockTimestamp)(signer);
|
|
80
82
|
// deploy a poll contract
|
|
81
83
|
await (0, sdk_1.deployPoll)({
|
|
@@ -85,8 +87,6 @@ describe("e2e tests", function test() {
|
|
|
85
87
|
pollEndTimestamp: startDate + constants_1.pollDuration,
|
|
86
88
|
relayers: [await signer.getAddress()],
|
|
87
89
|
maciAddress: maciAddresses.maciContractAddress,
|
|
88
|
-
verifierContractAddress,
|
|
89
|
-
vkRegistryContractAddress: vkRegistryAddress,
|
|
90
90
|
policyContractAddress: pollPolicyContractAddress,
|
|
91
91
|
initialVoiceCreditProxyContractAddress,
|
|
92
92
|
});
|
|
@@ -94,38 +94,37 @@ describe("e2e tests", function test() {
|
|
|
94
94
|
it("should signup one user", async () => {
|
|
95
95
|
await (0, sdk_1.signup)({
|
|
96
96
|
maciAddress: maciAddresses.maciContractAddress,
|
|
97
|
-
|
|
97
|
+
maciPublicKey: user.publicKey.serialize(),
|
|
98
98
|
sgData: constants_1.DEFAULT_SG_DATA,
|
|
99
|
-
signer,
|
|
99
|
+
signer: userSigners[0],
|
|
100
100
|
});
|
|
101
101
|
});
|
|
102
102
|
it("should join one user", async () => {
|
|
103
103
|
await (0, sdk_1.joinPoll)({
|
|
104
104
|
maciAddress: maciAddresses.maciContractAddress,
|
|
105
|
-
privateKey: user.
|
|
106
|
-
stateIndex: 1n,
|
|
105
|
+
privateKey: user.privateKey.serialize(),
|
|
107
106
|
pollId: 0n,
|
|
108
|
-
pollJoiningZkey: constants_1.
|
|
109
|
-
useWasm
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
pollJoiningZkey: constants_1.testPollJoiningZkeyPath,
|
|
108
|
+
useWasm,
|
|
109
|
+
pollJoiningWasm: constants_1.testPollJoiningWasmPath,
|
|
110
|
+
pollWitnessGenerator: constants_1.testPollJoiningWitnessPath,
|
|
112
111
|
rapidsnark: constants_1.testRapidsnarkPath,
|
|
113
112
|
sgDataArg: constants_1.DEFAULT_SG_DATA,
|
|
114
113
|
ivcpDataArg: constants_1.DEFAULT_IVCP_DATA,
|
|
115
|
-
signer,
|
|
114
|
+
signer: userSigners[0],
|
|
116
115
|
});
|
|
117
116
|
});
|
|
118
117
|
it("should publish one message", async () => {
|
|
119
118
|
await (0, sdk_1.publish)({
|
|
120
|
-
|
|
119
|
+
publicKey: user.publicKey.serialize(),
|
|
121
120
|
stateIndex: 1n,
|
|
122
121
|
voteOptionIndex: 0n,
|
|
123
122
|
nonce: 1n,
|
|
124
123
|
pollId: 0n,
|
|
125
124
|
newVoteWeight: 9n,
|
|
126
125
|
maciAddress: maciAddresses.maciContractAddress,
|
|
127
|
-
salt: (0, crypto_1.
|
|
128
|
-
privateKey: user.
|
|
126
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
127
|
+
privateKey: user.privateKey.serialize(),
|
|
129
128
|
signer,
|
|
130
129
|
});
|
|
131
130
|
});
|
|
@@ -139,9 +138,9 @@ describe("e2e tests", function test() {
|
|
|
139
138
|
});
|
|
140
139
|
await (0, sdk_1.signup)({
|
|
141
140
|
maciAddress: maciAddresses.maciContractAddress,
|
|
142
|
-
|
|
141
|
+
maciPublicKey: new domainobjs_1.Keypair().publicKey.serialize(),
|
|
143
142
|
sgData: constants_1.DEFAULT_SG_DATA,
|
|
144
|
-
signer,
|
|
143
|
+
signer: userSigners[1],
|
|
145
144
|
});
|
|
146
145
|
await (0, sdk_1.proveOnChain)({ ...constants_1.proveOnChainArgs, maciAddress: maciAddresses.maciContractAddress, signer });
|
|
147
146
|
await (0, sdk_1.verify)({
|
|
@@ -167,6 +166,12 @@ describe("e2e tests", function test() {
|
|
|
167
166
|
signer,
|
|
168
167
|
signupPolicyAddress: signupPolicyContractAddress,
|
|
169
168
|
});
|
|
169
|
+
// we set the verifying keys
|
|
170
|
+
const { verifyingKeysRegistryContractAddress } = maciAddresses;
|
|
171
|
+
await (0, sdk_1.setVerifyingKeys)({
|
|
172
|
+
...(await (0, constants_1.verifyingKeysArgs)(signer)),
|
|
173
|
+
verifyingKeysRegistryAddress: verifyingKeysRegistryContractAddress,
|
|
174
|
+
});
|
|
170
175
|
const startDate = await (0, sdk_1.getBlockTimestamp)(signer);
|
|
171
176
|
// deploy a poll contract
|
|
172
177
|
await (0, sdk_1.deployPoll)({
|
|
@@ -176,8 +181,6 @@ describe("e2e tests", function test() {
|
|
|
176
181
|
pollEndTimestamp: startDate + constants_1.pollDuration,
|
|
177
182
|
relayers: [await signer.getAddress()],
|
|
178
183
|
maciAddress: maciAddresses.maciContractAddress,
|
|
179
|
-
verifierContractAddress,
|
|
180
|
-
vkRegistryContractAddress: vkRegistryAddress,
|
|
181
184
|
policyContractAddress: pollPolicyContractAddress,
|
|
182
185
|
initialVoiceCreditProxyContractAddress,
|
|
183
186
|
});
|
|
@@ -188,9 +191,9 @@ describe("e2e tests", function test() {
|
|
|
188
191
|
// eslint-disable-next-line no-await-in-loop
|
|
189
192
|
await (0, sdk_1.signup)({
|
|
190
193
|
maciAddress: maciAddresses.maciContractAddress,
|
|
191
|
-
|
|
194
|
+
maciPublicKey: users[i].publicKey.serialize(),
|
|
192
195
|
sgData: constants_1.DEFAULT_SG_DATA,
|
|
193
|
-
signer,
|
|
196
|
+
signer: userSigners[i],
|
|
194
197
|
});
|
|
195
198
|
}
|
|
196
199
|
});
|
|
@@ -200,115 +203,114 @@ describe("e2e tests", function test() {
|
|
|
200
203
|
// eslint-disable-next-line no-await-in-loop
|
|
201
204
|
await (0, sdk_1.joinPoll)({
|
|
202
205
|
maciAddress: maciAddresses.maciContractAddress,
|
|
203
|
-
privateKey: users[i].
|
|
204
|
-
stateIndex: BigInt(i + 1),
|
|
206
|
+
privateKey: users[i].privateKey.serialize(),
|
|
205
207
|
pollId: 0n,
|
|
206
|
-
pollJoiningZkey: constants_1.
|
|
207
|
-
useWasm
|
|
208
|
-
|
|
209
|
-
|
|
208
|
+
pollJoiningZkey: constants_1.testPollJoiningZkeyPath,
|
|
209
|
+
useWasm,
|
|
210
|
+
pollJoiningWasm: constants_1.testPollJoiningWasmPath,
|
|
211
|
+
pollWitnessGenerator: constants_1.testPollJoiningWitnessPath,
|
|
210
212
|
rapidsnark: constants_1.testRapidsnarkPath,
|
|
211
213
|
sgDataArg: constants_1.DEFAULT_SG_DATA,
|
|
212
214
|
ivcpDataArg: constants_1.DEFAULT_IVCP_DATA,
|
|
213
|
-
signer,
|
|
215
|
+
signer: userSigners[i],
|
|
214
216
|
});
|
|
215
217
|
}
|
|
216
218
|
});
|
|
217
219
|
it("should publish eight messages", async () => {
|
|
218
220
|
await (0, sdk_1.publish)({
|
|
219
|
-
|
|
221
|
+
publicKey: users[0].publicKey.serialize(),
|
|
220
222
|
stateIndex: 1n,
|
|
221
223
|
voteOptionIndex: 0n,
|
|
222
224
|
nonce: 2n,
|
|
223
225
|
pollId: 0n,
|
|
224
226
|
newVoteWeight: 4n,
|
|
225
227
|
maciAddress: maciAddresses.maciContractAddress,
|
|
226
|
-
salt: (0, crypto_1.
|
|
227
|
-
privateKey: users[0].
|
|
228
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
229
|
+
privateKey: users[0].privateKey.serialize(),
|
|
228
230
|
signer,
|
|
229
231
|
});
|
|
230
232
|
await (0, sdk_1.publish)({
|
|
231
|
-
|
|
233
|
+
publicKey: users[0].publicKey.serialize(),
|
|
232
234
|
stateIndex: 1n,
|
|
233
235
|
voteOptionIndex: 0n,
|
|
234
236
|
nonce: 2n,
|
|
235
237
|
pollId: 0n,
|
|
236
238
|
newVoteWeight: 3n,
|
|
237
239
|
maciAddress: maciAddresses.maciContractAddress,
|
|
238
|
-
salt: (0, crypto_1.
|
|
239
|
-
privateKey: users[0].
|
|
240
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
241
|
+
privateKey: users[0].privateKey.serialize(),
|
|
240
242
|
signer,
|
|
241
243
|
});
|
|
242
244
|
await (0, sdk_1.publish)({
|
|
243
|
-
|
|
245
|
+
publicKey: users[0].publicKey.serialize(),
|
|
244
246
|
stateIndex: 1n,
|
|
245
247
|
voteOptionIndex: 0n,
|
|
246
248
|
nonce: 1n,
|
|
247
249
|
pollId: 0n,
|
|
248
250
|
newVoteWeight: 9n,
|
|
249
251
|
maciAddress: maciAddresses.maciContractAddress,
|
|
250
|
-
salt: (0, crypto_1.
|
|
251
|
-
privateKey: users[0].
|
|
252
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
253
|
+
privateKey: users[0].privateKey.serialize(),
|
|
252
254
|
signer,
|
|
253
255
|
});
|
|
254
256
|
await (0, sdk_1.publish)({
|
|
255
|
-
|
|
257
|
+
publicKey: users[1].publicKey.serialize(),
|
|
256
258
|
stateIndex: 2n,
|
|
257
259
|
voteOptionIndex: 2n,
|
|
258
260
|
nonce: 1n,
|
|
259
261
|
pollId: 0n,
|
|
260
262
|
newVoteWeight: 9n,
|
|
261
263
|
maciAddress: maciAddresses.maciContractAddress,
|
|
262
|
-
salt: (0, crypto_1.
|
|
263
|
-
privateKey: users[1].
|
|
264
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
265
|
+
privateKey: users[1].privateKey.serialize(),
|
|
264
266
|
signer,
|
|
265
267
|
});
|
|
266
268
|
await (0, sdk_1.publish)({
|
|
267
|
-
|
|
269
|
+
publicKey: users[2].publicKey.serialize(),
|
|
268
270
|
stateIndex: 3n,
|
|
269
271
|
voteOptionIndex: 2n,
|
|
270
272
|
nonce: 1n,
|
|
271
273
|
pollId: 0n,
|
|
272
274
|
newVoteWeight: 9n,
|
|
273
275
|
maciAddress: maciAddresses.maciContractAddress,
|
|
274
|
-
salt: (0, crypto_1.
|
|
275
|
-
privateKey: users[2].
|
|
276
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
277
|
+
privateKey: users[2].privateKey.serialize(),
|
|
276
278
|
signer,
|
|
277
279
|
});
|
|
278
280
|
await (0, sdk_1.publish)({
|
|
279
|
-
|
|
281
|
+
publicKey: users[3].publicKey.serialize(),
|
|
280
282
|
stateIndex: 4n,
|
|
281
283
|
voteOptionIndex: 2n,
|
|
282
284
|
nonce: 3n,
|
|
283
285
|
pollId: 0n,
|
|
284
286
|
newVoteWeight: 3n,
|
|
285
287
|
maciAddress: maciAddresses.maciContractAddress,
|
|
286
|
-
salt: (0, crypto_1.
|
|
287
|
-
privateKey: users[3].
|
|
288
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
289
|
+
privateKey: users[3].privateKey.serialize(),
|
|
288
290
|
signer,
|
|
289
291
|
});
|
|
290
292
|
await (0, sdk_1.publish)({
|
|
291
|
-
|
|
293
|
+
publicKey: users[3].publicKey.serialize(),
|
|
292
294
|
stateIndex: 4n,
|
|
293
295
|
voteOptionIndex: 2n,
|
|
294
296
|
nonce: 2n,
|
|
295
297
|
pollId: 0n,
|
|
296
298
|
newVoteWeight: 2n,
|
|
297
299
|
maciAddress: maciAddresses.maciContractAddress,
|
|
298
|
-
salt: (0, crypto_1.
|
|
299
|
-
privateKey: users[3].
|
|
300
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
301
|
+
privateKey: users[3].privateKey.serialize(),
|
|
300
302
|
signer,
|
|
301
303
|
});
|
|
302
304
|
await (0, sdk_1.publish)({
|
|
303
|
-
|
|
305
|
+
publicKey: users[3].publicKey.serialize(),
|
|
304
306
|
stateIndex: 4n,
|
|
305
307
|
voteOptionIndex: 1n,
|
|
306
308
|
nonce: 1n,
|
|
307
309
|
pollId: 0n,
|
|
308
310
|
newVoteWeight: 9n,
|
|
309
311
|
maciAddress: maciAddresses.maciContractAddress,
|
|
310
|
-
salt: (0, crypto_1.
|
|
311
|
-
privateKey: users[3].
|
|
312
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
313
|
+
privateKey: users[3].privateKey.serialize(),
|
|
312
314
|
signer,
|
|
313
315
|
});
|
|
314
316
|
});
|
|
@@ -317,98 +319,98 @@ describe("e2e tests", function test() {
|
|
|
317
319
|
{
|
|
318
320
|
pollId: 0n,
|
|
319
321
|
voteOptionIndex: 1n,
|
|
320
|
-
salt: (0, crypto_1.
|
|
322
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
321
323
|
nonce: 2n,
|
|
322
|
-
privateKey: users[0].
|
|
324
|
+
privateKey: users[0].privateKey,
|
|
323
325
|
stateIndex: 1n,
|
|
324
326
|
voteWeight: 4n,
|
|
325
|
-
|
|
327
|
+
coordinatorPublicKey: constants_1.coordinatorKeypair.publicKey,
|
|
326
328
|
maxVoteOption: BigInt(core_1.VOTE_OPTION_TREE_ARITY ** constants_1.deployPollArgs.voteOptionTreeDepth),
|
|
327
|
-
|
|
329
|
+
newPublicKey: users[0].publicKey,
|
|
328
330
|
},
|
|
329
331
|
{
|
|
330
332
|
pollId: 0n,
|
|
331
333
|
voteOptionIndex: 1n,
|
|
332
|
-
salt: (0, crypto_1.
|
|
334
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
333
335
|
nonce: 2n,
|
|
334
|
-
privateKey: users[0].
|
|
336
|
+
privateKey: users[0].privateKey,
|
|
335
337
|
stateIndex: 1n,
|
|
336
338
|
voteWeight: 3n,
|
|
337
|
-
|
|
339
|
+
coordinatorPublicKey: constants_1.coordinatorKeypair.publicKey,
|
|
338
340
|
maxVoteOption: BigInt(core_1.VOTE_OPTION_TREE_ARITY ** constants_1.deployPollArgs.voteOptionTreeDepth),
|
|
339
|
-
|
|
341
|
+
newPublicKey: users[0].publicKey,
|
|
340
342
|
},
|
|
341
343
|
{
|
|
342
344
|
pollId: 0n,
|
|
343
345
|
voteOptionIndex: 1n,
|
|
344
|
-
salt: (0, crypto_1.
|
|
346
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
345
347
|
nonce: 1n,
|
|
346
|
-
privateKey: users[0].
|
|
348
|
+
privateKey: users[0].privateKey,
|
|
347
349
|
stateIndex: 1n,
|
|
348
350
|
voteWeight: 9n,
|
|
349
|
-
|
|
351
|
+
coordinatorPublicKey: constants_1.coordinatorKeypair.publicKey,
|
|
350
352
|
maxVoteOption: BigInt(core_1.VOTE_OPTION_TREE_ARITY ** constants_1.deployPollArgs.voteOptionTreeDepth),
|
|
351
|
-
|
|
353
|
+
newPublicKey: users[0].publicKey,
|
|
352
354
|
},
|
|
353
355
|
{
|
|
354
356
|
pollId: 0n,
|
|
355
357
|
voteOptionIndex: 1n,
|
|
356
|
-
salt: (0, crypto_1.
|
|
358
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
357
359
|
nonce: 1n,
|
|
358
|
-
privateKey: users[1].
|
|
360
|
+
privateKey: users[1].privateKey,
|
|
359
361
|
stateIndex: 2n,
|
|
360
362
|
voteWeight: 9n,
|
|
361
|
-
|
|
363
|
+
coordinatorPublicKey: constants_1.coordinatorKeypair.publicKey,
|
|
362
364
|
maxVoteOption: BigInt(core_1.VOTE_OPTION_TREE_ARITY ** constants_1.deployPollArgs.voteOptionTreeDepth),
|
|
363
|
-
|
|
365
|
+
newPublicKey: users[1].publicKey,
|
|
364
366
|
},
|
|
365
367
|
{
|
|
366
368
|
pollId: 0n,
|
|
367
369
|
voteOptionIndex: 1n,
|
|
368
|
-
salt: (0, crypto_1.
|
|
370
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
369
371
|
nonce: 1n,
|
|
370
|
-
privateKey: users[2].
|
|
372
|
+
privateKey: users[2].privateKey,
|
|
371
373
|
stateIndex: 3n,
|
|
372
374
|
voteWeight: 9n,
|
|
373
|
-
|
|
375
|
+
coordinatorPublicKey: constants_1.coordinatorKeypair.publicKey,
|
|
374
376
|
maxVoteOption: BigInt(core_1.VOTE_OPTION_TREE_ARITY ** constants_1.deployPollArgs.voteOptionTreeDepth),
|
|
375
|
-
|
|
377
|
+
newPublicKey: users[2].publicKey,
|
|
376
378
|
},
|
|
377
379
|
{
|
|
378
380
|
pollId: 0n,
|
|
379
381
|
voteOptionIndex: 0n,
|
|
380
|
-
salt: (0, crypto_1.
|
|
382
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
381
383
|
nonce: 3n,
|
|
382
|
-
privateKey: users[3].
|
|
384
|
+
privateKey: users[3].privateKey,
|
|
383
385
|
stateIndex: 4n,
|
|
384
386
|
voteWeight: 3n,
|
|
385
|
-
|
|
387
|
+
coordinatorPublicKey: constants_1.coordinatorKeypair.publicKey,
|
|
386
388
|
maxVoteOption: BigInt(core_1.VOTE_OPTION_TREE_ARITY ** constants_1.deployPollArgs.voteOptionTreeDepth),
|
|
387
|
-
|
|
389
|
+
newPublicKey: users[3].publicKey,
|
|
388
390
|
},
|
|
389
391
|
{
|
|
390
392
|
pollId: 0n,
|
|
391
393
|
voteOptionIndex: 0n,
|
|
392
|
-
salt: (0, crypto_1.
|
|
394
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
393
395
|
nonce: 2n,
|
|
394
|
-
privateKey: users[3].
|
|
396
|
+
privateKey: users[3].privateKey,
|
|
395
397
|
stateIndex: 4n,
|
|
396
398
|
voteWeight: 2n,
|
|
397
|
-
|
|
399
|
+
coordinatorPublicKey: constants_1.coordinatorKeypair.publicKey,
|
|
398
400
|
maxVoteOption: BigInt(core_1.VOTE_OPTION_TREE_ARITY ** constants_1.deployPollArgs.voteOptionTreeDepth),
|
|
399
|
-
|
|
401
|
+
newPublicKey: users[3].publicKey,
|
|
400
402
|
},
|
|
401
403
|
{
|
|
402
404
|
pollId: 0n,
|
|
403
405
|
voteOptionIndex: 0n,
|
|
404
|
-
salt: (0, crypto_1.
|
|
406
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
405
407
|
nonce: 1n,
|
|
406
|
-
privateKey: users[3].
|
|
408
|
+
privateKey: users[3].privateKey,
|
|
407
409
|
stateIndex: 4n,
|
|
408
410
|
voteWeight: 9n,
|
|
409
|
-
|
|
411
|
+
coordinatorPublicKey: constants_1.coordinatorKeypair.publicKey,
|
|
410
412
|
maxVoteOption: BigInt(core_1.VOTE_OPTION_TREE_ARITY ** constants_1.deployPollArgs.voteOptionTreeDepth),
|
|
411
|
-
|
|
413
|
+
newPublicKey: users[3].publicKey,
|
|
412
414
|
},
|
|
413
415
|
];
|
|
414
416
|
const messages = votes
|
|
@@ -417,8 +419,8 @@ describe("e2e tests", function test() {
|
|
|
417
419
|
maciAddress: maciAddresses.maciContractAddress,
|
|
418
420
|
poll: 0,
|
|
419
421
|
data: message.data.map(String),
|
|
420
|
-
publicKey: ephemeralKeypair.
|
|
421
|
-
hash: message.hash(ephemeralKeypair.
|
|
422
|
+
publicKey: ephemeralKeypair.publicKey.asArray().map(String),
|
|
423
|
+
hash: message.hash(ephemeralKeypair.publicKey).toString(),
|
|
422
424
|
}));
|
|
423
425
|
await (0, utils_1.relayTestMessages)({ messages, signer, pollId: 0, maciAddress: maciAddresses.maciContractAddress });
|
|
424
426
|
});
|
|
@@ -452,6 +454,12 @@ describe("e2e tests", function test() {
|
|
|
452
454
|
signer,
|
|
453
455
|
signupPolicyAddress: signupPolicyContractAddress,
|
|
454
456
|
});
|
|
457
|
+
// we set the verifying keys
|
|
458
|
+
const { verifyingKeysRegistryContractAddress } = maciAddresses;
|
|
459
|
+
await (0, sdk_1.setVerifyingKeys)({
|
|
460
|
+
...(await (0, constants_1.verifyingKeysArgs)(signer)),
|
|
461
|
+
verifyingKeysRegistryAddress: verifyingKeysRegistryContractAddress,
|
|
462
|
+
});
|
|
455
463
|
const startDate = await (0, sdk_1.getBlockTimestamp)(signer);
|
|
456
464
|
// deploy a poll contract
|
|
457
465
|
await (0, sdk_1.deployPoll)({
|
|
@@ -461,8 +469,6 @@ describe("e2e tests", function test() {
|
|
|
461
469
|
pollEndTimestamp: startDate + constants_1.pollDuration,
|
|
462
470
|
relayers: [await signer.getAddress()],
|
|
463
471
|
maciAddress: maciAddresses.maciContractAddress,
|
|
464
|
-
verifierContractAddress,
|
|
465
|
-
vkRegistryContractAddress: vkRegistryAddress,
|
|
466
472
|
policyContractAddress: pollPolicyContractAddress,
|
|
467
473
|
initialVoiceCreditProxyContractAddress,
|
|
468
474
|
});
|
|
@@ -472,9 +478,9 @@ describe("e2e tests", function test() {
|
|
|
472
478
|
// eslint-disable-next-line no-await-in-loop
|
|
473
479
|
await (0, sdk_1.signup)({
|
|
474
480
|
maciAddress: maciAddresses.maciContractAddress,
|
|
475
|
-
|
|
481
|
+
maciPublicKey: users[i].publicKey.serialize(),
|
|
476
482
|
sgData: constants_1.DEFAULT_SG_DATA,
|
|
477
|
-
signer,
|
|
483
|
+
signer: userSigners[i],
|
|
478
484
|
});
|
|
479
485
|
}
|
|
480
486
|
});
|
|
@@ -482,17 +488,16 @@ describe("e2e tests", function test() {
|
|
|
482
488
|
// eslint-disable-next-line no-await-in-loop
|
|
483
489
|
await (0, sdk_1.joinPoll)({
|
|
484
490
|
maciAddress: maciAddresses.maciContractAddress,
|
|
485
|
-
privateKey: users[0].
|
|
486
|
-
stateIndex: 1n,
|
|
491
|
+
privateKey: users[0].privateKey.serialize(),
|
|
487
492
|
pollId: 0n,
|
|
488
|
-
pollJoiningZkey: constants_1.
|
|
489
|
-
useWasm
|
|
490
|
-
|
|
491
|
-
|
|
493
|
+
pollJoiningZkey: constants_1.testPollJoiningZkeyPath,
|
|
494
|
+
useWasm,
|
|
495
|
+
pollJoiningWasm: constants_1.testPollJoiningWasmPath,
|
|
496
|
+
pollWitnessGenerator: constants_1.testPollJoiningWitnessPath,
|
|
492
497
|
rapidsnark: constants_1.testRapidsnarkPath,
|
|
493
498
|
sgDataArg: constants_1.DEFAULT_SG_DATA,
|
|
494
499
|
ivcpDataArg: constants_1.DEFAULT_IVCP_DATA,
|
|
495
|
-
signer,
|
|
500
|
+
signer: userSigners[0],
|
|
496
501
|
});
|
|
497
502
|
});
|
|
498
503
|
it("should publish and relay 12 messages with the same nonce", async () => {
|
|
@@ -501,35 +506,35 @@ describe("e2e tests", function test() {
|
|
|
501
506
|
.map(() => (0, sdk_1.generateVote)({
|
|
502
507
|
pollId: 0n,
|
|
503
508
|
voteOptionIndex: 0n,
|
|
504
|
-
salt: (0, crypto_1.
|
|
509
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
505
510
|
nonce: 1n,
|
|
506
|
-
privateKey: users[0].
|
|
511
|
+
privateKey: users[0].privateKey,
|
|
507
512
|
stateIndex: 1n,
|
|
508
513
|
voteWeight: 9n,
|
|
509
|
-
|
|
514
|
+
coordinatorPublicKey: constants_1.coordinatorKeypair.publicKey,
|
|
510
515
|
maxVoteOption: BigInt(core_1.VOTE_OPTION_TREE_ARITY ** constants_1.deployPollArgs.voteOptionTreeDepth),
|
|
511
|
-
|
|
516
|
+
newPublicKey: users[0].publicKey,
|
|
512
517
|
}))
|
|
513
518
|
.map(({ message, ephemeralKeypair }) => ({
|
|
514
519
|
maciAddress: maciAddresses.maciContractAddress,
|
|
515
520
|
poll: 0,
|
|
516
521
|
data: message.data.map(String),
|
|
517
|
-
publicKey: ephemeralKeypair.
|
|
518
|
-
hash: message.hash(ephemeralKeypair.
|
|
522
|
+
publicKey: ephemeralKeypair.publicKey.asArray().map(String),
|
|
523
|
+
hash: message.hash(ephemeralKeypair.publicKey).toString(),
|
|
519
524
|
}));
|
|
520
525
|
await (0, utils_1.relayTestMessages)({ messages, signer, pollId: 0, maciAddress: maciAddresses.maciContractAddress });
|
|
521
526
|
for (let i = 0; i < 12; i += 1) {
|
|
522
527
|
// eslint-disable-next-line no-await-in-loop
|
|
523
528
|
await (0, sdk_1.publish)({
|
|
524
|
-
|
|
529
|
+
publicKey: users[0].publicKey.serialize(),
|
|
525
530
|
stateIndex: 1n,
|
|
526
531
|
voteOptionIndex: 0n,
|
|
527
532
|
nonce: 1n,
|
|
528
533
|
pollId: 0n,
|
|
529
534
|
newVoteWeight: 9n,
|
|
530
535
|
maciAddress: maciAddresses.maciContractAddress,
|
|
531
|
-
salt: (0, crypto_1.
|
|
532
|
-
privateKey: users[0].
|
|
536
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
537
|
+
privateKey: users[0].privateKey.serialize(),
|
|
533
538
|
signer,
|
|
534
539
|
});
|
|
535
540
|
}
|
|
@@ -564,6 +569,12 @@ describe("e2e tests", function test() {
|
|
|
564
569
|
signer,
|
|
565
570
|
signupPolicyAddress: signupPolicyContractAddress,
|
|
566
571
|
});
|
|
572
|
+
// we set the verifying keys
|
|
573
|
+
const { verifyingKeysRegistryContractAddress } = maciAddresses;
|
|
574
|
+
await (0, sdk_1.setVerifyingKeys)({
|
|
575
|
+
...(await (0, constants_1.verifyingKeysArgs)(signer)),
|
|
576
|
+
verifyingKeysRegistryAddress: verifyingKeysRegistryContractAddress,
|
|
577
|
+
});
|
|
567
578
|
const startDate = await (0, sdk_1.getBlockTimestamp)(signer);
|
|
568
579
|
// deploy a poll contract
|
|
569
580
|
await (0, sdk_1.deployPoll)({
|
|
@@ -573,8 +584,6 @@ describe("e2e tests", function test() {
|
|
|
573
584
|
pollEndTimestamp: startDate + constants_1.pollDuration,
|
|
574
585
|
relayers: [await signer.getAddress()],
|
|
575
586
|
maciAddress: maciAddresses.maciContractAddress,
|
|
576
|
-
verifierContractAddress,
|
|
577
|
-
vkRegistryContractAddress: vkRegistryAddress,
|
|
578
587
|
policyContractAddress: pollPolicyContractAddress,
|
|
579
588
|
initialVoiceCreditProxyContractAddress,
|
|
580
589
|
});
|
|
@@ -585,9 +594,9 @@ describe("e2e tests", function test() {
|
|
|
585
594
|
// eslint-disable-next-line no-await-in-loop
|
|
586
595
|
await (0, sdk_1.signup)({
|
|
587
596
|
maciAddress: maciAddresses.maciContractAddress,
|
|
588
|
-
|
|
597
|
+
maciPublicKey: users[i].publicKey.serialize(),
|
|
589
598
|
sgData: constants_1.DEFAULT_SG_DATA,
|
|
590
|
-
signer,
|
|
599
|
+
signer: userSigners[i],
|
|
591
600
|
});
|
|
592
601
|
}
|
|
593
602
|
});
|
|
@@ -597,17 +606,16 @@ describe("e2e tests", function test() {
|
|
|
597
606
|
// eslint-disable-next-line no-await-in-loop
|
|
598
607
|
await (0, sdk_1.joinPoll)({
|
|
599
608
|
maciAddress: maciAddresses.maciContractAddress,
|
|
600
|
-
privateKey: users[i].
|
|
601
|
-
stateIndex: BigInt(i + 1),
|
|
609
|
+
privateKey: users[i].privateKey.serialize(),
|
|
602
610
|
pollId: 0n,
|
|
603
|
-
pollJoiningZkey: constants_1.
|
|
604
|
-
useWasm
|
|
605
|
-
|
|
606
|
-
|
|
611
|
+
pollJoiningZkey: constants_1.testPollJoiningZkeyPath,
|
|
612
|
+
useWasm,
|
|
613
|
+
pollJoiningWasm: constants_1.testPollJoiningWasmPath,
|
|
614
|
+
pollWitnessGenerator: constants_1.testPollJoiningWitnessPath,
|
|
607
615
|
rapidsnark: constants_1.testRapidsnarkPath,
|
|
608
616
|
sgDataArg: constants_1.DEFAULT_SG_DATA,
|
|
609
617
|
ivcpDataArg: constants_1.DEFAULT_IVCP_DATA,
|
|
610
|
-
signer,
|
|
618
|
+
signer: userSigners[i],
|
|
611
619
|
});
|
|
612
620
|
}
|
|
613
621
|
});
|
|
@@ -617,14 +625,14 @@ describe("e2e tests", function test() {
|
|
|
617
625
|
// eslint-disable-next-line no-await-in-loop
|
|
618
626
|
await (0, sdk_1.publish)({
|
|
619
627
|
maciAddress: maciAddresses.maciContractAddress,
|
|
620
|
-
|
|
628
|
+
publicKey: users[i].publicKey.serialize(),
|
|
621
629
|
stateIndex: BigInt(i + 1),
|
|
622
630
|
voteOptionIndex: 0n,
|
|
623
631
|
nonce: 1n,
|
|
624
632
|
pollId: 0n,
|
|
625
633
|
newVoteWeight: 9n,
|
|
626
|
-
salt: (0, crypto_1.
|
|
627
|
-
privateKey: users[i].
|
|
634
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
635
|
+
privateKey: users[i].privateKey.serialize(),
|
|
628
636
|
signer,
|
|
629
637
|
});
|
|
630
638
|
}
|
|
@@ -657,6 +665,12 @@ describe("e2e tests", function test() {
|
|
|
657
665
|
signer,
|
|
658
666
|
signupPolicyAddress: signupPolicyContractAddress,
|
|
659
667
|
});
|
|
668
|
+
// we set the verifying keys
|
|
669
|
+
const { verifyingKeysRegistryContractAddress } = maciAddresses;
|
|
670
|
+
await (0, sdk_1.setVerifyingKeys)({
|
|
671
|
+
...(await (0, constants_1.verifyingKeysArgs)(signer)),
|
|
672
|
+
verifyingKeysRegistryAddress: verifyingKeysRegistryContractAddress,
|
|
673
|
+
});
|
|
660
674
|
const startDate = await (0, sdk_1.getBlockTimestamp)(signer);
|
|
661
675
|
// deploy a poll contract
|
|
662
676
|
await (0, sdk_1.deployPoll)({
|
|
@@ -666,8 +680,6 @@ describe("e2e tests", function test() {
|
|
|
666
680
|
pollEndTimestamp: startDate + constants_1.pollDuration,
|
|
667
681
|
relayers: [await signer.getAddress()],
|
|
668
682
|
maciAddress: maciAddresses.maciContractAddress,
|
|
669
|
-
verifierContractAddress,
|
|
670
|
-
vkRegistryContractAddress: vkRegistryAddress,
|
|
671
683
|
policyContractAddress: pollPolicyContractAddress,
|
|
672
684
|
initialVoiceCreditProxyContractAddress,
|
|
673
685
|
});
|
|
@@ -678,9 +690,9 @@ describe("e2e tests", function test() {
|
|
|
678
690
|
// eslint-disable-next-line no-await-in-loop
|
|
679
691
|
await (0, sdk_1.signup)({
|
|
680
692
|
maciAddress: maciAddresses.maciContractAddress,
|
|
681
|
-
|
|
693
|
+
maciPublicKey: users[i].publicKey.serialize(),
|
|
682
694
|
sgData: constants_1.DEFAULT_SG_DATA,
|
|
683
|
-
signer,
|
|
695
|
+
signer: userSigners[i],
|
|
684
696
|
});
|
|
685
697
|
}
|
|
686
698
|
});
|
|
@@ -690,17 +702,16 @@ describe("e2e tests", function test() {
|
|
|
690
702
|
// eslint-disable-next-line no-await-in-loop
|
|
691
703
|
await (0, sdk_1.joinPoll)({
|
|
692
704
|
maciAddress: maciAddresses.maciContractAddress,
|
|
693
|
-
privateKey: users[i].
|
|
694
|
-
stateIndex: BigInt(i + 1),
|
|
705
|
+
privateKey: users[i].privateKey.serialize(),
|
|
695
706
|
pollId: 0n,
|
|
696
|
-
pollJoiningZkey: constants_1.
|
|
697
|
-
useWasm
|
|
698
|
-
|
|
699
|
-
|
|
707
|
+
pollJoiningZkey: constants_1.testPollJoiningZkeyPath,
|
|
708
|
+
useWasm,
|
|
709
|
+
pollJoiningWasm: constants_1.testPollJoiningWasmPath,
|
|
710
|
+
pollWitnessGenerator: constants_1.testPollJoiningWitnessPath,
|
|
700
711
|
rapidsnark: constants_1.testRapidsnarkPath,
|
|
701
712
|
sgDataArg: constants_1.DEFAULT_SG_DATA,
|
|
702
713
|
ivcpDataArg: constants_1.DEFAULT_IVCP_DATA,
|
|
703
|
-
signer,
|
|
714
|
+
signer: userSigners[i],
|
|
704
715
|
});
|
|
705
716
|
}
|
|
706
717
|
});
|
|
@@ -710,14 +721,14 @@ describe("e2e tests", function test() {
|
|
|
710
721
|
// eslint-disable-next-line no-await-in-loop
|
|
711
722
|
await (0, sdk_1.publish)({
|
|
712
723
|
maciAddress: maciAddresses.maciContractAddress,
|
|
713
|
-
|
|
714
|
-
stateIndex:
|
|
724
|
+
publicKey: users[i].publicKey.serialize(),
|
|
725
|
+
stateIndex: BigInt(i + 1),
|
|
715
726
|
voteOptionIndex: 0n,
|
|
716
727
|
nonce: 1n,
|
|
717
728
|
pollId: 0n,
|
|
718
729
|
newVoteWeight: 9n,
|
|
719
|
-
salt: (0, crypto_1.
|
|
720
|
-
privateKey: users[i].
|
|
730
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
731
|
+
privateKey: users[i].privateKey.serialize(),
|
|
721
732
|
signer,
|
|
722
733
|
});
|
|
723
734
|
}
|
|
@@ -727,38 +738,38 @@ describe("e2e tests", function test() {
|
|
|
727
738
|
{
|
|
728
739
|
pollId: 0n,
|
|
729
740
|
voteOptionIndex: 1n,
|
|
730
|
-
salt: (0, crypto_1.
|
|
741
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
731
742
|
nonce: 2n,
|
|
732
|
-
privateKey: users[0].
|
|
743
|
+
privateKey: users[0].privateKey,
|
|
733
744
|
stateIndex: 1n,
|
|
734
745
|
voteWeight: 5n,
|
|
735
|
-
|
|
746
|
+
coordinatorPublicKey: constants_1.coordinatorKeypair.publicKey,
|
|
736
747
|
maxVoteOption: BigInt(core_1.VOTE_OPTION_TREE_ARITY ** constants_1.deployPollArgs.voteOptionTreeDepth),
|
|
737
|
-
|
|
748
|
+
newPublicKey: users[0].publicKey,
|
|
738
749
|
},
|
|
739
750
|
{
|
|
740
751
|
pollId: 0n,
|
|
741
752
|
voteOptionIndex: 2n,
|
|
742
|
-
salt: (0, crypto_1.
|
|
753
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
743
754
|
nonce: 3n,
|
|
744
|
-
privateKey: users[2].
|
|
755
|
+
privateKey: users[2].privateKey,
|
|
745
756
|
stateIndex: 3n,
|
|
746
757
|
voteWeight: 9n,
|
|
747
|
-
|
|
758
|
+
coordinatorPublicKey: constants_1.coordinatorKeypair.publicKey,
|
|
748
759
|
maxVoteOption: BigInt(core_1.VOTE_OPTION_TREE_ARITY ** constants_1.deployPollArgs.voteOptionTreeDepth),
|
|
749
|
-
|
|
760
|
+
newPublicKey: users[2].publicKey,
|
|
750
761
|
},
|
|
751
762
|
{
|
|
752
763
|
pollId: 0n,
|
|
753
764
|
voteOptionIndex: 3n,
|
|
754
|
-
salt: (0, crypto_1.
|
|
765
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
755
766
|
nonce: 3n,
|
|
756
|
-
privateKey: users[3].
|
|
767
|
+
privateKey: users[3].privateKey,
|
|
757
768
|
stateIndex: 4n,
|
|
758
769
|
voteWeight: 7n,
|
|
759
|
-
|
|
770
|
+
coordinatorPublicKey: constants_1.coordinatorKeypair.publicKey,
|
|
760
771
|
maxVoteOption: BigInt(core_1.VOTE_OPTION_TREE_ARITY ** constants_1.deployPollArgs.voteOptionTreeDepth),
|
|
761
|
-
|
|
772
|
+
newPublicKey: users[3].publicKey,
|
|
762
773
|
},
|
|
763
774
|
];
|
|
764
775
|
const messages = votes
|
|
@@ -767,8 +778,8 @@ describe("e2e tests", function test() {
|
|
|
767
778
|
maciAddress: maciAddresses.maciContractAddress,
|
|
768
779
|
poll: 0,
|
|
769
780
|
data: message.data.map(String),
|
|
770
|
-
publicKey: ephemeralKeypair.
|
|
771
|
-
hash: message.hash(ephemeralKeypair.
|
|
781
|
+
publicKey: ephemeralKeypair.publicKey.asArray().map(String),
|
|
782
|
+
hash: message.hash(ephemeralKeypair.publicKey).toString(),
|
|
772
783
|
}));
|
|
773
784
|
await (0, utils_1.relayTestMessages)({ messages, signer, pollId: 0, maciAddress: maciAddresses.maciContractAddress });
|
|
774
785
|
});
|
|
@@ -802,6 +813,12 @@ describe("e2e tests", function test() {
|
|
|
802
813
|
signer,
|
|
803
814
|
signupPolicyAddress: signupPolicyContractAddress,
|
|
804
815
|
});
|
|
816
|
+
// we set the verifying keys
|
|
817
|
+
const { verifyingKeysRegistryContractAddress } = maciAddresses;
|
|
818
|
+
await (0, sdk_1.setVerifyingKeys)({
|
|
819
|
+
...(await (0, constants_1.verifyingKeysArgs)(signer)),
|
|
820
|
+
verifyingKeysRegistryAddress: verifyingKeysRegistryContractAddress,
|
|
821
|
+
});
|
|
805
822
|
const startDate = await (0, sdk_1.getBlockTimestamp)(signer);
|
|
806
823
|
// deploy a poll contract
|
|
807
824
|
await (0, sdk_1.deployPoll)({
|
|
@@ -811,85 +828,81 @@ describe("e2e tests", function test() {
|
|
|
811
828
|
pollEndTimestamp: startDate + constants_1.pollDuration,
|
|
812
829
|
relayers: [await signer.getAddress()],
|
|
813
830
|
maciAddress: maciAddresses.maciContractAddress,
|
|
814
|
-
verifierContractAddress,
|
|
815
|
-
vkRegistryContractAddress: vkRegistryAddress,
|
|
816
831
|
policyContractAddress: pollPolicyContractAddress,
|
|
817
832
|
initialVoiceCreditProxyContractAddress,
|
|
818
833
|
});
|
|
819
834
|
// signup
|
|
820
835
|
await (0, sdk_1.signup)({
|
|
821
836
|
maciAddress: maciAddresses.maciContractAddress,
|
|
822
|
-
|
|
837
|
+
maciPublicKey: users[0].publicKey.serialize(),
|
|
823
838
|
sgData: constants_1.DEFAULT_SG_DATA,
|
|
824
|
-
signer,
|
|
839
|
+
signer: userSigners[0],
|
|
825
840
|
});
|
|
826
841
|
// joinPoll
|
|
827
842
|
await (0, sdk_1.joinPoll)({
|
|
828
843
|
maciAddress: maciAddresses.maciContractAddress,
|
|
829
|
-
privateKey: users[0].
|
|
830
|
-
stateIndex: 1n,
|
|
844
|
+
privateKey: users[0].privateKey.serialize(),
|
|
831
845
|
pollId: 0n,
|
|
832
|
-
pollJoiningZkey: constants_1.
|
|
833
|
-
useWasm
|
|
834
|
-
|
|
835
|
-
|
|
846
|
+
pollJoiningZkey: constants_1.testPollJoiningZkeyPath,
|
|
847
|
+
useWasm,
|
|
848
|
+
pollJoiningWasm: constants_1.testPollJoiningWasmPath,
|
|
849
|
+
pollWitnessGenerator: constants_1.testPollJoiningWitnessPath,
|
|
836
850
|
rapidsnark: constants_1.testRapidsnarkPath,
|
|
837
851
|
sgDataArg: constants_1.DEFAULT_SG_DATA,
|
|
838
852
|
ivcpDataArg: constants_1.DEFAULT_IVCP_DATA,
|
|
839
|
-
signer,
|
|
853
|
+
signer: userSigners[0],
|
|
840
854
|
});
|
|
841
855
|
// publish
|
|
842
856
|
await (0, sdk_1.publish)({
|
|
843
|
-
|
|
857
|
+
publicKey: users[0].publicKey.serialize(),
|
|
844
858
|
stateIndex: 1n,
|
|
845
859
|
voteOptionIndex: 0n,
|
|
846
860
|
nonce: 1n,
|
|
847
861
|
pollId: 0n,
|
|
848
862
|
newVoteWeight: 9n,
|
|
849
863
|
maciAddress: maciAddresses.maciContractAddress,
|
|
850
|
-
salt: (0, crypto_1.
|
|
851
|
-
privateKey: users[0].
|
|
864
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
865
|
+
privateKey: users[0].privateKey.serialize(),
|
|
852
866
|
signer,
|
|
853
867
|
});
|
|
854
868
|
await (0, sdk_1.signup)({
|
|
855
869
|
maciAddress: maciAddresses.maciContractAddress,
|
|
856
|
-
|
|
870
|
+
maciPublicKey: users[1].publicKey.serialize(),
|
|
857
871
|
sgData: constants_1.DEFAULT_SG_DATA,
|
|
858
|
-
signer,
|
|
872
|
+
signer: userSigners[1],
|
|
859
873
|
});
|
|
860
874
|
await (0, sdk_1.signup)({
|
|
861
875
|
maciAddress: maciAddresses.maciContractAddress,
|
|
862
|
-
|
|
876
|
+
maciPublicKey: users[2].publicKey.serialize(),
|
|
863
877
|
sgData: constants_1.DEFAULT_SG_DATA,
|
|
864
|
-
signer,
|
|
878
|
+
signer: userSigners[2],
|
|
865
879
|
});
|
|
866
880
|
// joinPoll
|
|
867
881
|
await (0, sdk_1.joinPoll)({
|
|
868
882
|
maciAddress: maciAddresses.maciContractAddress,
|
|
869
|
-
privateKey: users[1].
|
|
870
|
-
stateIndex: 2n,
|
|
883
|
+
privateKey: users[1].privateKey.serialize(),
|
|
871
884
|
pollId: 0n,
|
|
872
|
-
pollJoiningZkey: constants_1.
|
|
873
|
-
useWasm
|
|
874
|
-
|
|
875
|
-
|
|
885
|
+
pollJoiningZkey: constants_1.testPollJoiningZkeyPath,
|
|
886
|
+
useWasm,
|
|
887
|
+
pollJoiningWasm: constants_1.testPollJoiningWasmPath,
|
|
888
|
+
pollWitnessGenerator: constants_1.testPollJoiningWitnessPath,
|
|
876
889
|
rapidsnark: constants_1.testRapidsnarkPath,
|
|
877
890
|
sgDataArg: constants_1.DEFAULT_SG_DATA,
|
|
878
891
|
ivcpDataArg: constants_1.DEFAULT_IVCP_DATA,
|
|
879
|
-
signer,
|
|
892
|
+
signer: userSigners[1],
|
|
880
893
|
});
|
|
881
894
|
const votes = [
|
|
882
895
|
{
|
|
883
896
|
pollId: 0n,
|
|
884
897
|
voteOptionIndex: 0n,
|
|
885
|
-
salt: (0, crypto_1.
|
|
898
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
886
899
|
nonce: 1n,
|
|
887
|
-
privateKey: users[1].
|
|
900
|
+
privateKey: users[1].privateKey,
|
|
888
901
|
stateIndex: 2n,
|
|
889
902
|
voteWeight: 2n,
|
|
890
|
-
|
|
903
|
+
coordinatorPublicKey: constants_1.coordinatorKeypair.publicKey,
|
|
891
904
|
maxVoteOption: BigInt(core_1.VOTE_OPTION_TREE_ARITY ** constants_1.deployPollArgs.voteOptionTreeDepth),
|
|
892
|
-
|
|
905
|
+
newPublicKey: users[1].publicKey,
|
|
893
906
|
},
|
|
894
907
|
];
|
|
895
908
|
const messages = votes
|
|
@@ -898,8 +911,8 @@ describe("e2e tests", function test() {
|
|
|
898
911
|
maciAddress: maciAddresses.maciContractAddress,
|
|
899
912
|
poll: 0,
|
|
900
913
|
data: message.data.map(String),
|
|
901
|
-
publicKey: ephemeralKeypair.
|
|
902
|
-
hash: message.hash(ephemeralKeypair.
|
|
914
|
+
publicKey: ephemeralKeypair.publicKey.asArray().map(String),
|
|
915
|
+
hash: message.hash(ephemeralKeypair.publicKey).toString(),
|
|
903
916
|
}));
|
|
904
917
|
await (0, utils_1.relayTestMessages)({ messages, signer, pollId: 0, maciAddress: maciAddresses.maciContractAddress });
|
|
905
918
|
const ipfsMessageBackupFiles = await (0, utils_1.getBackupFilenames)();
|
|
@@ -929,8 +942,6 @@ describe("e2e tests", function test() {
|
|
|
929
942
|
pollEndTimestamp: startDate + constants_1.pollDuration,
|
|
930
943
|
relayers: [await signer.getAddress()],
|
|
931
944
|
maciAddress: maciAddresses.maciContractAddress,
|
|
932
|
-
verifierContractAddress,
|
|
933
|
-
vkRegistryContractAddress: vkRegistryAddress,
|
|
934
945
|
policyContractAddress: pollPolicyContractAddress,
|
|
935
946
|
initialVoiceCreditProxyContractAddress,
|
|
936
947
|
});
|
|
@@ -938,47 +949,45 @@ describe("e2e tests", function test() {
|
|
|
938
949
|
it("should signup two new users", async () => {
|
|
939
950
|
await (0, sdk_1.signup)({
|
|
940
951
|
maciAddress: maciAddresses.maciContractAddress,
|
|
941
|
-
|
|
952
|
+
maciPublicKey: users[3].publicKey.serialize(),
|
|
942
953
|
sgData: constants_1.DEFAULT_SG_DATA,
|
|
943
|
-
signer,
|
|
954
|
+
signer: userSigners[3],
|
|
944
955
|
});
|
|
945
956
|
await (0, sdk_1.signup)({
|
|
946
957
|
maciAddress: maciAddresses.maciContractAddress,
|
|
947
|
-
|
|
958
|
+
maciPublicKey: users[4].publicKey.serialize(),
|
|
948
959
|
sgData: constants_1.DEFAULT_SG_DATA,
|
|
949
|
-
signer,
|
|
960
|
+
signer: userSigners[4],
|
|
950
961
|
});
|
|
951
962
|
});
|
|
952
963
|
it("should join users", async () => {
|
|
953
964
|
// joinPoll
|
|
954
965
|
await (0, sdk_1.joinPoll)({
|
|
955
966
|
maciAddress: maciAddresses.maciContractAddress,
|
|
956
|
-
privateKey: users[3].
|
|
957
|
-
stateIndex: 4n,
|
|
967
|
+
privateKey: users[3].privateKey.serialize(),
|
|
958
968
|
pollId: 1n,
|
|
959
|
-
pollJoiningZkey: constants_1.
|
|
960
|
-
useWasm
|
|
961
|
-
|
|
962
|
-
|
|
969
|
+
pollJoiningZkey: constants_1.testPollJoiningZkeyPath,
|
|
970
|
+
useWasm,
|
|
971
|
+
pollJoiningWasm: constants_1.testPollJoiningWasmPath,
|
|
972
|
+
pollWitnessGenerator: constants_1.testPollJoiningWitnessPath,
|
|
963
973
|
rapidsnark: constants_1.testRapidsnarkPath,
|
|
964
974
|
sgDataArg: constants_1.DEFAULT_SG_DATA,
|
|
965
975
|
ivcpDataArg: constants_1.DEFAULT_IVCP_DATA,
|
|
966
|
-
signer,
|
|
976
|
+
signer: userSigners[3],
|
|
967
977
|
});
|
|
968
978
|
// joinPoll
|
|
969
979
|
await (0, sdk_1.joinPoll)({
|
|
970
980
|
maciAddress: maciAddresses.maciContractAddress,
|
|
971
|
-
privateKey: users[4].
|
|
972
|
-
stateIndex: 5n,
|
|
981
|
+
privateKey: users[4].privateKey.serialize(),
|
|
973
982
|
pollId: 1n,
|
|
974
|
-
pollJoiningZkey: constants_1.
|
|
975
|
-
useWasm
|
|
976
|
-
|
|
977
|
-
|
|
983
|
+
pollJoiningZkey: constants_1.testPollJoiningZkeyPath,
|
|
984
|
+
useWasm,
|
|
985
|
+
pollJoiningWasm: constants_1.testPollJoiningWasmPath,
|
|
986
|
+
pollWitnessGenerator: constants_1.testPollJoiningWitnessPath,
|
|
978
987
|
rapidsnark: constants_1.testRapidsnarkPath,
|
|
979
988
|
sgDataArg: constants_1.DEFAULT_SG_DATA,
|
|
980
989
|
ivcpDataArg: constants_1.DEFAULT_IVCP_DATA,
|
|
981
|
-
signer,
|
|
990
|
+
signer: userSigners[4],
|
|
982
991
|
});
|
|
983
992
|
});
|
|
984
993
|
it("should relay new messages", async () => {
|
|
@@ -986,26 +995,26 @@ describe("e2e tests", function test() {
|
|
|
986
995
|
{
|
|
987
996
|
pollId: 1n,
|
|
988
997
|
voteOptionIndex: 1n,
|
|
989
|
-
salt: (0, crypto_1.
|
|
998
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
990
999
|
nonce: 1n,
|
|
991
|
-
privateKey: users[0].
|
|
1000
|
+
privateKey: users[0].privateKey,
|
|
992
1001
|
stateIndex: 1n,
|
|
993
1002
|
voteWeight: 9n,
|
|
994
|
-
|
|
1003
|
+
coordinatorPublicKey: constants_1.coordinatorKeypair.publicKey,
|
|
995
1004
|
maxVoteOption: BigInt(core_1.VOTE_OPTION_TREE_ARITY ** constants_1.deployPollArgs.voteOptionTreeDepth),
|
|
996
|
-
|
|
1005
|
+
newPublicKey: users[0].publicKey,
|
|
997
1006
|
},
|
|
998
1007
|
{
|
|
999
1008
|
pollId: 1n,
|
|
1000
1009
|
voteOptionIndex: 0n,
|
|
1001
|
-
salt: (0, crypto_1.
|
|
1010
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
1002
1011
|
nonce: 1n,
|
|
1003
|
-
privateKey: users[1].
|
|
1012
|
+
privateKey: users[1].privateKey,
|
|
1004
1013
|
stateIndex: 1n,
|
|
1005
1014
|
voteWeight: 5n,
|
|
1006
|
-
|
|
1015
|
+
coordinatorPublicKey: constants_1.coordinatorKeypair.publicKey,
|
|
1007
1016
|
maxVoteOption: BigInt(core_1.VOTE_OPTION_TREE_ARITY ** constants_1.deployPollArgs.voteOptionTreeDepth),
|
|
1008
|
-
|
|
1017
|
+
newPublicKey: users[1].publicKey,
|
|
1009
1018
|
},
|
|
1010
1019
|
];
|
|
1011
1020
|
const messages = votes
|
|
@@ -1014,36 +1023,36 @@ describe("e2e tests", function test() {
|
|
|
1014
1023
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1015
1024
|
poll: 1,
|
|
1016
1025
|
data: message.data.map(String),
|
|
1017
|
-
publicKey: ephemeralKeypair.
|
|
1018
|
-
hash: message.hash(ephemeralKeypair.
|
|
1026
|
+
publicKey: ephemeralKeypair.publicKey.asArray().map(String),
|
|
1027
|
+
hash: message.hash(ephemeralKeypair.publicKey).toString(),
|
|
1019
1028
|
}));
|
|
1020
1029
|
await (0, utils_1.relayTestMessages)({ messages, signer, pollId: 1, maciAddress: maciAddresses.maciContractAddress });
|
|
1021
1030
|
});
|
|
1022
1031
|
it("should publish a new message from the first poll voter", async () => {
|
|
1023
1032
|
await (0, sdk_1.publish)({
|
|
1024
|
-
|
|
1033
|
+
publicKey: users[0].publicKey.serialize(),
|
|
1025
1034
|
stateIndex: 1n,
|
|
1026
1035
|
voteOptionIndex: 0n,
|
|
1027
1036
|
nonce: 1n,
|
|
1028
1037
|
pollId: 1n,
|
|
1029
1038
|
newVoteWeight: 7n,
|
|
1030
1039
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1031
|
-
salt: (0, crypto_1.
|
|
1032
|
-
privateKey: users[0].
|
|
1040
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
1041
|
+
privateKey: users[0].privateKey.serialize(),
|
|
1033
1042
|
signer,
|
|
1034
1043
|
});
|
|
1035
1044
|
});
|
|
1036
1045
|
it("should publish a new message by the new poll voters", async () => {
|
|
1037
1046
|
await (0, sdk_1.publish)({
|
|
1038
|
-
|
|
1047
|
+
publicKey: users[1].publicKey.serialize(),
|
|
1039
1048
|
stateIndex: 1n,
|
|
1040
1049
|
voteOptionIndex: 0n,
|
|
1041
1050
|
nonce: 1n,
|
|
1042
1051
|
pollId: 1n,
|
|
1043
1052
|
newVoteWeight: 7n,
|
|
1044
1053
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1045
|
-
salt: (0, crypto_1.
|
|
1046
|
-
privateKey: users[1].
|
|
1054
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
1055
|
+
privateKey: users[1].privateKey.serialize(),
|
|
1047
1056
|
signer,
|
|
1048
1057
|
});
|
|
1049
1058
|
});
|
|
@@ -1084,6 +1093,12 @@ describe("e2e tests", function test() {
|
|
|
1084
1093
|
signer,
|
|
1085
1094
|
signupPolicyAddress: signupPolicyContractAddress,
|
|
1086
1095
|
});
|
|
1096
|
+
// we set the verifying keys
|
|
1097
|
+
const { verifyingKeysRegistryContractAddress } = maciAddresses;
|
|
1098
|
+
await (0, sdk_1.setVerifyingKeys)({
|
|
1099
|
+
...(await (0, constants_1.verifyingKeysArgs)(signer)),
|
|
1100
|
+
verifyingKeysRegistryAddress: verifyingKeysRegistryContractAddress,
|
|
1101
|
+
});
|
|
1087
1102
|
});
|
|
1088
1103
|
it("should run the first poll", async () => {
|
|
1089
1104
|
const [pollPolicy] = await (0, sdk_1.deployFreeForAllSignUpPolicy)({}, signer, true);
|
|
@@ -1097,8 +1112,6 @@ describe("e2e tests", function test() {
|
|
|
1097
1112
|
pollEndTimestamp: startDate + constants_1.pollDuration,
|
|
1098
1113
|
relayers: [await signer.getAddress()],
|
|
1099
1114
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1100
|
-
verifierContractAddress,
|
|
1101
|
-
vkRegistryContractAddress: vkRegistryAddress,
|
|
1102
1115
|
policyContractAddress: pollPolicyContractAddress,
|
|
1103
1116
|
initialVoiceCreditProxyContractAddress,
|
|
1104
1117
|
});
|
|
@@ -1108,14 +1121,14 @@ describe("e2e tests", function test() {
|
|
|
1108
1121
|
// eslint-disable-next-line no-await-in-loop
|
|
1109
1122
|
await (0, sdk_1.signup)({
|
|
1110
1123
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1111
|
-
|
|
1124
|
+
maciPublicKey: users[i].publicKey.serialize(),
|
|
1112
1125
|
sgData: constants_1.DEFAULT_SG_DATA,
|
|
1113
|
-
signer,
|
|
1126
|
+
signer: userSigners[i],
|
|
1114
1127
|
});
|
|
1115
1128
|
// eslint-disable-next-line no-await-in-loop
|
|
1116
1129
|
const { isRegistered, stateIndex } = await (0, sdk_1.getSignedupUserData)({
|
|
1117
1130
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1118
|
-
|
|
1131
|
+
maciPublicKey: users[i].publicKey.serialize(),
|
|
1119
1132
|
signer,
|
|
1120
1133
|
});
|
|
1121
1134
|
(0, chai_1.expect)(isRegistered).to.eq(true);
|
|
@@ -1127,23 +1140,22 @@ describe("e2e tests", function test() {
|
|
|
1127
1140
|
// eslint-disable-next-line no-await-in-loop
|
|
1128
1141
|
await (0, sdk_1.joinPoll)({
|
|
1129
1142
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1130
|
-
privateKey: users[i].
|
|
1131
|
-
stateIndex: BigInt(i + 1),
|
|
1143
|
+
privateKey: users[i].privateKey.serialize(),
|
|
1132
1144
|
pollId: 0n,
|
|
1133
|
-
pollJoiningZkey: constants_1.
|
|
1134
|
-
useWasm
|
|
1135
|
-
|
|
1136
|
-
|
|
1145
|
+
pollJoiningZkey: constants_1.testPollJoiningZkeyPath,
|
|
1146
|
+
useWasm,
|
|
1147
|
+
pollJoiningWasm: constants_1.testPollJoiningWasmPath,
|
|
1148
|
+
pollWitnessGenerator: constants_1.testPollJoiningWitnessPath,
|
|
1137
1149
|
rapidsnark: constants_1.testRapidsnarkPath,
|
|
1138
1150
|
sgDataArg: constants_1.DEFAULT_SG_DATA,
|
|
1139
1151
|
ivcpDataArg: constants_1.DEFAULT_IVCP_DATA,
|
|
1140
|
-
signer,
|
|
1152
|
+
signer: userSigners[i],
|
|
1141
1153
|
});
|
|
1142
1154
|
// eslint-disable-next-line no-await-in-loop
|
|
1143
1155
|
const { isJoined, pollStateIndex } = await (0, sdk_1.getJoinedUserData)({
|
|
1144
1156
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1145
1157
|
pollId: 0n,
|
|
1146
|
-
|
|
1158
|
+
pollPublicKey: users[i].publicKey.serialize(),
|
|
1147
1159
|
signer,
|
|
1148
1160
|
startBlock: 0,
|
|
1149
1161
|
});
|
|
@@ -1152,29 +1164,29 @@ describe("e2e tests", function test() {
|
|
|
1152
1164
|
}
|
|
1153
1165
|
// publish
|
|
1154
1166
|
await (0, sdk_1.publish)({
|
|
1155
|
-
|
|
1167
|
+
publicKey: users[0].publicKey.serialize(),
|
|
1156
1168
|
stateIndex: 1n,
|
|
1157
1169
|
voteOptionIndex: 0n,
|
|
1158
1170
|
nonce: 1n,
|
|
1159
1171
|
pollId: 0n,
|
|
1160
1172
|
newVoteWeight: 9n,
|
|
1161
1173
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1162
|
-
salt: (0, crypto_1.
|
|
1163
|
-
privateKey: users[0].
|
|
1174
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
1175
|
+
privateKey: users[0].privateKey.serialize(),
|
|
1164
1176
|
signer,
|
|
1165
1177
|
});
|
|
1166
1178
|
const votes = [
|
|
1167
1179
|
{
|
|
1168
1180
|
pollId: 0n,
|
|
1169
1181
|
voteOptionIndex: 0n,
|
|
1170
|
-
salt: (0, crypto_1.
|
|
1182
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
1171
1183
|
nonce: 1n,
|
|
1172
|
-
privateKey: users[0].
|
|
1184
|
+
privateKey: users[0].privateKey,
|
|
1173
1185
|
stateIndex: 1n,
|
|
1174
1186
|
voteWeight: 5n,
|
|
1175
|
-
|
|
1187
|
+
coordinatorPublicKey: constants_1.coordinatorKeypair.publicKey,
|
|
1176
1188
|
maxVoteOption: BigInt(core_1.VOTE_OPTION_TREE_ARITY ** constants_1.deployPollArgs.voteOptionTreeDepth),
|
|
1177
|
-
|
|
1189
|
+
newPublicKey: users[0].publicKey,
|
|
1178
1190
|
},
|
|
1179
1191
|
];
|
|
1180
1192
|
const messages = votes
|
|
@@ -1183,8 +1195,8 @@ describe("e2e tests", function test() {
|
|
|
1183
1195
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1184
1196
|
poll: 0,
|
|
1185
1197
|
data: message.data.map(String),
|
|
1186
|
-
publicKey: ephemeralKeypair.
|
|
1187
|
-
hash: message.hash(ephemeralKeypair.
|
|
1198
|
+
publicKey: ephemeralKeypair.publicKey.asArray().map(String),
|
|
1199
|
+
hash: message.hash(ephemeralKeypair.publicKey).toString(),
|
|
1188
1200
|
}));
|
|
1189
1201
|
await (0, utils_1.relayTestMessages)({ messages, signer, pollId: 0, maciAddress: maciAddresses.maciContractAddress });
|
|
1190
1202
|
const ipfsMessageBackupFiles = await (0, utils_1.getBackupFilenames)();
|
|
@@ -1215,8 +1227,6 @@ describe("e2e tests", function test() {
|
|
|
1215
1227
|
pollEndTimestamp: startDate + constants_1.pollDuration,
|
|
1216
1228
|
relayers: [await signer.getAddress()],
|
|
1217
1229
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1218
|
-
verifierContractAddress,
|
|
1219
|
-
vkRegistryContractAddress: vkRegistryAddress,
|
|
1220
1230
|
policyContractAddress: pollPolicyContractAddress,
|
|
1221
1231
|
initialVoiceCreditProxyContractAddress,
|
|
1222
1232
|
});
|
|
@@ -1232,8 +1242,6 @@ describe("e2e tests", function test() {
|
|
|
1232
1242
|
pollEndTimestamp: startDate + constants_1.pollDuration,
|
|
1233
1243
|
relayers: [await signer.getAddress()],
|
|
1234
1244
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1235
|
-
verifierContractAddress,
|
|
1236
|
-
vkRegistryContractAddress: vkRegistryAddress,
|
|
1237
1245
|
policyContractAddress: pollPolicyContractAddress,
|
|
1238
1246
|
initialVoiceCreditProxyContractAddress,
|
|
1239
1247
|
});
|
|
@@ -1241,28 +1249,28 @@ describe("e2e tests", function test() {
|
|
|
1241
1249
|
});
|
|
1242
1250
|
it("join the second and third polls", async () => {
|
|
1243
1251
|
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
1244
|
-
for (let
|
|
1252
|
+
for (let pollId = 1; pollId <= 2; pollId += 1) {
|
|
1253
|
+
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
1245
1254
|
for (let i = 0; i < users.length; i += 1) {
|
|
1246
1255
|
// eslint-disable-next-line no-await-in-loop
|
|
1247
1256
|
await (0, sdk_1.joinPoll)({
|
|
1248
1257
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1249
|
-
privateKey: users[i].
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
pollWitgen: constants_1.testPollJoiningWitnessPath,
|
|
1258
|
+
privateKey: users[i].privateKey.serialize(),
|
|
1259
|
+
pollId: BigInt(pollId),
|
|
1260
|
+
pollJoiningZkey: constants_1.testPollJoiningZkeyPath,
|
|
1261
|
+
useWasm,
|
|
1262
|
+
pollJoiningWasm: constants_1.testPollJoiningWasmPath,
|
|
1263
|
+
pollWitnessGenerator: constants_1.testPollJoiningWitnessPath,
|
|
1256
1264
|
rapidsnark: constants_1.testRapidsnarkPath,
|
|
1257
1265
|
sgDataArg: constants_1.DEFAULT_SG_DATA,
|
|
1258
1266
|
ivcpDataArg: constants_1.DEFAULT_IVCP_DATA,
|
|
1259
|
-
signer,
|
|
1267
|
+
signer: userSigners[i],
|
|
1260
1268
|
});
|
|
1261
1269
|
// eslint-disable-next-line no-await-in-loop
|
|
1262
1270
|
const { isJoined, pollStateIndex } = await (0, sdk_1.getJoinedUserData)({
|
|
1263
1271
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1264
|
-
pollId: BigInt(
|
|
1265
|
-
|
|
1272
|
+
pollId: BigInt(pollId),
|
|
1273
|
+
pollPublicKey: users[i].publicKey.serialize(),
|
|
1266
1274
|
signer,
|
|
1267
1275
|
startBlock: 0,
|
|
1268
1276
|
});
|
|
@@ -1273,39 +1281,39 @@ describe("e2e tests", function test() {
|
|
|
1273
1281
|
});
|
|
1274
1282
|
it("should publish messages to the second poll", async () => {
|
|
1275
1283
|
await (0, sdk_1.publish)({
|
|
1276
|
-
|
|
1284
|
+
publicKey: users[0].publicKey.serialize(),
|
|
1277
1285
|
stateIndex: 1n,
|
|
1278
1286
|
voteOptionIndex: 0n,
|
|
1279
1287
|
nonce: 1n,
|
|
1280
1288
|
pollId: 1n,
|
|
1281
1289
|
newVoteWeight: 9n,
|
|
1282
1290
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1283
|
-
salt: (0, crypto_1.
|
|
1284
|
-
privateKey: users[0].
|
|
1291
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
1292
|
+
privateKey: users[0].privateKey.serialize(),
|
|
1285
1293
|
signer,
|
|
1286
1294
|
});
|
|
1287
1295
|
await (0, sdk_1.publish)({
|
|
1288
|
-
|
|
1296
|
+
publicKey: users[1].publicKey.serialize(),
|
|
1289
1297
|
stateIndex: 2n,
|
|
1290
1298
|
voteOptionIndex: 3n,
|
|
1291
1299
|
nonce: 1n,
|
|
1292
1300
|
pollId: 1n,
|
|
1293
1301
|
newVoteWeight: 1n,
|
|
1294
1302
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1295
|
-
salt: (0, crypto_1.
|
|
1296
|
-
privateKey: users[1].
|
|
1303
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
1304
|
+
privateKey: users[1].privateKey.serialize(),
|
|
1297
1305
|
signer,
|
|
1298
1306
|
});
|
|
1299
1307
|
await (0, sdk_1.publish)({
|
|
1300
|
-
|
|
1308
|
+
publicKey: users[2].publicKey.serialize(),
|
|
1301
1309
|
stateIndex: 3n,
|
|
1302
1310
|
voteOptionIndex: 5n,
|
|
1303
1311
|
nonce: 1n,
|
|
1304
1312
|
pollId: 1n,
|
|
1305
1313
|
newVoteWeight: 3n,
|
|
1306
1314
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1307
|
-
salt: (0, crypto_1.
|
|
1308
|
-
privateKey: users[2].
|
|
1315
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
1316
|
+
privateKey: users[2].privateKey.serialize(),
|
|
1309
1317
|
signer,
|
|
1310
1318
|
});
|
|
1311
1319
|
});
|
|
@@ -1314,14 +1322,14 @@ describe("e2e tests", function test() {
|
|
|
1314
1322
|
{
|
|
1315
1323
|
pollId: 1n,
|
|
1316
1324
|
voteOptionIndex: 0n,
|
|
1317
|
-
salt: (0, crypto_1.
|
|
1325
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
1318
1326
|
nonce: 1n,
|
|
1319
|
-
privateKey: users[0].
|
|
1327
|
+
privateKey: users[0].privateKey,
|
|
1320
1328
|
stateIndex: 1n,
|
|
1321
1329
|
voteWeight: 3n,
|
|
1322
|
-
|
|
1330
|
+
coordinatorPublicKey: constants_1.coordinatorKeypair.publicKey,
|
|
1323
1331
|
maxVoteOption: BigInt(core_1.VOTE_OPTION_TREE_ARITY ** constants_1.deployPollArgs.voteOptionTreeDepth),
|
|
1324
|
-
|
|
1332
|
+
newPublicKey: users[0].publicKey,
|
|
1325
1333
|
},
|
|
1326
1334
|
];
|
|
1327
1335
|
const messages = votes
|
|
@@ -1330,8 +1338,8 @@ describe("e2e tests", function test() {
|
|
|
1330
1338
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1331
1339
|
poll: 1,
|
|
1332
1340
|
data: message.data.map(String),
|
|
1333
|
-
publicKey: ephemeralKeypair.
|
|
1334
|
-
hash: message.hash(ephemeralKeypair.
|
|
1341
|
+
publicKey: ephemeralKeypair.publicKey.asArray().map(String),
|
|
1342
|
+
hash: message.hash(ephemeralKeypair.publicKey).toString(),
|
|
1335
1343
|
}));
|
|
1336
1344
|
await (0, utils_1.relayTestMessages)({ messages, signer, pollId: 1, maciAddress: maciAddresses.maciContractAddress });
|
|
1337
1345
|
});
|
|
@@ -1340,26 +1348,26 @@ describe("e2e tests", function test() {
|
|
|
1340
1348
|
{
|
|
1341
1349
|
pollId: 2n,
|
|
1342
1350
|
voteOptionIndex: 7n,
|
|
1343
|
-
salt: (0, crypto_1.
|
|
1351
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
1344
1352
|
nonce: 1n,
|
|
1345
|
-
privateKey: users[4].
|
|
1353
|
+
privateKey: users[4].privateKey,
|
|
1346
1354
|
stateIndex: 4n,
|
|
1347
1355
|
voteWeight: 3n,
|
|
1348
|
-
|
|
1356
|
+
coordinatorPublicKey: constants_1.coordinatorKeypair.publicKey,
|
|
1349
1357
|
maxVoteOption: BigInt(core_1.VOTE_OPTION_TREE_ARITY ** constants_1.deployPollArgs.voteOptionTreeDepth),
|
|
1350
|
-
|
|
1358
|
+
newPublicKey: users[4].publicKey,
|
|
1351
1359
|
},
|
|
1352
1360
|
{
|
|
1353
1361
|
pollId: 2n,
|
|
1354
1362
|
voteOptionIndex: 5n,
|
|
1355
|
-
salt: (0, crypto_1.
|
|
1363
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
1356
1364
|
nonce: 1n,
|
|
1357
|
-
privateKey: users[5].
|
|
1365
|
+
privateKey: users[5].privateKey,
|
|
1358
1366
|
stateIndex: 5n,
|
|
1359
1367
|
voteWeight: 4n,
|
|
1360
|
-
|
|
1368
|
+
coordinatorPublicKey: constants_1.coordinatorKeypair.publicKey,
|
|
1361
1369
|
maxVoteOption: BigInt(core_1.VOTE_OPTION_TREE_ARITY ** constants_1.deployPollArgs.voteOptionTreeDepth),
|
|
1362
|
-
|
|
1370
|
+
newPublicKey: users[5].publicKey,
|
|
1363
1371
|
},
|
|
1364
1372
|
];
|
|
1365
1373
|
const messages = votes
|
|
@@ -1368,46 +1376,46 @@ describe("e2e tests", function test() {
|
|
|
1368
1376
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1369
1377
|
poll: 2,
|
|
1370
1378
|
data: message.data.map(String),
|
|
1371
|
-
publicKey: ephemeralKeypair.
|
|
1372
|
-
hash: message.hash(ephemeralKeypair.
|
|
1379
|
+
publicKey: ephemeralKeypair.publicKey.asArray().map(String),
|
|
1380
|
+
hash: message.hash(ephemeralKeypair.publicKey).toString(),
|
|
1373
1381
|
}));
|
|
1374
1382
|
await (0, utils_1.relayTestMessages)({ messages, signer, pollId: 2, maciAddress: maciAddresses.maciContractAddress });
|
|
1375
1383
|
});
|
|
1376
1384
|
it("should publish messages to the third poll", async () => {
|
|
1377
1385
|
await (0, sdk_1.publish)({
|
|
1378
|
-
|
|
1386
|
+
publicKey: users[3].publicKey.serialize(),
|
|
1379
1387
|
stateIndex: 3n,
|
|
1380
1388
|
voteOptionIndex: 5n,
|
|
1381
1389
|
nonce: 1n,
|
|
1382
1390
|
pollId: 2n,
|
|
1383
1391
|
newVoteWeight: 3n,
|
|
1384
1392
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1385
|
-
salt: (0, crypto_1.
|
|
1386
|
-
privateKey: users[3].
|
|
1393
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
1394
|
+
privateKey: users[3].privateKey.serialize(),
|
|
1387
1395
|
signer,
|
|
1388
1396
|
});
|
|
1389
1397
|
await (0, sdk_1.publish)({
|
|
1390
|
-
|
|
1398
|
+
publicKey: users[4].publicKey.serialize(),
|
|
1391
1399
|
stateIndex: 4n,
|
|
1392
1400
|
voteOptionIndex: 7n,
|
|
1393
1401
|
nonce: 1n,
|
|
1394
1402
|
pollId: 2n,
|
|
1395
1403
|
newVoteWeight: 2n,
|
|
1396
1404
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1397
|
-
salt: (0, crypto_1.
|
|
1398
|
-
privateKey: users[4].
|
|
1405
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
1406
|
+
privateKey: users[4].privateKey.serialize(),
|
|
1399
1407
|
signer,
|
|
1400
1408
|
});
|
|
1401
1409
|
await (0, sdk_1.publish)({
|
|
1402
|
-
|
|
1410
|
+
publicKey: users[5].publicKey.serialize(),
|
|
1403
1411
|
stateIndex: 5n,
|
|
1404
1412
|
voteOptionIndex: 5n,
|
|
1405
1413
|
nonce: 1n,
|
|
1406
1414
|
pollId: 2n,
|
|
1407
1415
|
newVoteWeight: 9n,
|
|
1408
1416
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1409
|
-
salt: (0, crypto_1.
|
|
1410
|
-
privateKey: users[5].
|
|
1417
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
1418
|
+
privateKey: users[5].privateKey.serialize(),
|
|
1411
1419
|
signer,
|
|
1412
1420
|
});
|
|
1413
1421
|
});
|
|
@@ -1480,6 +1488,12 @@ describe("e2e tests", function test() {
|
|
|
1480
1488
|
signer,
|
|
1481
1489
|
signupPolicyAddress: signupPolicyContractAddress,
|
|
1482
1490
|
});
|
|
1491
|
+
// we set the verifying keys
|
|
1492
|
+
const { verifyingKeysRegistryContractAddress } = maciAddresses;
|
|
1493
|
+
await (0, sdk_1.setVerifyingKeys)({
|
|
1494
|
+
...(await (0, constants_1.verifyingKeysArgs)(signer)),
|
|
1495
|
+
verifyingKeysRegistryAddress: verifyingKeysRegistryContractAddress,
|
|
1496
|
+
});
|
|
1483
1497
|
const startDate = await (0, sdk_1.getBlockTimestamp)(signer);
|
|
1484
1498
|
// deploy a poll contract
|
|
1485
1499
|
await (0, sdk_1.deployPoll)({
|
|
@@ -1489,8 +1503,6 @@ describe("e2e tests", function test() {
|
|
|
1489
1503
|
pollEndTimestamp: startDate + constants_1.pollDuration,
|
|
1490
1504
|
relayers: [await signer.getAddress()],
|
|
1491
1505
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1492
|
-
verifierContractAddress,
|
|
1493
|
-
vkRegistryContractAddress: vkRegistryAddress,
|
|
1494
1506
|
policyContractAddress: pollPolicyContractAddress,
|
|
1495
1507
|
initialVoiceCreditProxyContractAddress,
|
|
1496
1508
|
});
|
|
@@ -1498,7 +1510,7 @@ describe("e2e tests", function test() {
|
|
|
1498
1510
|
it("should signup one user", async () => {
|
|
1499
1511
|
await (0, sdk_1.signup)({
|
|
1500
1512
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1501
|
-
|
|
1513
|
+
maciPublicKey: user.publicKey.serialize(),
|
|
1502
1514
|
sgData: constants_1.DEFAULT_SG_DATA,
|
|
1503
1515
|
signer,
|
|
1504
1516
|
});
|
|
@@ -1507,13 +1519,12 @@ describe("e2e tests", function test() {
|
|
|
1507
1519
|
// joinPoll
|
|
1508
1520
|
await (0, sdk_1.joinPoll)({
|
|
1509
1521
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1510
|
-
privateKey: user.
|
|
1511
|
-
stateIndex: 1n,
|
|
1522
|
+
privateKey: user.privateKey.serialize(),
|
|
1512
1523
|
pollId: 0n,
|
|
1513
|
-
pollJoiningZkey: constants_1.
|
|
1514
|
-
useWasm
|
|
1515
|
-
|
|
1516
|
-
|
|
1524
|
+
pollJoiningZkey: constants_1.testPollJoiningZkeyPath,
|
|
1525
|
+
useWasm,
|
|
1526
|
+
pollJoiningWasm: constants_1.testPollJoiningWasmPath,
|
|
1527
|
+
pollWitnessGenerator: constants_1.testPollJoiningWitnessPath,
|
|
1517
1528
|
rapidsnark: constants_1.testRapidsnarkPath,
|
|
1518
1529
|
sgDataArg: constants_1.DEFAULT_SG_DATA,
|
|
1519
1530
|
ivcpDataArg: constants_1.DEFAULT_IVCP_DATA,
|
|
@@ -1522,15 +1533,15 @@ describe("e2e tests", function test() {
|
|
|
1522
1533
|
});
|
|
1523
1534
|
it("should publish one message", async () => {
|
|
1524
1535
|
await (0, sdk_1.publish)({
|
|
1525
|
-
|
|
1536
|
+
publicKey: user.publicKey.serialize(),
|
|
1526
1537
|
stateIndex: 1n,
|
|
1527
1538
|
voteOptionIndex: 5n,
|
|
1528
1539
|
nonce: 1n,
|
|
1529
1540
|
pollId: 0n,
|
|
1530
1541
|
newVoteWeight: 3n,
|
|
1531
1542
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1532
|
-
salt: (0, crypto_1.
|
|
1533
|
-
privateKey: user.
|
|
1543
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
1544
|
+
privateKey: user.privateKey.serialize(),
|
|
1534
1545
|
signer,
|
|
1535
1546
|
});
|
|
1536
1547
|
});
|
|
@@ -1539,14 +1550,14 @@ describe("e2e tests", function test() {
|
|
|
1539
1550
|
{
|
|
1540
1551
|
pollId: 0n,
|
|
1541
1552
|
voteOptionIndex: 5n,
|
|
1542
|
-
salt: (0, crypto_1.
|
|
1553
|
+
salt: (0, crypto_1.generateRandomSalt)(),
|
|
1543
1554
|
nonce: 1n,
|
|
1544
|
-
privateKey: user.
|
|
1555
|
+
privateKey: user.privateKey,
|
|
1545
1556
|
stateIndex: 1n,
|
|
1546
1557
|
voteWeight: 5n,
|
|
1547
|
-
|
|
1558
|
+
coordinatorPublicKey: constants_1.coordinatorKeypair.publicKey,
|
|
1548
1559
|
maxVoteOption: BigInt(core_1.VOTE_OPTION_TREE_ARITY ** constants_1.deployPollArgs.voteOptionTreeDepth),
|
|
1549
|
-
|
|
1560
|
+
newPublicKey: user.publicKey,
|
|
1550
1561
|
},
|
|
1551
1562
|
];
|
|
1552
1563
|
const messages = votes
|
|
@@ -1555,8 +1566,8 @@ describe("e2e tests", function test() {
|
|
|
1555
1566
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1556
1567
|
poll: 0,
|
|
1557
1568
|
data: message.data.map(String),
|
|
1558
|
-
publicKey: ephemeralKeypair.
|
|
1559
|
-
hash: message.hash(ephemeralKeypair.
|
|
1569
|
+
publicKey: ephemeralKeypair.publicKey.asArray().map(String),
|
|
1570
|
+
hash: message.hash(ephemeralKeypair.publicKey).toString(),
|
|
1560
1571
|
}));
|
|
1561
1572
|
await (0, utils_1.relayTestMessages)({ messages, signer, pollId: 0, maciAddress: maciAddresses.maciContractAddress });
|
|
1562
1573
|
});
|
|
@@ -1567,7 +1578,7 @@ describe("e2e tests", function test() {
|
|
|
1567
1578
|
await (0, sdk_1.generateMaciState)({
|
|
1568
1579
|
maciAddress: maciAddresses.maciContractAddress,
|
|
1569
1580
|
outputPath: stateOutPath,
|
|
1570
|
-
coordinatorPrivateKey: constants_1.
|
|
1581
|
+
coordinatorPrivateKey: constants_1.coordinatorPrivateKey,
|
|
1571
1582
|
blockPerBatch: 50,
|
|
1572
1583
|
pollId: 0n,
|
|
1573
1584
|
signer,
|