From bcf6d95e265365687edb59f256ae579a6a43ce15 Mon Sep 17 00:00:00 2001 From: ctrlc03 <93448202+ctrlc03@users.noreply.github.com> Date: Sun, 7 Jan 2024 19:48:59 +0000 Subject: [PATCH] test(cli): reorganize e2e tests and add more tests for cli commands --- cli/package.json | 16 +- cli/tests/{ => e2e}/e2e.subsidy.test.ts | 647 +----------------- cli/tests/{ => e2e}/e2e.test.ts | 420 +++--------- cli/tests/{ => e2e}/keyChange.test.ts | 9 +- cli/tests/unit/airdrop.test.ts | 26 + cli/tests/unit/data/testVk.json | 94 +++ cli/tests/unit/fundWallet.test.ts | 16 + .../tests/unit/genKeyPair.test.ts | 3 +- .../tests/unit/genPubkey.test.ts | 9 +- cli/tests/unit/timeTravel.test.ts | 16 + cli/tests/unit/topup.test.ts | 47 ++ cli/tests/unit/utils.test.ts | 36 + contracts/hardhat.config.ts | 1 + .../ts/__tests__/artifacts/test_vk.json | 124 ++-- integrationTests/package.json | 4 +- 15 files changed, 426 insertions(+), 1042 deletions(-) rename cli/tests/{ => e2e}/e2e.subsidy.test.ts (50%) rename cli/tests/{ => e2e}/e2e.test.ts (82%) rename cli/tests/{ => e2e}/keyChange.test.ts (98%) create mode 100644 cli/tests/unit/airdrop.test.ts create mode 100644 cli/tests/unit/data/testVk.json create mode 100644 cli/tests/unit/fundWallet.test.ts rename integrationTests/ts/__tests__/cli-genMaciKeypair.test.ts => cli/tests/unit/genKeyPair.test.ts (96%) rename integrationTests/ts/__tests__/cli-genMaciPubkey.test.ts => cli/tests/unit/genPubkey.test.ts (72%) create mode 100644 cli/tests/unit/timeTravel.test.ts create mode 100644 cli/tests/unit/topup.test.ts create mode 100644 cli/tests/unit/utils.test.ts diff --git a/cli/package.json b/cli/package.json index b2c229c2cc..193caffe99 100644 --- a/cli/package.json +++ b/cli/package.json @@ -14,10 +14,17 @@ "watch": "tsc --watch", "build": "tsc", "postbuild": "cp package.json ./build", - "test": "nyc ts-mocha --exit tests/*.test.ts", + "test": "nyc ts-mocha --exit tests/**/*.test.ts", "test:e2e": "ts-mocha --exit tests/e2e.test.ts", "test:e2e-subsidy": "ts-mocha --exit tests/e2e.subsidy.test.ts", - "test:keyChange": "ts-mocha --exit tests/keyChange.test.ts" + "test:keyChange": "ts-mocha --exit tests/keyChange.test.ts", + "test:unit": "nyc ts-mocha --exit tests/unit/*.test.ts", + "test:airdrop": "nyc ts-mocha --exit tests/unit/airdrop.test.ts", + "test:genPubKey": "ts-mocha --exit tests/unit/genPubKey.test.ts", + "test:genKeypair": "ts-mocha --exit tests/unit/genKeyPair.test.ts", + "test:timeTravel": "ts-mocha --exit tests/unit/timeTravel.test.ts", + "test:fundWallet": "ts-mocha --exit tests/unit/fundWallet.test.ts", + "test:utils": "ts-mocha --exit tests/unit/utils.test.ts" }, "dependencies": { "@commander-js/extra-typings": "^11.1.0", @@ -57,10 +64,11 @@ ], "all": true, "exclude": [ - "**/tests/*.ts", "**/*.js", "**/*.d.ts", - "hardhat.config.ts" + "hardhat.config.ts", + "tests/**/*.ts", + "ts/index.ts" ], "branches": ">50%", "lines": ">50%", diff --git a/cli/tests/e2e.subsidy.test.ts b/cli/tests/e2e/e2e.subsidy.test.ts similarity index 50% rename from cli/tests/e2e.subsidy.test.ts rename to cli/tests/e2e/e2e.subsidy.test.ts index 45f23bf784..fc8d3afbf2 100644 --- a/cli/tests/e2e.subsidy.test.ts +++ b/cli/tests/e2e/e2e.subsidy.test.ts @@ -15,9 +15,8 @@ import { signup, timeTravel, verify, -} from "../ts/commands"; -import { DeployedContracts, PollContracts } from "../ts/utils"; - +} from "../../ts/commands"; +import { DeployedContracts, PollContracts } from "../../ts/utils"; import { INT_STATE_TREE_DEPTH, MSG_BATCH_DEPTH, @@ -42,8 +41,8 @@ import { testTallyFilePath, testTallyVotesWasmPath, testTallyVotesWitnessPath, -} from "./constants"; -import { cleanSubsidy, isArm } from "./utils"; +} from "../constants"; +import { cleanSubsidy, isArm } from "../utils"; describe("e2e with Subsidy tests", function test() { const useWasm = isArm(); @@ -69,85 +68,8 @@ describe("e2e with Subsidy tests", function test() { subsidyTestZkeyPath, ); }); - describe("test1", () => { - const user1Key = new Keypair(); - - after(() => { - cleanSubsidy(); - }); - - before(async () => { - // deploy the smart contracts - maciAddresses = await deploy(STATE_TREE_DEPTH); - // deploy a poll contract - pollAddresses = await deployPoll( - pollDuration, - maxMessages, - maxVoteOptions, - INT_STATE_TREE_DEPTH, - MSG_BATCH_DEPTH, - MSG_TREE_DEPTH, - VOTE_OPTION_TREE_DEPTH, - coordinatorPubKey, - ); - }); - - it("should signup one user", async () => { - await signup(user1Key.pubKey.serialize()); - }); - - it("should publish one message", async () => { - await publish( - user1Key.pubKey.serialize(), - 1, - 0, - 1, - 0, - 9, - maciAddresses.maciAddress, - genRandomSalt().toString(), - user1Key.privKey.serialize(), - ); - }); - - it("should generate zk-SNARK proofs and verify them", async () => { - await timeTravel(pollDuration, true); - await mergeMessages(0); - await mergeSignups(0); - const tallyData = await genProofs( - testProofsDirPath, - testTallyFilePath, - tallyVotesTestZkeyPath, - processMessageTestZkeyPath, - 0, - testSubsidyFilePath, - subsidyTestZkeyPath, - testRapidsnarkPath, - testProcessMessagesWitnessPath, - testTallyVotesWitnessPath, - testSubsidyWitnessPath, - coordinatorPrivKey, - maciAddresses.maciAddress, - undefined, - testProcessMessagesWasmPath, - testTallyVotesWasmPath, - testSubsidyWasmPath, - useWasm, - ); - await proveOnChain("0", testProofsDirPath); - await verify( - "0", - testTallyFilePath, - tallyData, - maciAddresses.maciAddress, - pollAddresses.tally, - pollAddresses.subsidy, - testSubsidyFilePath, - ); - }); - }); - describe("test2", () => { + describe("4 signups, 6 messages", () => { after(() => { cleanSubsidy(); }); @@ -284,7 +206,7 @@ describe("e2e with Subsidy tests", function test() { }); }); - describe("test3", () => { + describe("9 signups, 1 message", () => { after(() => { cleanSubsidy(); }); @@ -376,7 +298,7 @@ describe("e2e with Subsidy tests", function test() { }); }); - describe("test4", () => { + describe("8 signups (same key), 12 messages (same message)", () => { after(() => { cleanSubsidy(); }); @@ -460,561 +382,6 @@ describe("e2e with Subsidy tests", function test() { }); }); - describe("test5", () => { - after(() => { - cleanSubsidy(); - }); - - const users = [new Keypair(), new Keypair(), new Keypair(), new Keypair()]; - - before(async () => { - // deploy the smart contracts - maciAddresses = await deploy(STATE_TREE_DEPTH); - // deploy a poll contract - pollAddresses = await deployPoll( - pollDuration, - maxMessages, - maxVoteOptions, - INT_STATE_TREE_DEPTH, - MSG_BATCH_DEPTH, - MSG_TREE_DEPTH, - VOTE_OPTION_TREE_DEPTH, - coordinatorPubKey, - ); - }); - - it("should signup four users", async () => { - // eslint-disable-next-line @typescript-eslint/prefer-for-of - for (let i = 0; i < users.length; i += 1) { - // eslint-disable-next-line no-await-in-loop - await signup(users[i].pubKey.serialize()); - } - }); - - it("should publish four messages", async () => { - await publish( - users[0].pubKey.serialize(), - 1, - 0, - 1, - 0, - 9, - maciAddresses.maciAddress, - genRandomSalt().toString(), - users[0].privKey.serialize(), - ); - await publish( - users[1].pubKey.serialize(), - 2, - 1, - 1, - 0, - 9, - maciAddresses.maciAddress, - genRandomSalt().toString(), - users[1].privKey.serialize(), - ); - await publish( - users[2].pubKey.serialize(), - 3, - 2, - 1, - 0, - 9, - maciAddresses.maciAddress, - genRandomSalt().toString(), - users[2].privKey.serialize(), - ); - await publish( - users[3].pubKey.serialize(), - 4, - 3, - 1, - 0, - 9, - maciAddresses.maciAddress, - genRandomSalt().toString(), - users[0].privKey.serialize(), - ); - }); - - it("should generate zk-SNARK proofs and verify them", async () => { - await timeTravel(pollDuration, true); - await mergeMessages(0); - await mergeSignups(0); - const tallyData = await genProofs( - testProofsDirPath, - testTallyFilePath, - tallyVotesTestZkeyPath, - processMessageTestZkeyPath, - 0, - testSubsidyFilePath, - subsidyTestZkeyPath, - testRapidsnarkPath, - testProcessMessagesWitnessPath, - testTallyVotesWitnessPath, - testSubsidyWitnessPath, - coordinatorPrivKey, - maciAddresses.maciAddress, - undefined, - testProcessMessagesWasmPath, - testTallyVotesWasmPath, - testSubsidyWasmPath, - useWasm, - ); - await proveOnChain("0", testProofsDirPath); - await verify( - "0", - testTallyFilePath, - tallyData, - maciAddresses.maciAddress, - pollAddresses.tally, - pollAddresses.subsidy, - testSubsidyFilePath, - ); - }); - }); - - describe("test6", () => { - after(() => { - cleanSubsidy(); - }); - - const users = [new Keypair(), new Keypair(), new Keypair(), new Keypair(), new Keypair()]; - - before(async () => { - // deploy the smart contracts - maciAddresses = await deploy(STATE_TREE_DEPTH); - // deploy a poll contract - pollAddresses = await deployPoll( - pollDuration, - maxMessages, - maxVoteOptions, - INT_STATE_TREE_DEPTH, - MSG_BATCH_DEPTH, - MSG_TREE_DEPTH, - VOTE_OPTION_TREE_DEPTH, - coordinatorPubKey, - ); - }); - - it("should signup five users", async () => { - // eslint-disable-next-line @typescript-eslint/prefer-for-of - for (let i = 0; i < users.length; i += 1) { - // eslint-disable-next-line no-await-in-loop - await signup(users[i].pubKey.serialize()); - } - }); - - it("should publish five messages", async () => { - await publish( - users[0].pubKey.serialize(), - 1, - 0, - 1, - 0, - 9, - maciAddresses.maciAddress, - genRandomSalt().toString(), - users[0].privKey.serialize(), - ); - await publish( - users[1].pubKey.serialize(), - 2, - 1, - 1, - 0, - 9, - maciAddresses.maciAddress, - genRandomSalt().toString(), - users[1].privKey.serialize(), - ); - await publish( - users[2].pubKey.serialize(), - 3, - 2, - 1, - 0, - 9, - maciAddresses.maciAddress, - genRandomSalt().toString(), - users[2].privKey.serialize(), - ); - await publish( - users[3].pubKey.serialize(), - 4, - 3, - 1, - 0, - 9, - maciAddresses.maciAddress, - genRandomSalt().toString(), - users[3].privKey.serialize(), - ); - await publish( - users[4].pubKey.serialize(), - 5, - 4, - 1, - 0, - 9, - maciAddresses.maciAddress, - genRandomSalt().toString(), - users[4].privKey.serialize(), - ); - }); - - it("should generate zk-SNARK proofs and verify them", async () => { - await timeTravel(pollDuration, true); - await mergeMessages(0); - await mergeSignups(0); - const tallyData = await genProofs( - testProofsDirPath, - testTallyFilePath, - tallyVotesTestZkeyPath, - processMessageTestZkeyPath, - 0, - testSubsidyFilePath, - subsidyTestZkeyPath, - testRapidsnarkPath, - testProcessMessagesWitnessPath, - testTallyVotesWitnessPath, - testSubsidyWitnessPath, - coordinatorPrivKey, - maciAddresses.maciAddress, - undefined, - testProcessMessagesWasmPath, - testTallyVotesWasmPath, - testSubsidyWasmPath, - useWasm, - ); - await proveOnChain("0", testProofsDirPath); - await verify( - "0", - testTallyFilePath, - tallyData, - maciAddresses.maciAddress, - pollAddresses.tally, - pollAddresses.subsidy, - testSubsidyFilePath, - ); - }); - }); - - describe("test7", () => { - after(() => { - cleanSubsidy(); - }); - - const user = new Keypair(); - - const publishArgs = [ - { - quiet: true, - pubkey: user.pubKey.serialize(), - privateKey: user.privKey.serialize(), - stateIndex: 6, - voteOptionIndex: 5, - nonce: 1, - newVoteWeight: 6, - pollId: 0, - }, - { - quiet: true, - pubkey: user.pubKey.serialize(), - privateKey: user.privKey.serialize(), - stateIndex: 5, - voteOptionIndex: 5, - nonce: 2, - newVoteWeight: 5, - pollId: 0, - }, - { - quiet: true, - pubkey: user.pubKey.serialize(), - privateKey: user.privKey.serialize(), - stateIndex: 5, - voteOptionIndex: 4, - nonce: 1, - pollId: 0, - newVoteWeight: 5, - }, - { - quiet: true, - pubkey: user.pubKey.serialize(), - privateKey: user.privKey.serialize(), - stateIndex: 4, - voteOptionIndex: 4, - nonce: 2, - pollId: 0, - newVoteWeight: 4, - }, - { - quiet: true, - pubkey: user.pubKey.serialize(), - privateKey: user.privKey.serialize(), - stateIndex: 4, - voteOptionIndex: 3, - nonce: 1, - pollId: 0, - newVoteWeight: 4, - }, - { - quiet: true, - pubkey: user.pubKey.serialize(), - privateKey: user.privKey.serialize(), - stateIndex: 3, - voteOptionIndex: 3, - nonce: 2, - pollId: 0, - newVoteWeight: 3, - }, - { - quiet: true, - pubkey: user.pubKey.serialize(), - privateKey: user.privKey.serialize(), - stateIndex: 2, - voteOptionIndex: 2, - nonce: 2, - pollId: 0, - newVoteWeight: 2, - }, - { - quiet: true, - pubkey: user.pubKey.serialize(), - privateKey: user.privKey.serialize(), - stateIndex: 2, - voteOptionIndex: 1, - nonce: 1, - pollId: 0, - newVoteWeight: 2, - }, - { - quiet: true, - pubkey: user.pubKey.serialize(), - privateKey: user.privKey.serialize(), - stateIndex: 1, - voteOptionIndex: 1, - nonce: 2, - pollId: 0, - newVoteWeight: 1, - }, - { - quiet: true, - pubkey: user.pubKey.serialize(), - privateKey: user.privKey.serialize(), - stateIndex: 1, - voteOptionIndex: 0, - nonce: 1, - pollId: 0, - newVoteWeight: 1, - }, - ]; - - before(async () => { - // deploy the smart contracts - maciAddresses = await deploy(STATE_TREE_DEPTH); - // deploy a poll contract - pollAddresses = await deployPoll( - pollDuration, - maxMessages, - maxVoteOptions, - INT_STATE_TREE_DEPTH, - MSG_BATCH_DEPTH, - MSG_TREE_DEPTH, - VOTE_OPTION_TREE_DEPTH, - coordinatorPubKey, - ); - }); - - it("should signup an user", async () => { - // eslint-disable-next-line @typescript-eslint/prefer-for-of - for (let i = 0; i < 6; i += 1) { - // eslint-disable-next-line no-await-in-loop - await signup(publishArgs[i].pubkey); - } - }); - - it("should publish all messages", async () => { - // eslint-disable-next-line @typescript-eslint/prefer-for-of - for (let i = 0; i < publishArgs.length; i += 1) { - // eslint-disable-next-line no-await-in-loop - await publish( - publishArgs[i].pubkey, - publishArgs[i].stateIndex, - publishArgs[i].voteOptionIndex, - publishArgs[i].nonce, - publishArgs[i].pollId, - publishArgs[i].newVoteWeight, - maciAddresses.maciAddress, - genRandomSalt().toString(), - publishArgs[i].privateKey, - ); - } - }); - - it("should generate zk-SNARK proofs and verify them", async () => { - await timeTravel(pollDuration, true); - await mergeMessages(0); - await mergeSignups(0); - const tallyData = await genProofs( - testProofsDirPath, - testTallyFilePath, - tallyVotesTestZkeyPath, - processMessageTestZkeyPath, - 0, - testSubsidyFilePath, - subsidyTestZkeyPath, - testRapidsnarkPath, - testProcessMessagesWitnessPath, - testTallyVotesWitnessPath, - testSubsidyWitnessPath, - coordinatorPrivKey, - maciAddresses.maciAddress, - undefined, - testProcessMessagesWasmPath, - testTallyVotesWasmPath, - testSubsidyWasmPath, - useWasm, - ); - await proveOnChain("0", testProofsDirPath); - await verify( - "0", - testTallyFilePath, - tallyData, - maciAddresses.maciAddress, - pollAddresses.tally, - pollAddresses.subsidy, - testSubsidyFilePath, - ); - }); - }); - - describe("multiplePolls1", () => { - after(() => { - cleanSubsidy(); - }); - - const user = new Keypair(); - - before(async () => { - // deploy the smart contracts - maciAddresses = await deploy(STATE_TREE_DEPTH); - // deploy a poll contract - pollAddresses = await deployPoll( - pollDuration, - 25, - 25, - INT_STATE_TREE_DEPTH, - MSG_BATCH_DEPTH, - MSG_TREE_DEPTH, - VOTE_OPTION_TREE_DEPTH, - coordinatorPubKey, - ); - // signup - await signup(user.pubKey.serialize()); - // publish - await publish( - user.pubKey.serialize(), - 1, - 0, - 1, - 0, - 9, - maciAddresses.maciAddress, - genRandomSalt().toString(), - user.privKey.serialize(), - ); - // time travel - await timeTravel(pollDuration, true); - // generate proofs - await mergeMessages(0); - await mergeSignups(0); - const tallyData = await genProofs( - testProofsDirPath, - testTallyFilePath, - tallyVotesTestZkeyPath, - processMessageTestZkeyPath, - 0, - testSubsidyFilePath, - subsidyTestZkeyPath, - testRapidsnarkPath, - testProcessMessagesWitnessPath, - testTallyVotesWitnessPath, - testSubsidyWitnessPath, - coordinatorPrivKey, - maciAddresses.maciAddress, - undefined, - testProcessMessagesWasmPath, - testTallyVotesWasmPath, - testSubsidyWasmPath, - useWasm, - ); - await proveOnChain("0", testProofsDirPath); - await verify( - "0", - testTallyFilePath, - tallyData, - maciAddresses.maciAddress, - pollAddresses.tally, - pollAddresses.subsidy, - testSubsidyFilePath, - ); - cleanSubsidy(); - }); - - it("should deploy a new poll", async () => { - pollAddresses = await deployPoll( - pollDuration, - maxMessages, - maxVoteOptions, - INT_STATE_TREE_DEPTH, - MSG_BATCH_DEPTH, - MSG_TREE_DEPTH, - VOTE_OPTION_TREE_DEPTH, - coordinatorPubKey, - ); - }); - it("should publish a new message", async () => { - await publish(user.pubKey.serialize(), 1, 0, 1, 1, 7, undefined, undefined, user.privKey.serialize()); - }); - it("should generate proofs and verify them", async () => { - await timeTravel(pollDuration, true); - await mergeMessages(1); - await mergeSignups(1); - const tallyData = await genProofs( - testProofsDirPath, - testTallyFilePath, - tallyVotesTestZkeyPath, - processMessageTestZkeyPath, - 1, - testSubsidyFilePath, - subsidyTestZkeyPath, - testRapidsnarkPath, - testProcessMessagesWitnessPath, - testTallyVotesWitnessPath, - testSubsidyWitnessPath, - coordinatorPrivKey, - maciAddresses.maciAddress, - undefined, - testProcessMessagesWasmPath, - testTallyVotesWasmPath, - testSubsidyWasmPath, - useWasm, - ); - await proveOnChain("1", testProofsDirPath); - await verify( - "1", - testTallyFilePath, - tallyData, - maciAddresses.maciAddress, - pollAddresses.tally, - pollAddresses.subsidy, - testSubsidyFilePath, - ); - }); - }); - describe("multiplePolls2", () => { const users = [ new Keypair(), diff --git a/cli/tests/e2e.test.ts b/cli/tests/e2e/e2e.test.ts similarity index 82% rename from cli/tests/e2e.test.ts rename to cli/tests/e2e/e2e.test.ts index 87dd48e779..13d0ab394e 100644 --- a/cli/tests/e2e.test.ts +++ b/cli/tests/e2e/e2e.test.ts @@ -20,9 +20,8 @@ import { timeTravel, topup, verify, -} from "../ts/commands"; -import { DeployedContracts, PollContracts } from "../ts/utils"; - +} from "../../ts/commands"; +import { DeployedContracts, PollContracts } from "../../ts/utils"; import { INT_STATE_TREE_DEPTH, MSG_BATCH_DEPTH, @@ -43,8 +42,8 @@ import { testTallyFilePath, testTallyVotesWasmPath, testTallyVotesWitnessPath, -} from "./constants"; -import { cleanVanilla, isArm } from "./utils"; +} from "../constants"; +import { cleanVanilla, isArm } from "../utils"; /** Test scenarios: @@ -53,12 +52,10 @@ import { cleanVanilla, isArm } from "./utils"; 5 signups, 1 message 8 signups, 10 messages 4 signups, 4 messages - 5 signups, 5 messages test if keys are set correctly given a set of files - test if key change works - multiple batch: Sign up 6 times, Publish 6 times 1 signup and 1 valid message for multiple polls 7 signups and 1 message, another polls and 6 messages + 1 signup, 1 topup message and 1 vote message */ describe("e2e tests", function test() { const useWasm = isArm(); @@ -83,7 +80,7 @@ describe("e2e tests", function test() { ); }); - describe("test1", () => { + describe("1 signup, 1 message", () => { after(() => { cleanVanilla(); }); @@ -160,7 +157,7 @@ describe("e2e tests", function test() { }); }); - describe("test2", () => { + describe("4 signups, 4 messages", () => { after(() => { cleanVanilla(); }); @@ -173,8 +170,8 @@ describe("e2e tests", function test() { // deploy a poll contract pollAddresses = await deployPoll( pollDuration, - maxMessages, - maxVoteOptions, + 25, + 25, INT_STATE_TREE_DEPTH, MSG_BATCH_DEPTH, MSG_TREE_DEPTH, @@ -191,7 +188,7 @@ describe("e2e tests", function test() { } }); - it("should publish six messages", async () => { + it("should publish four messages", async () => { await publish( users[0].pubKey.serialize(), 1, @@ -234,119 +231,6 @@ describe("e2e tests", function test() { 9, maciAddresses.maciAddress, genRandomSalt().toString(), - users[3].privKey.serialize(), - ); - await publish( - users[3].pubKey.serialize(), - 4, - 3, - 1, - 0, - 9, - maciAddresses.maciAddress, - genRandomSalt().toString(), - users[3].privKey.serialize(), - ); - await publish( - users[3].pubKey.serialize(), - 4, - 3, - 1, - 0, - 9, - maciAddresses.maciAddress, - genRandomSalt().toString(), - users[3].privKey.serialize(), - ); - }); - - it("should generate zk-SNARK proofs and verify them", async () => { - await timeTravel(pollDuration); - await mergeMessages(0, maciAddresses.maciAddress); - await mergeSignups(0, maciAddresses.maciAddress); - const tallyFileData = await genProofs( - testProofsDirPath, - testTallyFilePath, - tallyVotesTestZkeyPath, - processMessageTestZkeyPath, - 0, - undefined, - undefined, - testRapidsnarkPath, - testProcessMessagesWitnessPath, - testTallyVotesWitnessPath, - undefined, - coordinatorPrivKey, - maciAddresses.maciAddress, - undefined, - testProcessMessagesWasmPath, - testTallyVotesWasmPath, - undefined, - useWasm, - ); - await proveOnChain("0", testProofsDirPath); - await verify( - "0", - testTallyFilePath, - tallyFileData, - maciAddresses.maciAddress, - pollAddresses.tally, - pollAddresses.subsidy, - ); - }); - }); - - describe("test3", () => { - after(() => { - cleanVanilla(); - }); - - const users = [ - new Keypair(), - new Keypair(), - new Keypair(), - new Keypair(), - new Keypair(), - new Keypair(), - new Keypair(), - new Keypair(), - new Keypair(), - ]; - - before(async () => { - // deploy the smart contracts - maciAddresses = await deploy(STATE_TREE_DEPTH); - // deploy a poll contract - pollAddresses = await deployPoll( - pollDuration, - 25, - 25, - INT_STATE_TREE_DEPTH, - MSG_BATCH_DEPTH, - MSG_TREE_DEPTH, - VOTE_OPTION_TREE_DEPTH, - coordinatorPubKey, - ); - }); - - it("should signup nine users", async () => { - // eslint-disable-next-line @typescript-eslint/prefer-for-of - for (let i = 0; i < users.length; i += 1) { - // eslint-disable-next-line no-await-in-loop - await signup(users[i].pubKey.serialize()); - } - }); - - it("should publish one message", async () => { - await publish( - users[0].pubKey.serialize(), - 1, - 0, - 1, - 0, - 9, - maciAddresses.maciAddress, - genRandomSalt().toString(), users[0].privKey.serialize(), ); }); @@ -387,90 +271,7 @@ describe("e2e tests", function test() { }); }); - describe("test4", () => { - after(() => { - cleanVanilla(); - }); - - const user = new Keypair(); - - before(async () => { - // deploy the smart contracts - maciAddresses = await deploy(STATE_TREE_DEPTH); - // deploy a poll contract - pollAddresses = await deployPoll( - pollDuration, - 25, - 25, - INT_STATE_TREE_DEPTH, - MSG_BATCH_DEPTH, - MSG_TREE_DEPTH, - VOTE_OPTION_TREE_DEPTH, - coordinatorPubKey, - ); - }); - - it("should signup eight users (same pub key)", async () => { - for (let i = 0; i < 8; i += 1) { - // eslint-disable-next-line no-await-in-loop - await signup(user.pubKey.serialize()); - } - }); - - it("should publish 12 messages with the same nonce", async () => { - for (let i = 0; i < 12; i += 1) { - // eslint-disable-next-line no-await-in-loop - await publish( - user.pubKey.serialize(), - 1, - 0, - 1, - 0, - 9, - maciAddresses.maciAddress, - genRandomSalt().toString(), - user.privKey.serialize(), - ); - } - }); - - it("should generate zk-SNARK proofs and verify them", async () => { - await timeTravel(pollDuration); - await mergeMessages(0, maciAddresses.maciAddress); - await mergeSignups(0, maciAddresses.maciAddress); - const tallyFileData = await genProofs( - testProofsDirPath, - testTallyFilePath, - tallyVotesTestZkeyPath, - processMessageTestZkeyPath, - 0, - undefined, - undefined, - testRapidsnarkPath, - testProcessMessagesWitnessPath, - testTallyVotesWitnessPath, - undefined, - coordinatorPrivKey, - maciAddresses.maciAddress, - undefined, - testProcessMessagesWasmPath, - testTallyVotesWasmPath, - undefined, - useWasm, - ); - await proveOnChain("0", testProofsDirPath); - await verify( - "0", - testTallyFilePath, - tallyFileData, - maciAddresses.maciAddress, - pollAddresses.tally, - pollAddresses.subsidy, - ); - }); - }); - - describe("test5", () => { + describe("4 signups, 6 messages", () => { after(() => { cleanVanilla(); }); @@ -483,8 +284,8 @@ describe("e2e tests", function test() { // deploy a poll contract pollAddresses = await deployPoll( pollDuration, - 25, - 25, + maxMessages, + maxVoteOptions, INT_STATE_TREE_DEPTH, MSG_BATCH_DEPTH, MSG_TREE_DEPTH, @@ -501,7 +302,7 @@ describe("e2e tests", function test() { } }); - it("should publish four messages", async () => { + it("should publish six messages", async () => { await publish( users[0].pubKey.serialize(), 1, @@ -544,7 +345,29 @@ describe("e2e tests", function test() { 9, maciAddresses.maciAddress, genRandomSalt().toString(), - users[0].privKey.serialize(), + users[3].privKey.serialize(), + ); + await publish( + users[3].pubKey.serialize(), + 4, + 3, + 1, + 0, + 9, + maciAddresses.maciAddress, + genRandomSalt().toString(), + users[3].privKey.serialize(), + ); + await publish( + users[3].pubKey.serialize(), + 4, + 3, + 1, + 0, + 9, + maciAddresses.maciAddress, + genRandomSalt().toString(), + users[3].privKey.serialize(), ); }); @@ -584,12 +407,22 @@ describe("e2e tests", function test() { }); }); - describe("test6", () => { + describe("5 signups, 1 message", () => { after(() => { cleanVanilla(); }); - const users = [new Keypair(), new Keypair(), new Keypair(), new Keypair(), new Keypair()]; + const users = [ + new Keypair(), + new Keypair(), + new Keypair(), + new Keypair(), + new Keypair(), + new Keypair(), + new Keypair(), + new Keypair(), + new Keypair(), + ]; before(async () => { // deploy the smart contracts @@ -597,8 +430,8 @@ describe("e2e tests", function test() { // deploy a poll contract pollAddresses = await deployPoll( pollDuration, - maxMessages, - maxVoteOptions, + 25, + 25, INT_STATE_TREE_DEPTH, MSG_BATCH_DEPTH, MSG_TREE_DEPTH, @@ -607,7 +440,7 @@ describe("e2e tests", function test() { ); }); - it("should signup five users", async () => { + it("should signup nine users", async () => { // eslint-disable-next-line @typescript-eslint/prefer-for-of for (let i = 0; i < users.length; i += 1) { // eslint-disable-next-line no-await-in-loop @@ -615,7 +448,7 @@ describe("e2e tests", function test() { } }); - it("should publish five messages", async () => { + it("should publish one message", async () => { await publish( users[0].pubKey.serialize(), 1, @@ -627,50 +460,6 @@ describe("e2e tests", function test() { genRandomSalt().toString(), users[0].privKey.serialize(), ); - await publish( - users[1].pubKey.serialize(), - 2, - 1, - 1, - 0, - 9, - maciAddresses.maciAddress, - genRandomSalt().toString(), - users[1].privKey.serialize(), - ); - await publish( - users[2].pubKey.serialize(), - 3, - 2, - 1, - 0, - 9, - maciAddresses.maciAddress, - genRandomSalt().toString(), - users[2].privKey.serialize(), - ); - await publish( - users[3].pubKey.serialize(), - 4, - 3, - 1, - 0, - 9, - maciAddresses.maciAddress, - genRandomSalt().toString(), - users[3].privKey.serialize(), - ); - await publish( - users[4].pubKey.serialize(), - 5, - 4, - 1, - 0, - 9, - maciAddresses.maciAddress, - genRandomSalt().toString(), - users[4].privKey.serialize(), - ); }); it("should generate zk-SNARK proofs and verify them", async () => { @@ -709,31 +498,12 @@ describe("e2e tests", function test() { }); }); - describe("checkKeys", () => { - before(async () => { - // deploy maci as we need the address - await deploy(STATE_TREE_DEPTH); - }); - it("should check if the verifying keys have been set correctly", async () => { - await checkVerifyingKeys( - STATE_TREE_DEPTH, - INT_STATE_TREE_DEPTH, - MSG_TREE_DEPTH, - VOTE_OPTION_TREE_DEPTH, - MSG_BATCH_DEPTH, - processMessageTestZkeyPath, - tallyVotesTestZkeyPath, - ); - }); - }); - - describe("keyChange", () => { + describe("8 signups (same key), 12 messages (same message)", () => { after(() => { cleanVanilla(); }); - const key1 = new Keypair(); - const key2 = new Keypair(); + const user = new Keypair(); before(async () => { // deploy the smart contracts @@ -741,56 +511,38 @@ describe("e2e tests", function test() { // deploy a poll contract pollAddresses = await deployPoll( pollDuration, - maxMessages, - maxVoteOptions, + 25, + 25, INT_STATE_TREE_DEPTH, MSG_BATCH_DEPTH, MSG_TREE_DEPTH, VOTE_OPTION_TREE_DEPTH, coordinatorPubKey, ); - // signup a user - await signup(key1.pubKey.serialize()); - // publish messages - await publish( - key1.pubKey.serialize(), - 1, - 0, - 1, - 0, - 9, - maciAddresses.maciAddress, - genRandomSalt().toString(), - key1.privKey.serialize(), - ); }); - it("should publish a message to change the user maci key", async () => { - await publish( - key1.pubKey.serialize(), - 1, - 0, - 1, - 0, - 9, - maciAddresses.maciAddress, - genRandomSalt().toString(), - key1.privKey.serialize(), - ); + it("should signup eight users (same pub key)", async () => { + for (let i = 0; i < 8; i += 1) { + // eslint-disable-next-line no-await-in-loop + await signup(user.pubKey.serialize()); + } }); - it("should vote for a different option using the new key", async () => { - await publish( - key2.pubKey.serialize(), - 1, - 1, - 1, - 0, - 9, - maciAddresses.maciAddress, - genRandomSalt().toString(), - key2.privKey.serialize(), - ); + it("should publish 12 messages with the same nonce", async () => { + for (let i = 0; i < 12; i += 1) { + // eslint-disable-next-line no-await-in-loop + await publish( + user.pubKey.serialize(), + 1, + 0, + 1, + 0, + 9, + maciAddresses.maciAddress, + genRandomSalt().toString(), + user.privKey.serialize(), + ); + } }); it("should generate zk-SNARK proofs and verify them", async () => { @@ -829,6 +581,24 @@ describe("e2e tests", function test() { }); }); + describe("checkKeys", () => { + before(async () => { + // deploy maci as we need the address + await deploy(STATE_TREE_DEPTH); + }); + it("should check if the verifying keys have been set correctly", async () => { + await checkVerifyingKeys( + STATE_TREE_DEPTH, + INT_STATE_TREE_DEPTH, + MSG_TREE_DEPTH, + VOTE_OPTION_TREE_DEPTH, + MSG_BATCH_DEPTH, + processMessageTestZkeyPath, + tallyVotesTestZkeyPath, + ); + }); + }); + describe("multiplePolls1", () => { after(() => { cleanVanilla(); diff --git a/cli/tests/keyChange.test.ts b/cli/tests/e2e/keyChange.test.ts similarity index 98% rename from cli/tests/keyChange.test.ts rename to cli/tests/e2e/keyChange.test.ts index 7f6249226b..360068357a 100644 --- a/cli/tests/keyChange.test.ts +++ b/cli/tests/e2e/keyChange.test.ts @@ -4,7 +4,7 @@ import { Keypair } from "maci-domainobjs"; import fs from "fs"; -import { DeployedContracts, TallyData } from "../ts"; +import { DeployedContracts, TallyData } from "../../ts"; import { deploy, deployPoll, @@ -18,8 +18,7 @@ import { signup, timeTravel, verify, -} from "../ts/commands"; - +} from "../../ts/commands"; import { INT_STATE_TREE_DEPTH, MSG_BATCH_DEPTH, @@ -37,8 +36,8 @@ import { testTallyFilePath, testTallyVotesWasmPath, testTallyVotesWitnessPath, -} from "./constants"; -import { cleanVanilla, isArm } from "./utils"; +} from "../constants"; +import { cleanVanilla, isArm } from "../utils"; describe("keyChange tests", function test() { const useWasm = isArm(); diff --git a/cli/tests/unit/airdrop.test.ts b/cli/tests/unit/airdrop.test.ts new file mode 100644 index 0000000000..e06ce77dfc --- /dev/null +++ b/cli/tests/unit/airdrop.test.ts @@ -0,0 +1,26 @@ +import { expect } from "chai"; +import { ZeroAddress } from "ethers"; +import { deployTopupCredit } from "maci-contracts"; + +import { airdrop } from "../../ts"; + +describe("airdrop", () => { + let topupContractAddress: string | undefined; + + before(async () => { + const topupContract = await deployTopupCredit(); + topupContractAddress = await topupContract.getAddress(); + }); + + it("should airdrop tokens to the coordinator", async () => { + await expect(airdrop(100, topupContractAddress)).to.be.fulfilled; + }); + + it("should throw when the amount is negative", async () => { + await expect(airdrop(-1, topupContractAddress)).to.be.rejectedWith("Invalid amount"); + }); + + it("should throw when the ERC20 contract address is invalid", async () => { + await expect(airdrop(100, ZeroAddress)).to.be.rejectedWith("Invalid ERC20 contract address"); + }); +}); diff --git a/cli/tests/unit/data/testVk.json b/cli/tests/unit/data/testVk.json new file mode 100644 index 0000000000..d43765f385 --- /dev/null +++ b/cli/tests/unit/data/testVk.json @@ -0,0 +1,94 @@ +{ + "protocol": "groth16", + "curve": "bn128", + "nPublic": 1, + "vk_alpha_1": [ + "20491192805390485299153009773594534940189261866228447918068658471970481763042", + "9383485363053290200918347156157836566562967994039712273449902621266178545958", + "1" + ], + "vk_beta_2": [ + [ + "6375614351688725206403948262868962793625744043794305715222011528459656738731", + "4252822878758300859123897981450591353533073413197771768651442665752259397132" + ], + [ + "10505242626370262277552901082094356697409835680220590971873171140371331206856", + "21847035105528745403288232691147584728191162732299865338377159692350059136679" + ], + [ + "1", + "0" + ] + ], + "vk_gamma_2": [ + [ + "10857046999023057135944570762232829481370756359578518086990519993285655852781", + "11559732032986387107991004021392285783925812861821192530917403151452391805634" + ], + [ + "8495653923123431417604973247489272438418190587263600148770280649306958101930", + "4082367875863433681332203403145435568316851327593401208105741076214120093531" + ], + [ + "1", + "0" + ] + ], + "vk_delta_2": [ + [ + "10857046999023057135944570762232829481370756359578518086990519993285655852781", + "11559732032986387107991004021392285783925812861821192530917403151452391805634" + ], + [ + "8495653923123431417604973247489272438418190587263600148770280649306958101930", + "4082367875863433681332203403145435568316851327593401208105741076214120093531" + ], + [ + "1", + "0" + ] + ], + "vk_alphabeta_12": [ + [ + [ + "2029413683389138792403550203267699914886160938906632433982220835551125967885", + "21072700047562757817161031222997517981543347628379360635925549008442030252106" + ], + [ + "5940354580057074848093997050200682056184807770593307860589430076672439820312", + "12156638873931618554171829126792193045421052652279363021382169897324752428276" + ], + [ + "7898200236362823042373859371574133993780991612861777490112507062703164551277", + "7074218545237549455313236346927434013100842096812539264420499035217050630853" + ] + ], + [ + [ + "7077479683546002997211712695946002074877511277312570035766170199895071832130", + "10093483419865920389913245021038182291233451549023025229112148274109565435465" + ], + [ + "4595479056700221319381530156280926371456704509942304414423590385166031118820", + "19831328484489333784475432780421641293929726139240675179672856274388269393268" + ], + [ + "11934129596455521040620786944827826205713621633706285934057045369193958244500", + "8037395052364110730298837004334506829870972346962140206007064471173334027475" + ] + ] + ], + "IC": [ + [ + "10217961970561191542644673983819768829937049061556810432559046731768416748444", + "6614275190456400384394041626145087414551326824635999101683327156828330915037", + "1" + ], + [ + "11971344866240172007938968889867162918709454623842568616296127157079254314975", + "10060981430167258432297298832690153434217272087448231305232740724870906593798", + "1" + ] + ] +} \ No newline at end of file diff --git a/cli/tests/unit/fundWallet.test.ts b/cli/tests/unit/fundWallet.test.ts new file mode 100644 index 0000000000..4249daa1b8 --- /dev/null +++ b/cli/tests/unit/fundWallet.test.ts @@ -0,0 +1,16 @@ +import { expect } from "chai"; +import { ZeroAddress } from "ethers"; +import { getDefaultSigner } from "maci-contracts"; + +import { fundWallet } from "../../ts"; + +describe("fundWallet", () => { + it("should increase the balance of a wallet", async () => { + const signer = await getDefaultSigner(); + + const balanceBefore = await signer.provider?.getBalance(ZeroAddress); + await fundWallet(1000000000, ZeroAddress); + const balanceAfter = await signer.provider?.getBalance(ZeroAddress); + expect(balanceAfter).to.be.gt(balanceBefore!); + }); +}); diff --git a/integrationTests/ts/__tests__/cli-genMaciKeypair.test.ts b/cli/tests/unit/genKeyPair.test.ts similarity index 96% rename from integrationTests/ts/__tests__/cli-genMaciKeypair.test.ts rename to cli/tests/unit/genKeyPair.test.ts index 108598e36c..dbc2dbf253 100644 --- a/integrationTests/ts/__tests__/cli-genMaciKeypair.test.ts +++ b/cli/tests/unit/genKeyPair.test.ts @@ -1,8 +1,9 @@ import { expect } from "chai"; -import { genKeyPair } from "maci-cli"; import { genPubKey } from "maci-crypto"; import { PubKey, PrivKey } from "maci-domainobjs"; +import { genKeyPair } from "../../ts"; + describe("genMaciKeypair CLI subcommand", () => { it("genMaciKeypair should output a random private key and public key", () => { const keypair1 = genKeyPair(true); diff --git a/integrationTests/ts/__tests__/cli-genMaciPubkey.test.ts b/cli/tests/unit/genPubkey.test.ts similarity index 72% rename from integrationTests/ts/__tests__/cli-genMaciPubkey.test.ts rename to cli/tests/unit/genPubkey.test.ts index 0470a31bb4..6ced0877dd 100644 --- a/integrationTests/ts/__tests__/cli-genMaciPubkey.test.ts +++ b/cli/tests/unit/genPubkey.test.ts @@ -1,10 +1,11 @@ import { expect } from "chai"; -import { genKeyPair, genMaciPubKey } from "maci-cli"; import { genPubKey } from "maci-crypto"; import { PubKey, PrivKey } from "maci-domainobjs"; +import { genKeyPair, genMaciPubKey } from "../../ts"; + describe("genMaciPubkey CLI subcommand", () => { - it("genMaciPubkey should output a correct public key", () => { + it("should output a valid public key", () => { const keypair = genKeyPair(true); const pubKey = genMaciPubKey(keypair.privateKey, true); @@ -16,4 +17,8 @@ describe("genMaciPubkey CLI subcommand", () => { expect(unserializedPk.rawPubKey[0].toString()).to.eq(pk2[0].toString()); expect(unserializedPk.rawPubKey[1].toString()).to.eq(pk2[1].toString()); }); + + it("should throw when given an invalid private key", () => { + expect(() => genMaciPubKey("invalid", true)).to.throw("Invalid private key"); + }); }); diff --git a/cli/tests/unit/timeTravel.test.ts b/cli/tests/unit/timeTravel.test.ts new file mode 100644 index 0000000000..b387aed234 --- /dev/null +++ b/cli/tests/unit/timeTravel.test.ts @@ -0,0 +1,16 @@ +import { expect } from "chai"; +import { getDefaultSigner } from "maci-contracts"; + +import { timeTravel } from "../../ts"; + +describe("timeTravel", () => { + it("should work when given a valid integer number", async () => { + const signer = await getDefaultSigner(); + const blockNumber = await signer.provider?.getBlock("latest"); + + await expect(timeTravel(5)).to.be.fulfilled; + + const blockNumberAfter = await signer.provider?.getBlock("latest"); + expect(blockNumberAfter!.timestamp).to.be.gt(blockNumber!.timestamp); + }); +}); diff --git a/cli/tests/unit/topup.test.ts b/cli/tests/unit/topup.test.ts new file mode 100644 index 0000000000..2090973608 --- /dev/null +++ b/cli/tests/unit/topup.test.ts @@ -0,0 +1,47 @@ +import { expect } from "chai"; +import { Signer } from "ethers"; +import { + deployConstantInitialVoiceCreditProxy, + deployFreeForAllSignUpGatekeeper, + deployMaci, + deployMockVerifier, + deployTopupCredit, + getDefaultSigner, +} from "maci-contracts"; + +import { topup } from "../../ts"; + +describe("topup", () => { + let signer: Signer; + let maciAddress: string; + + before(async () => { + signer = await getDefaultSigner(); + const signupGatekepper = await deployFreeForAllSignUpGatekeeper(signer, true); + const verifier = await deployMockVerifier(signer, true); + const topupCredit = await deployTopupCredit(signer, true); + const initialVoiceCreditProxyAddress = await deployConstantInitialVoiceCreditProxy(100, signer, true); + const maciContracts = await deployMaci( + await signupGatekepper.getAddress(), + await initialVoiceCreditProxyAddress.getAddress(), + await verifier.getAddress(), + await topupCredit.getAddress(), + signer, + 10, + true, + ); + maciAddress = await maciContracts.maciContract.getAddress(); + }); + + it("should throw when the state index is invalid", async () => { + await expect(topup(100, 0, 0, maciAddress)).to.be.rejectedWith("State index must be greater than 0"); + }); + + it("should throw when the poll ID is invalid", async () => { + await expect(topup(100, 1, -1, maciAddress)).to.be.rejectedWith("Poll ID must be a positive integer"); + }); + + it("should throw when the amount is invalid", async () => { + await expect(topup(0, 1, 0, maciAddress)).to.be.rejectedWith("Topup amount must be greater than 0"); + }); +}); diff --git a/cli/tests/unit/utils.test.ts b/cli/tests/unit/utils.test.ts new file mode 100644 index 0000000000..7e17314408 --- /dev/null +++ b/cli/tests/unit/utils.test.ts @@ -0,0 +1,36 @@ +import { expect } from "chai"; +import { SNARK_FIELD_SIZE, genRandomSalt } from "maci-crypto"; +import { VerifyingKey } from "maci-domainobjs"; + +import fs from "fs"; +import path from "path"; + +import { compareVks } from "../../ts/utils"; +import { validateSalt } from "../../ts/utils/salt"; + +describe("utils", () => { + const vkPath = path.resolve(__dirname, "data", "testVk.json"); + const vk1 = VerifyingKey.fromJSON(fs.readFileSync(vkPath).toString()); + + describe("vks", () => { + it("should return true for two equal VKs", () => { + expect(compareVks(vk1, vk1.asContractParam())).to.eq(true); + }); + + it("should return false for two unequal VKs", () => { + const vk2 = vk1.asContractParam(); + vk2.alpha1.x = 9999n; + expect(compareVks(vk1, vk2)).to.eq(false); + }); + }); + + describe("validateSalt", () => { + it("should return true for a valid salt", () => { + expect(validateSalt(genRandomSalt().toString())).to.eq(true); + }); + + it("should return false for an invalid salt", () => { + expect(validateSalt(SNARK_FIELD_SIZE.toString())).to.eq(false); + }); + }); +}); diff --git a/contracts/hardhat.config.ts b/contracts/hardhat.config.ts index 4ace0da419..31a29ca13e 100644 --- a/contracts/hardhat.config.ts +++ b/contracts/hardhat.config.ts @@ -20,6 +20,7 @@ const config: HardhatUserConfig = { hardhat: { accounts: { mnemonic: "candy maple cake sugar pudding cream honey rich smooth crumble sweet treat", + count: 20, }, loggingEnabled: false, allowUnlimitedContractSize: true, diff --git a/domainobjs/ts/__tests__/artifacts/test_vk.json b/domainobjs/ts/__tests__/artifacts/test_vk.json index 88f3006178..d43765f385 100644 --- a/domainobjs/ts/__tests__/artifacts/test_vk.json +++ b/domainobjs/ts/__tests__/artifacts/test_vk.json @@ -1,94 +1,94 @@ { - "protocol": "groth16", - "curve": "bn128", - "nPublic": 1, - "vk_alpha_1": [ - "20491192805390485299153009773594534940189261866228447918068658471970481763042", - "9383485363053290200918347156157836566562967994039712273449902621266178545958", - "1" - ], - "vk_beta_2": [ - [ - "6375614351688725206403948262868962793625744043794305715222011528459656738731", - "4252822878758300859123897981450591353533073413197771768651442665752259397132" - ], - [ - "10505242626370262277552901082094356697409835680220590971873171140371331206856", - "21847035105528745403288232691147584728191162732299865338377159692350059136679" - ], - [ - "1", - "0" - ] - ], - "vk_gamma_2": [ - [ + "protocol": "groth16", + "curve": "bn128", + "nPublic": 1, + "vk_alpha_1": [ + "20491192805390485299153009773594534940189261866228447918068658471970481763042", + "9383485363053290200918347156157836566562967994039712273449902621266178545958", + "1" + ], + "vk_beta_2": [ + [ + "6375614351688725206403948262868962793625744043794305715222011528459656738731", + "4252822878758300859123897981450591353533073413197771768651442665752259397132" + ], + [ + "10505242626370262277552901082094356697409835680220590971873171140371331206856", + "21847035105528745403288232691147584728191162732299865338377159692350059136679" + ], + [ + "1", + "0" + ] + ], + "vk_gamma_2": [ + [ "10857046999023057135944570762232829481370756359578518086990519993285655852781", "11559732032986387107991004021392285783925812861821192530917403151452391805634" - ], - [ + ], + [ "8495653923123431417604973247489272438418190587263600148770280649306958101930", "4082367875863433681332203403145435568316851327593401208105741076214120093531" - ], - [ + ], + [ "1", "0" - ] - ], - "vk_delta_2": [ - [ + ] + ], + "vk_delta_2": [ + [ "10857046999023057135944570762232829481370756359578518086990519993285655852781", "11559732032986387107991004021392285783925812861821192530917403151452391805634" - ], - [ + ], + [ "8495653923123431417604973247489272438418190587263600148770280649306958101930", "4082367875863433681332203403145435568316851327593401208105741076214120093531" - ], - [ + ], + [ "1", "0" - ] - ], - "vk_alphabeta_12": [ - [ + ] + ], + "vk_alphabeta_12": [ + [ [ - "2029413683389138792403550203267699914886160938906632433982220835551125967885", - "21072700047562757817161031222997517981543347628379360635925549008442030252106" + "2029413683389138792403550203267699914886160938906632433982220835551125967885", + "21072700047562757817161031222997517981543347628379360635925549008442030252106" ], [ - "5940354580057074848093997050200682056184807770593307860589430076672439820312", - "12156638873931618554171829126792193045421052652279363021382169897324752428276" + "5940354580057074848093997050200682056184807770593307860589430076672439820312", + "12156638873931618554171829126792193045421052652279363021382169897324752428276" ], [ - "7898200236362823042373859371574133993780991612861777490112507062703164551277", - "7074218545237549455313236346927434013100842096812539264420499035217050630853" + "7898200236362823042373859371574133993780991612861777490112507062703164551277", + "7074218545237549455313236346927434013100842096812539264420499035217050630853" ] - ], - [ + ], + [ [ - "7077479683546002997211712695946002074877511277312570035766170199895071832130", - "10093483419865920389913245021038182291233451549023025229112148274109565435465" + "7077479683546002997211712695946002074877511277312570035766170199895071832130", + "10093483419865920389913245021038182291233451549023025229112148274109565435465" ], [ - "4595479056700221319381530156280926371456704509942304414423590385166031118820", - "19831328484489333784475432780421641293929726139240675179672856274388269393268" + "4595479056700221319381530156280926371456704509942304414423590385166031118820", + "19831328484489333784475432780421641293929726139240675179672856274388269393268" ], [ - "11934129596455521040620786944827826205713621633706285934057045369193958244500", - "8037395052364110730298837004334506829870972346962140206007064471173334027475" + "11934129596455521040620786944827826205713621633706285934057045369193958244500", + "8037395052364110730298837004334506829870972346962140206007064471173334027475" ] - ] - ], - "IC": [ - [ + ] + ], + "IC": [ + [ "10217961970561191542644673983819768829937049061556810432559046731768416748444", "6614275190456400384394041626145087414551326824635999101683327156828330915037", "1" - ], - [ + ], + [ "11971344866240172007938968889867162918709454623842568616296127157079254314975", "10060981430167258432297298832690153434217272087448231305232740724870906593798", "1" - ] ] - } \ No newline at end of file + ] +} \ No newline at end of file diff --git a/integrationTests/package.json b/integrationTests/package.json index 9b6f144d03..d4a1239e47 100644 --- a/integrationTests/package.json +++ b/integrationTests/package.json @@ -7,9 +7,7 @@ "watch": "tsc --watch", "build": "tsc", "test": "ts-mocha --exit ./ts/__tests__/**.test.ts", - "test:genMaciKeypair": "ts-mocha --exit ./ts/__tests__/cli-genMaciKeypair.test.ts", - "test:genMaciPubkey": "ts-mocha --exit ./ts/__tests__/cli-genMaciPubkey.test.ts", - "test:integration": "NODE_OPTIONS=--max-old-space-size=4096 ts-mocha --exit ./ts/__tests__/integration.test.ts", + "test:suites": "NODE_OPTIONS=--max-old-space-size=4096 ts-mocha --exit ./ts/__tests__/suites.test.ts", "test:maciKeys": "ts-mocha --exit ./ts/__tests__/maci-keys.test.ts", "download-zkeys": "./scripts/download_zkeys.sh" },