Skip to content

Commit

Permalink
Merge pull request #705 from semaphore-protocol/test/add-contracts-tests
Browse files Browse the repository at this point in the history
Add contract tests
  • Loading branch information
cedoor authored Mar 14, 2024
2 parents 87b48ca + e1481b8 commit dcaba25
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/contracts/test/Semaphore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,30 @@ describe("Semaphore", () => {
"Semaphore__MerkleTreeRootIsExpired"
)
})

it("Should not verify a proof if the Merkle depth is not supported", async () => {
const scope = "random-scope"

const proof = await generateProof(identity, group, message, scope, merkleTreeDepth)

proof.merkleTreeDepth = 33

const transaction = semaphoreContract.verifyProof(groupId, proof)

await expect(transaction).to.be.revertedWithCustomError(
semaphoreContract,
"Semaphore__MerkleTreeDepthIsNotSupported"
)
})

it("Should not verify a proof if the group has no members", async () => {
const groupId = 6
await semaphoreContract["createGroup(address)"](accountAddresses[0])

const transaction = semaphoreContract.verifyProof(groupId, proof)

await expect(transaction).to.be.revertedWithCustomError(semaphoreContract, "Semaphore__GroupHasNoMembers")
})
})

describe("# validateProof", () => {
Expand Down

0 comments on commit dcaba25

Please sign in to comment.