From 4e4b4e629ae90e6e7963d0db96558405abb57f6d Mon Sep 17 00:00:00 2001 From: zkFriendly Date: Wed, 13 Mar 2024 23:11:58 +0100 Subject: [PATCH] test(contracts): assert only admin can add members --- packages/contracts/test/Semaphore.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/contracts/test/Semaphore.ts b/packages/contracts/test/Semaphore.ts index 4ca01e7c..52929e60 100644 --- a/packages/contracts/test/Semaphore.ts +++ b/packages/contracts/test/Semaphore.ts @@ -32,7 +32,7 @@ describe("Semaphore", () => { it("Should create a group", async () => { const transaction = semaphoreContract .connect(accounts[1]) - ["createGroup(uint256,address)"](groupId, accountAddresses[1]) + ["createGroup(uint256,address)"](groupId, accountAddresses[1]) await expect(transaction).to.emit(semaphoreContract, "GroupCreated").withArgs(groupId) await expect(transaction) @@ -122,6 +122,17 @@ describe("Semaphore", () => { }) describe("# addMembers", () => { + it("Should not add members if the caller is not the group admin", async () => { + const members = [BigInt(1), BigInt(2), BigInt(3)] + + const transaction = semaphoreContract.connect(accounts[1]).addMembers(groupId, members) + + await expect(transaction).to.be.revertedWithCustomError( + semaphoreContract, + "Semaphore__CallerIsNotTheGroupAdmin" + ) + }) + it("Should add new members to an existing group", async () => { const groupId = 3 const members = [BigInt(1), BigInt(2), BigInt(3)]