Skip to content

Commit

Permalink
Merge pull request #1190 from privacy-scaling-explorations/chore/web-…
Browse files Browse the repository at this point in the history
…app-install

chore(cli): support install for web apps
  • Loading branch information
0xmad authored Feb 13, 2024
2 parents 6871338 + 3166cdd commit a0c4c98
Show file tree
Hide file tree
Showing 18 changed files with 205 additions and 185 deletions.
4 changes: 2 additions & 2 deletions cli/tests/ceremony-params/ceremonyParams.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ describe("stress tests", function test() {
});

it("should signup 1 user", async () => {
await signup({ maciPubKey: users[0].pubKey.serialize(), signer });
await signup({ maciAddress: maciAddresses.maciAddress, maciPubKey: users[0].pubKey.serialize(), signer });
});

it("should publish 2 messages", async () => {
Expand Down Expand Up @@ -154,7 +154,7 @@ describe("stress tests", function test() {
await mergeSignups({ ...mergeSignupsArgs, signer });
await genProofs({ ...genProofsCeremonyArgs, signer });
await proveOnChain({ ...proveOnChainArgs, signer });
await verify({ ...verifyArgs, signer });
await verify({ ...verifyArgs(), signer });
});
});
});
16 changes: 12 additions & 4 deletions cli/tests/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import {
MergeSignupsArgs,
ProveOnChainArgs,
SetVerifyingKeysArgs,
TallyData,
TimeTravelArgs,
VerifyArgs,
readJSONFile,
} from "../ts/utils";

export const STATE_TREE_DEPTH = 10;
Expand Down Expand Up @@ -128,10 +130,16 @@ export const proveOnChainArgs: Omit<ProveOnChainArgs, "signer"> = {
subsidyEnabled: false,
};

