Skip to content

Commit

Permalink
fix(group): after a sequence of updates a proof is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauman committed Dec 7, 2024
1 parent b5bed1c commit 5a510c3
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions packages/contracts/test/Semaphore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,39 +476,35 @@ describe("Semaphore", () => {
const group = new Group(members)

// Create a group and add 3 members.
let transaction = await semaphoreContract["createGroup(address)"](accountAddresses[0])

const { logs } = (await transaction.wait()) as any
await semaphoreContract["createGroup(address)"](accountAddresses[0])

const [groupId] = logs[0].args
const groupId = 2

// Adding members to group

transaction = await semaphoreContract.addMembers(groupId, members)
await transaction.wait()
await semaphoreContract.addMembers(groupId, members)

// Remove the third member.
{
group.removeMember(2)
const { siblings } = group.generateMerkleProof(2)

transaction = await semaphoreContract.removeMember(groupId, members[2], siblings)
await transaction.wait()
await semaphoreContract.removeMember(groupId, members[2], siblings)
}

// Update the second member.
{
group.updateMember(1, members[2])
const { siblings } = group.generateMerkleProof(1)

transaction = await semaphoreContract.updateMember(groupId, members[1], members[2], siblings)
await transaction.wait()
await semaphoreContract.updateMember(groupId, members[1], members[2], siblings)
}

// Validate a proof.

const proof = await generateProof(identity, group, 42, group.root)

transaction = await semaphoreContract.validateProof(groupId, proof)
const transaction = await semaphoreContract.validateProof(groupId, proof)

await expect(transaction)
.to.emit(semaphoreContract, "ProofValidated")
Expand Down

0 comments on commit 5a510c3

Please sign in to comment.