diff --git a/packages/contracts/test/Semaphore.ts b/packages/contracts/test/Semaphore.ts index c72619bc2..2e53c83bd 100644 --- a/packages/contracts/test/Semaphore.ts +++ b/packages/contracts/test/Semaphore.ts @@ -463,9 +463,62 @@ describe("Semaphore", () => { const proof = await generateProof(identity, group, message, group.root, merkleTreeDepth) - return { semaphoreContract, groupId, proof } + return { semaphoreContract, groupId, proof, accountAddresses } } + it("Should insert members,remove member,update member and verifyProof", async () => { + const { semaphoreContract, accountAddresses } = await loadFixture(deployValidateProofFixture) + + const identity = new Identity("0") + const members = Array.from({ length: 3 }, (_, i) => new Identity(i.toString())).map( + ({ commitment }) => commitment + ) + const group = new Group(members) + + // Create a group and add 3 members. + await semaphoreContract["createGroup(address)"](accountAddresses[0]) + + const groupId = 2 + + // Adding members to group + + await semaphoreContract.addMembers(groupId, members) + + // Remove the third member. + { + group.removeMember(2) + const { siblings } = group.generateMerkleProof(2) + + await semaphoreContract.removeMember(groupId, members[2], siblings) + } + + // Update the second member. + { + group.updateMember(1, members[2]) + const { siblings } = group.generateMerkleProof(1) + + await semaphoreContract.updateMember(groupId, members[1], members[2], siblings) + } + + // Validate a proof. + + const proof = await generateProof(identity, group, 42, group.root) + + const transaction = await semaphoreContract.validateProof(groupId, proof) + + await expect(transaction) + .to.emit(semaphoreContract, "ProofValidated") + .withArgs( + groupId, + proof.merkleTreeDepth, + proof.merkleTreeRoot, + proof.nullifier, + proof.message, + proof.merkleTreeRoot, + proof.points + ) + }) + it("Should throw an exception if the proof is not valid", async () => { const { semaphoreContract, groupId, proof } = await loadFixture(deployValidateProofFixture) diff --git a/packages/group/package.json b/packages/group/package.json index 87f7b640d..3d8ec26fe 100644 --- a/packages/group/package.json +++ b/packages/group/package.json @@ -36,7 +36,7 @@ "rollup-plugin-cleanup": "^3.2.1" }, "dependencies": { - "@zk-kit/lean-imt": "2.2.1", + "@zk-kit/lean-imt": "2.2.2", "@zk-kit/utils": "1.2.1", "poseidon-lite": "0.3.0" } diff --git a/yarn.lock b/yarn.lock index 24645aa32..30ce0fd67 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7451,7 +7451,7 @@ __metadata: resolution: "@semaphore-protocol/group@workspace:packages/group" dependencies: "@rollup/plugin-typescript": "npm:^11.1.6" - "@zk-kit/lean-imt": "npm:2.2.1" + "@zk-kit/lean-imt": "npm:2.2.2" "@zk-kit/utils": "npm:1.2.1" poseidon-lite: "npm:0.3.0" rimraf: "npm:^5.0.5" @@ -9589,12 +9589,12 @@ __metadata: languageName: node linkType: hard -"@zk-kit/lean-imt@npm:2.2.1": - version: 2.2.1 - resolution: "@zk-kit/lean-imt@npm:2.2.1" +"@zk-kit/lean-imt@npm:2.2.2": + version: 2.2.2 + resolution: "@zk-kit/lean-imt@npm:2.2.2" dependencies: "@zk-kit/utils": "npm:1.2.1" - checksum: 10/f57ba0ab15ff38609c352862b21023d370bd250c37c7ef15d4ee7724c8179a7fdd6647ac8a555e6cf523032d1c769fb9eae6de5364a97574224ff7de1a34f8a8 + checksum: 10/321e1964a4a0b7a19083c01743f5ee2a7311b1eede6775ce952a6fecf07d347dc4cdb250a557ff459bc6d3bff030e2a571f5116510c2392ca523f50c4d02311d languageName: node linkType: hard