test(contracts): assert only admin can add members

This commit is contained in:
zkFriendly
2024-03-13 23:11:58 +01:00
parent bfe050d16b
commit 4e4b4e629a

View File

@@ -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)]