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