export const verifyArgs: Omit<VerifyArgs, "signer"> = {
pollId: 0n,
subsidyEnabled: false,
tallyFile: testTallyFilePath,
export const verifyArgs = (): Omit<VerifyArgs, "signer"> => {
const tallyData = readJSONFile(testTallyFilePath) as unknown as TallyData;

return {
pollId: 0n,
subsidyEnabled: false,
tallyData,
maciAddress: tallyData.maci,
tallyAddress: tallyData.tallyAddress,
};
};

export const deployArgs: Omit<DeployArgs, "signer"> = {
Expand Down
8 changes: 5 additions & 3 deletions cli/tests/e2e/e2e.nonQv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe("e2e tests", function test() {
await setVerifyingKeys({ ...setVerifyingKeysNonQvArgs, signer });
});

describe("1 signup, 1 message (with signer as argument)", () => {
describe("1 signup, 1 message", () => {
after(() => {
cleanVanilla();
});
Expand All @@ -96,7 +96,7 @@ describe("e2e tests", function test() {
});

it("should signup one user", async () => {
await signup({ maciPubKey: user.pubKey.serialize(), signer });
await signup({ maciAddress: maciAddresses.maciAddress, maciPubKey: user.pubKey.serialize(), signer });
});

it("should publish one message", async () => {
Expand All @@ -121,8 +121,10 @@ describe("e2e tests", function test() {
const tallyFileData = await genProofs({ ...genProofsArgs, signer, useQuadraticVoting: false });
await proveOnChain({ ...proveOnChainArgs, signer });
await verify({
...verifyArgs,
...verifyArgs(),
tallyData: tallyFileData,
maciAddress: tallyFileData.maci,
tallyAddress: tallyFileData.tallyAddress,
signer,
});
});
Expand Down
26 changes: 16 additions & 10 deletions cli/tests/e2e/e2e.subsidy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,13 @@ describe("e2e with Subsidy tests", function test() {
// 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({ maciPubKey: users[i].pubKey.serialize(), signer });
await signup({ maciAddress: maciAddresses.maciAddress, maciPubKey: users[i].pubKey.serialize(), signer });
}
});

it("should publish six messages", async () => {
await publish({
maciContractAddress: maciAddresses.maciAddress,
pubkey: users[0].pubKey.serialize(),
stateIndex: 1n,
voteOptionIndex: 0n,
Expand All @@ -129,6 +130,7 @@ describe("e2e with Subsidy tests", function test() {
});

await publish({
maciContractAddress: maciAddresses.maciAddress,
pubkey: users[1].pubKey.serialize(),
stateIndex: 2n,
voteOptionIndex: 1n,
Expand All @@ -141,6 +143,7 @@ describe("e2e with Subsidy tests", function test() {
});

await publish({
maciContractAddress: maciAddresses.maciAddress,
pubkey: users[2].pubKey.serialize(),
stateIndex: 3n,
voteOptionIndex: 2n,
Expand All @@ -153,6 +156,7 @@ describe("e2e with Subsidy tests", function test() {
});

await publish({
maciContractAddress: maciAddresses.maciAddress,
pubkey: users[3].pubKey.serialize(),
stateIndex: 4n,
voteOptionIndex: 3n,
Expand All @@ -165,6 +169,7 @@ describe("e2e with Subsidy tests", function test() {
});

await publish({
maciContractAddress: maciAddresses.maciAddress,
pubkey: users[3].pubKey.serialize(),
stateIndex: 4n,
voteOptionIndex: 3n,
Expand All @@ -177,6 +182,7 @@ describe("e2e with Subsidy tests", function test() {
});

await publish({
maciContractAddress: maciAddresses.maciAddress,
pubkey: users[3].pubKey.serialize(),
stateIndex: 4n,
voteOptionIndex: 3n,
Expand All @@ -195,7 +201,7 @@ describe("e2e with Subsidy tests", function test() {
await mergeSignups({ ...mergeSignupsArgs, signer });
await genProofs({ ...genProofsArgs, signer });
await proveOnChain({ ...proveOnChainArgs, signer });
await verify({ ...verifyArgs, signer });
await verify({ ...verifyArgs(), signer });
});
});

Expand Down Expand Up @@ -227,7 +233,7 @@ describe("e2e with Subsidy tests", function test() {
// 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({ maciPubKey: users[i].pubKey.serialize(), signer });
await signup({ maciAddress: maciAddresses.maciAddress, maciPubKey: users[i].pubKey.serialize(), signer });
}
});

Expand All @@ -252,7 +258,7 @@ describe("e2e with Subsidy tests", function test() {
await mergeSignups({ ...mergeSignupsArgs, signer });
const tallyData = await genProofs({ ...genProofsArgs, signer });
await proveOnChain({ ...proveOnChainArgs, signer });
await verify({ ...verifyArgs, tallyData, signer });
await verify({ ...verifyArgs(), tallyData, signer });
});
});

Expand All @@ -273,7 +279,7 @@ describe("e2e with Subsidy tests", function test() {
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({ maciPubKey: user.pubKey.serialize(), signer });
await signup({ maciAddress: maciAddresses.maciAddress, maciPubKey: user.pubKey.serialize(), signer });
}
});

Expand Down Expand Up @@ -301,7 +307,7 @@ describe("e2e with Subsidy tests", function test() {
await mergeSignups({ ...mergeSignupsArgs, signer });
const tallyData = await genProofs({ ...genProofsArgs, signer });
await proveOnChain({ ...proveOnChainArgs, signer });
await verify({ ...verifyArgs, tallyData, signer });
await verify({ ...verifyArgs(), tallyData, signer });
});
});

Expand Down Expand Up @@ -334,7 +340,7 @@ describe("e2e with Subsidy tests", function test() {
// 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({ maciPubKey: users[i].pubKey.serialize(), signer });
await signup({ maciAddress: maciAddresses.maciAddress, maciPubKey: users[i].pubKey.serialize(), signer });
}
// publish
await publish({
Expand All @@ -356,7 +362,7 @@ describe("e2e with Subsidy tests", function test() {
await mergeSignups({ ...mergeSignupsArgs, signer });
await genProofs({ ...genProofsArgs, signer });
await proveOnChain({ ...proveOnChainArgs, signer });
await verify({ ...verifyArgs, signer });
await verify({ ...verifyArgs(), signer });
cleanSubsidy();
});

Expand Down Expand Up @@ -463,7 +469,7 @@ describe("e2e with Subsidy tests", function test() {
signer,
});
await verify({
...verifyArgs,
...verifyArgs(),
pollId: 1n,
tallyData,
tallyAddress: pollAddresses.tally,
Expand All @@ -486,7 +492,7 @@ describe("e2e with Subsidy tests", function test() {
signer,
});
await verify({
...verifyArgs,
...verifyArgs(),
pollId: 2n,
tallyData,
tallyAddress: secondPollAddresses.tally,
Expand Down
Loading

0 comments on commit a0c4c98

Please sign in to comment.