diff --git a/contracts/tests/EASGatekeeper.test.ts b/contracts/tests/EASGatekeeper.test.ts index 20841eb96b..b3ad86286b 100644 --- a/contracts/tests/EASGatekeeper.test.ts +++ b/contracts/tests/EASGatekeeper.test.ts @@ -35,8 +35,9 @@ describe("EAS Gatekeeper", () => { }); describe("Deployment", () => { - it("The gatekeeper should be deployed correctly", () => { + it("The gatekeeper should be deployed correctly", async () => { expect(easGatekeeper).to.not.eq(undefined); + expect(await easGatekeeper.getAddress()).to.not.eq(ZeroAddress); }); it("should fail to deploy when the eas contract address is not valid", async () => { diff --git a/contracts/tests/GitcoinPassportGatekeeper.test.ts b/contracts/tests/GitcoinPassportGatekeeper.test.ts index 62b467c42f..38a6edbc95 100644 --- a/contracts/tests/GitcoinPassportGatekeeper.test.ts +++ b/contracts/tests/GitcoinPassportGatekeeper.test.ts @@ -35,8 +35,9 @@ describe("GitcoinPassport Gatekeeper", () => { }); describe("Deployment", () => { - it("The gatekeeper should be deployed correctly", () => { + it("The gatekeeper should be deployed correctly", async () => { expect(gitcoinGatekeeper).to.not.eq(undefined); + expect(await gitcoinGatekeeper.getAddress()).to.not.eq(ZeroAddress); }); it("should fail to deploy when the decoder contract address is not valid", async () => { diff --git a/contracts/tests/MACI.test.ts b/contracts/tests/MACI.test.ts index 0fa6410d15..ecf23bb10a 100644 --- a/contracts/tests/MACI.test.ts +++ b/contracts/tests/MACI.test.ts @@ -1,6 +1,6 @@ /* eslint-disable no-underscore-dangle */ import { expect } from "chai"; -import { AbiCoder, BigNumberish, Signer } from "ethers"; +import { AbiCoder, BigNumberish, Signer, ZeroAddress } from "ethers"; import { EthereumProvider } from "hardhat/types"; import { MaciState } from "maci-core"; import { NOTHING_UP_MY_SLEEVE } from "maci-crypto"; @@ -34,7 +34,6 @@ describe("MACI", function test() { let signer: Signer; const maciState = new MaciState(STATE_TREE_DEPTH); - const signUpTxOpts = { gasLimit: 400000 }; describe("Deployment", () => { before(async () => { @@ -80,7 +79,6 @@ describe("MACI", function test() { user.pubKey.asContractParam(), AbiCoder.defaultAbiCoder().encode(["uint256"], [1]), AbiCoder.defaultAbiCoder().encode(["uint256"], [0]), - signUpTxOpts, ); // eslint-disable-next-line no-await-in-loop const receipt = await tx.wait(); @@ -115,7 +113,6 @@ describe("MACI", function test() { }, AbiCoder.defaultAbiCoder().encode(["uint256"], [1]), AbiCoder.defaultAbiCoder().encode(["uint256"], [0]), - signUpTxOpts, ), ).to.be.revertedWithCustomError(maciContract, "InvalidPubKey"); }); @@ -129,7 +126,6 @@ describe("MACI", function test() { }, AbiCoder.defaultAbiCoder().encode(["uint256"], [1]), AbiCoder.defaultAbiCoder().encode(["uint256"], [0]), - signUpTxOpts, ), ).to.be.revertedWithCustomError(maciContract, "InvalidPubKey"); }); @@ -143,7 +139,6 @@ describe("MACI", function test() { }, AbiCoder.defaultAbiCoder().encode(["uint256"], [1]), AbiCoder.defaultAbiCoder().encode(["uint256"], [0]), - signUpTxOpts, ), ).to.be.revertedWithCustomError(maciContract, "InvalidPubKey"); }); @@ -157,7 +152,6 @@ describe("MACI", function test() { }, AbiCoder.defaultAbiCoder().encode(["uint256"], [1]), AbiCoder.defaultAbiCoder().encode(["uint256"], [0]), - signUpTxOpts, ), ).to.be.revertedWithCustomError(maciContract, "InvalidPubKey"); }); @@ -223,7 +217,6 @@ describe("MACI", function test() { verifierContract, vkRegistryContract, EMode.QV, - { gasLimit: 10000000 }, ); const receipt = await tx.wait(); @@ -231,12 +224,7 @@ describe("MACI", function test() { deployTime = block!.timestamp; expect(receipt?.status).to.eq(1); - const iface = maciContract.interface; - const logs = receipt!.logs[receipt!.logs.length - 1]; - const event = iface.parseLog(logs as unknown as { topics: string[]; data: string }) as unknown as { - args: { _pollId: bigint }; - }; - pollId = event.args._pollId; + pollId = (await maciContract.nextPollId()) - 1n; const p = maciState.deployPoll( BigInt(deployTime + duration), @@ -268,7 +256,6 @@ describe("MACI", function test() { verifierContract, vkRegistryContract, EMode.QV, - { gasLimit: 10000000 }, ); const receipt = await tx.wait(); expect(receipt?.status).to.eq(1); @@ -286,7 +273,6 @@ describe("MACI", function test() { verifierContract, vkRegistryContract, EMode.QV, - { gasLimit: 10000000 }, ); const receipt = await tx.wait(); expect(receipt?.status).to.eq(1); @@ -305,9 +291,7 @@ describe("MACI", function test() { it("should allow a Poll contract to merge the state tree (calculate the state root)", async () => { await timeTravel(signer.provider as unknown as EthereumProvider, Number(duration) + 1); - const tx = await pollContract.mergeMaciState({ - gasLimit: 3000000, - }); + const tx = await pollContract.mergeMaciState(); const receipt = await tx.wait(); expect(receipt?.status).to.eq(1); }); @@ -327,7 +311,6 @@ describe("MACI", function test() { users[0].pubKey.asContractParam(), AbiCoder.defaultAbiCoder().encode(["uint256"], [1]), AbiCoder.defaultAbiCoder().encode(["uint256"], [0]), - signUpTxOpts, ); const receipt = await tx.wait(); expect(receipt?.status).to.eq(1); @@ -353,8 +336,11 @@ describe("MACI", function test() { }); describe("getPoll", () => { - it("should return an address for a valid id", async () => { - expect(await maciContract.getPoll(pollId)).to.not.eq(0); + it("should return an object for a valid id", async () => { + const pollContracts = await maciContract.getPoll(pollId); + expect(pollContracts.poll).to.not.eq(ZeroAddress); + expect(pollContracts.messageProcessor).to.not.eq(ZeroAddress); + expect(pollContracts.tally).to.not.eq(ZeroAddress); }); it("should throw when given an invalid poll id", async () => { diff --git a/contracts/tests/MessageProcessor.test.ts b/contracts/tests/MessageProcessor.test.ts index d10465fab0..ea446f53f8 100644 --- a/contracts/tests/MessageProcessor.test.ts +++ b/contracts/tests/MessageProcessor.test.ts @@ -68,32 +68,18 @@ describe("MessageProcessor", () => { verifierContract, vkRegistryContract, EMode.QV, - { - gasLimit: 10000000, - }, ); let receipt = await tx.wait(); // extract poll id expect(receipt?.status).to.eq(1); - const iface = maciContract.interface; - const logs = receipt!.logs[receipt!.logs.length - 1]; - const event = iface.parseLog(logs as unknown as { topics: string[]; data: string }) as unknown as { - args: { - _pollId: bigint; - pollAddr: { - poll: string; - messageProcessor: string; - tally: string; - }; - }; - }; - pollId = event.args._pollId; + + pollId = (await maciContract.nextPollId()) - 1n; const pollContracts = await maciContract.getPoll(pollId); pollContract = PollFactory.connect(pollContracts.poll, signer); - mpContract = MessageProcessorFactory.connect(event.args.pollAddr.messageProcessor, signer); + mpContract = MessageProcessorFactory.connect(pollContracts.messageProcessor, signer); const block = await signer.provider!.getBlock(receipt!.blockHash); const deployTime = block!.timestamp; @@ -132,7 +118,6 @@ describe("MessageProcessor", () => { EMode.QV, testProcessVk.asContractParam() as IVerifyingKeyStruct, testTallyVk.asContractParam() as IVerifyingKeyStruct, - { gasLimit: 1000000 }, ); receipt = await tx.wait(); expect(receipt?.status).to.eq(1); diff --git a/contracts/tests/Poll.test.ts b/contracts/tests/Poll.test.ts index 245ef1940f..4fe27804d1 100644 --- a/contracts/tests/Poll.test.ts +++ b/contracts/tests/Poll.test.ts @@ -59,9 +59,6 @@ describe("Poll", () => { verifierContract, vkRegistryContract, EMode.QV, - { - gasLimit: 10000000, - }, ); const receipt = await tx.wait(); @@ -69,12 +66,8 @@ describe("Poll", () => { deployTime = block!.timestamp; expect(receipt?.status).to.eq(1); - const iface = maciContract.interface; - const logs = receipt!.logs[receipt!.logs.length - 1]; - const event = iface.parseLog(logs as unknown as { topics: string[]; data: string }) as unknown as { - args: { _pollId: bigint }; - }; - pollId = event.args._pollId; + + pollId = (await maciContract.nextPollId()) - 1n; const pollContracts = await maciContract.getPoll(pollId); pollContract = PollFactory.connect(pollContracts.poll, signer); @@ -154,9 +147,6 @@ describe("Poll", () => { r.mockVerifierContract as Verifier, r.vkRegistryContract, EMode.QV, - { - gasLimit: 10000000, - }, ), ).to.be.revertedWithCustomError(testMaciContract, "InvalidPubKey"); }); @@ -275,13 +265,11 @@ describe("Poll", () => { }); it("should allow to merge the message AccQueue", async () => { - let tx = await pollContract.mergeMessageAqSubRoots(0, { - gasLimit: 3000000, - }); + let tx = await pollContract.mergeMessageAqSubRoots(0); let receipt = await tx.wait(); expect(receipt?.status).to.eq(1); - tx = await pollContract.mergeMessageAq({ gasLimit: 4000000 }); + tx = await pollContract.mergeMessageAq(); receipt = await tx.wait(); expect(receipt?.status).to.eq(1); }); diff --git a/contracts/tests/Tally.test.ts b/contracts/tests/Tally.test.ts index 668dcb20d5..73a3ec5517 100644 --- a/contracts/tests/Tally.test.ts +++ b/contracts/tests/Tally.test.ts @@ -79,9 +79,6 @@ describe("TallyVotes", () => { verifierContract, vkRegistryContract, EMode.QV, - { - gasLimit: 10000000, - }, ); const receipt = await tx.wait(); @@ -89,27 +86,13 @@ describe("TallyVotes", () => { const deployTime = block!.timestamp; expect(receipt?.status).to.eq(1); - const iface = maciContract.interface; - const logs = receipt!.logs[receipt!.logs.length - 1]; - const event = iface.parseLog(logs as unknown as { topics: string[]; data: string }) as unknown as { - args: { - _pollId: bigint; - pollAddr: { - poll: string; - messageProcessor: string; - tally: string; - }; - }; - name: string; - }; - expect(event.name).to.eq("DeployPoll"); - - pollId = event.args._pollId; + + pollId = (await maciContract.nextPollId()) - 1n; const pollContracts = await maciContract.getPoll(pollId); pollContract = PollFactory.connect(pollContracts.poll, signer); - mpContract = MessageProcessorFactory.connect(event.args.pollAddr.messageProcessor, signer); - tallyContract = TallyFactory.connect(event.args.pollAddr.tally, signer); + mpContract = MessageProcessorFactory.connect(pollContracts.messageProcessor, signer); + tallyContract = TallyFactory.connect(pollContracts.tally, signer); // deploy local poll const p = maciState.deployPoll(BigInt(deployTime + duration), maxValues, treeDepths, messageBatchSize, coordinator); @@ -146,7 +129,6 @@ describe("TallyVotes", () => { EMode.QV, testProcessVk.asContractParam() as IVerifyingKeyStruct, testTallyVk.asContractParam() as IVerifyingKeyStruct, - { gasLimit: 1000000 }, ); }); @@ -260,9 +242,6 @@ describe("TallyVotes", () => { verifierContract, vkRegistryContract, EMode.QV, - { - gasLimit: 10000000, - }, ); const receipt = await tx.wait(); @@ -270,27 +249,13 @@ describe("TallyVotes", () => { const deployTime = block!.timestamp; expect(receipt?.status).to.eq(1); - const iface = maciContract.interface; - const logs = receipt!.logs[receipt!.logs.length - 1]; - const event = iface.parseLog(logs as unknown as { topics: string[]; data: string }) as unknown as { - args: { - _pollId: bigint; - pollAddr: { - poll: string; - messageProcessor: string; - tally: string; - }; - }; - name: string; - }; - expect(event.name).to.eq("DeployPoll"); - - pollId = event.args._pollId; + + pollId = (await maciContract.nextPollId()) - 1n; const pollContracts = await maciContract.getPoll(pollId); pollContract = PollFactory.connect(pollContracts.poll, signer); - mpContract = MessageProcessorFactory.connect(event.args.pollAddr.messageProcessor, signer); - tallyContract = TallyFactory.connect(event.args.pollAddr.tally, signer); + mpContract = MessageProcessorFactory.connect(pollContracts.messageProcessor, signer); + tallyContract = TallyFactory.connect(pollContracts.tally, signer); // deploy local poll const p = maciState.deployPoll( @@ -333,7 +298,6 @@ describe("TallyVotes", () => { EMode.QV, testProcessVk.asContractParam() as IVerifyingKeyStruct, testTallyVk.asContractParam() as IVerifyingKeyStruct, - { gasLimit: 1000000 }, ); await timeTravel(signer.provider! as unknown as EthereumProvider, updatedDuration); @@ -405,9 +369,6 @@ describe("TallyVotes", () => { verifierContract, vkRegistryContract, EMode.QV, - { - gasLimit: 10000000, - }, ); const receipt = await tx.wait(); @@ -415,27 +376,13 @@ describe("TallyVotes", () => { const deployTime = block!.timestamp; expect(receipt?.status).to.eq(1); - const iface = maciContract.interface; - const logs = receipt!.logs[receipt!.logs.length - 1]; - const event = iface.parseLog(logs as unknown as { topics: string[]; data: string }) as unknown as { - args: { - _pollId: bigint; - pollAddr: { - poll: string; - messageProcessor: string; - tally: string; - }; - }; - name: string; - }; - expect(event.name).to.eq("DeployPoll"); - - pollId = event.args._pollId; + + pollId = (await maciContract.nextPollId()) - 1n; const pollContracts = await maciContract.getPoll(pollId); pollContract = PollFactory.connect(pollContracts.poll, signer); - mpContract = MessageProcessorFactory.connect(event.args.pollAddr.messageProcessor, signer); - tallyContract = TallyFactory.connect(event.args.pollAddr.tally, signer); + mpContract = MessageProcessorFactory.connect(pollContracts.messageProcessor, signer); + tallyContract = TallyFactory.connect(pollContracts.tally, signer); // deploy local poll const p = maciState.deployPoll( @@ -478,7 +425,6 @@ describe("TallyVotes", () => { EMode.QV, testProcessVk.asContractParam() as IVerifyingKeyStruct, testTallyVk.asContractParam() as IVerifyingKeyStruct, - { gasLimit: 1000000 }, ); await timeTravel(signer.provider! as unknown as EthereumProvider, updatedDuration); diff --git a/contracts/tests/TallyNonQv.test.ts b/contracts/tests/TallyNonQv.test.ts index 0d94ae40a9..22b78f2d7a 100644 --- a/contracts/tests/TallyNonQv.test.ts +++ b/contracts/tests/TallyNonQv.test.ts @@ -78,9 +78,6 @@ describe("TallyVotesNonQv", () => { verifierContract, vkRegistryContract, EMode.NON_QV, - { - gasLimit: 10000000, - }, ); const receipt = await tx.wait(); @@ -88,27 +85,13 @@ describe("TallyVotesNonQv", () => { const deployTime = block!.timestamp; expect(receipt?.status).to.eq(1); - const iface = maciContract.interface; - const logs = receipt!.logs[receipt!.logs.length - 1]; - const event = iface.parseLog(logs as unknown as { topics: string[]; data: string }) as unknown as { - args: { - _pollId: bigint; - pollAddr: { - poll: string; - messageProcessor: string; - tally: string; - }; - }; - name: string; - }; - expect(event.name).to.eq("DeployPoll"); - - pollId = event.args._pollId; + + pollId = (await maciContract.nextPollId()) - 1n; const pollContracts = await maciContract.getPoll(pollId); pollContract = PollFactory.connect(pollContracts.poll, signer); - mpContract = MessageProcessorFactory.connect(event.args.pollAddr.messageProcessor, signer); - tallyContract = TallyFactory.connect(event.args.pollAddr.tally, signer); + mpContract = MessageProcessorFactory.connect(pollContracts.messageProcessor, signer); + tallyContract = TallyFactory.connect(pollContracts.tally, signer); // deploy local poll const p = maciState.deployPoll(BigInt(deployTime + duration), maxValues, treeDepths, messageBatchSize, coordinator); @@ -145,7 +128,6 @@ describe("TallyVotesNonQv", () => { EMode.NON_QV, testProcessVk.asContractParam() as IVerifyingKeyStruct, testTallyVk.asContractParam() as IVerifyingKeyStruct, - { gasLimit: 1000000 }, ); }); diff --git a/contracts/tests/Verifier.test.ts b/contracts/tests/Verifier.test.ts index d48d737c0f..df381b8a4b 100644 --- a/contracts/tests/Verifier.test.ts +++ b/contracts/tests/Verifier.test.ts @@ -87,7 +87,6 @@ describe("DomainObjs", () => { proof, vk.asContractParam() as IVerifyingKeyStruct, publicInputs[0], - { gasLimit: 1000000 }, ); expect(isValid).to.eq(true); @@ -97,7 +96,6 @@ describe("DomainObjs", () => { proof, vk.asContractParam() as IVerifyingKeyStruct, BigInt(publicInputs[0]) + BigInt(1), - { gasLimit: 1000000 }, ); expect(isValid).to.eq(false); diff --git a/contracts/tests/VkRegistry.test.ts b/contracts/tests/VkRegistry.test.ts index ddb95923dc..a3ce0e0993 100644 --- a/contracts/tests/VkRegistry.test.ts +++ b/contracts/tests/VkRegistry.test.ts @@ -42,7 +42,6 @@ describe("VkRegistry", () => { EMode.QV, testProcessVk.asContractParam() as IVerifyingKeyStruct, testTallyVk.asContractParam() as IVerifyingKeyStruct, - { gasLimit: 1000000 }, ); const receipt = await tx.wait(); expect(receipt?.status).to.eq(1); @@ -59,7 +58,6 @@ describe("VkRegistry", () => { EMode.QV, testProcessVk.asContractParam() as IVerifyingKeyStruct, testTallyVk.asContractParam() as IVerifyingKeyStruct, - { gasLimit: 1000000 }, ), ).to.be.revertedWithCustomError(vkRegistryContract, "ProcessVkAlreadySet"); }); @@ -74,7 +72,6 @@ describe("VkRegistry", () => { EMode.QV, testProcessVk.asContractParam() as IVerifyingKeyStruct, testTallyVk.asContractParam() as IVerifyingKeyStruct, - { gasLimit: 1000000 }, ); const receipt = await tx.wait(); expect(receipt?.status).to.eq(1); @@ -90,7 +87,6 @@ describe("VkRegistry", () => { EMode.NON_QV, testProcessVk.asContractParam() as IVerifyingKeyStruct, testTallyVk.asContractParam() as IVerifyingKeyStruct, - { gasLimit: 1000000 }, ); const receipt = await tx.wait(); expect(receipt?.status).to.eq(1); @@ -108,7 +104,6 @@ describe("VkRegistry", () => { [EMode.NON_QV], [testProcessVkNonQv.asContractParam() as IVerifyingKeyStruct], [testTallyVkNonQv.asContractParam() as IVerifyingKeyStruct], - { gasLimit: 1000000 }, ); const receipt = await tx.wait(); @@ -129,7 +124,6 @@ describe("VkRegistry", () => { testProcessVkNonQv.asContractParam() as IVerifyingKeyStruct, ], [testTallyVk.asContractParam() as IVerifyingKeyStruct], - { gasLimit: 1000000 }, ), ).to.be.revertedWithCustomError(vkRegistryContract, "InvalidKeysParams"); }); diff --git a/contracts/tests/ZupassGatekeeper.test.ts b/contracts/tests/ZupassGatekeeper.test.ts index d7e4e45e9e..360b77318c 100644 --- a/contracts/tests/ZupassGatekeeper.test.ts +++ b/contracts/tests/ZupassGatekeeper.test.ts @@ -46,8 +46,9 @@ describe("Zupass Gatekeeper", () => { }); describe("Deployment", () => { - it("The gatekeeper should be deployed correctly", () => { + it("The gatekeeper should be deployed correctly", async () => { expect(zupassGatekeeper).to.not.eq(undefined); + expect(await zupassGatekeeper.getAddress()).to.not.eq(ZeroAddress); }); });