@@ -17,6 +17,7 @@ describe("Semaphore", () => {
17
17
18
18
const treeDepth = Number ( process . env . TREE_DEPTH ) || 20
19
19
const groupId = 1
20
+ const group = new Group ( groupId , treeDepth )
20
21
const members = createIdentityCommitments ( 3 )
21
22
22
23
const wasmFilePath = `../../snark-artifacts/${ treeDepth } /semaphore.wasm`
@@ -36,12 +37,7 @@ describe("Semaphore", () => {
36
37
37
38
describe ( "# createGroup" , ( ) => {
38
39
it ( "Should not create a group if the tree depth is not supported" , async ( ) => {
39
- const transaction = semaphoreContract [ "createGroup(uint256,uint256,uint256,address)" ] (
40
- groupId ,
41
- 10 ,
42
- 0 ,
43
- accounts [ 0 ]
44
- )
40
+ const transaction = semaphoreContract [ "createGroup(uint256,uint256,address)" ] ( groupId , 10 , accounts [ 0 ] )
45
41
46
42
await expect ( transaction ) . to . be . revertedWithCustomError (
47
43
semaphoreContract ,
@@ -52,30 +48,34 @@ describe("Semaphore", () => {
52
48
it ( "Should create a group" , async ( ) => {
53
49
const transaction = semaphoreContract
54
50
. connect ( signers [ 1 ] )
55
- [ "createGroup(uint256,uint256,uint256, address)" ] ( groupId , treeDepth , 0 , accounts [ 1 ] )
51
+ [ "createGroup(uint256,uint256,address)" ] ( groupId , treeDepth , accounts [ 1 ] )
56
52
57
- await expect ( transaction ) . to . emit ( semaphoreContract , "GroupCreated" ) . withArgs ( groupId , treeDepth , 0 )
53
+ await expect ( transaction )
54
+ . to . emit ( semaphoreContract , "GroupCreated" )
55
+ . withArgs ( groupId , treeDepth , group . zeroValue )
58
56
await expect ( transaction )
59
57
. to . emit ( semaphoreContract , "GroupAdminUpdated" )
60
58
. withArgs ( groupId , constants . AddressZero , accounts [ 1 ] )
61
59
} )
62
60
63
61
it ( "Should create a group with a custom Merkle tree root expiration" , async ( ) => {
64
62
const groupId = 2
63
+ const group = new Group ( 2 )
65
64
const transaction = await semaphoreContract
66
65
. connect ( signers [ 1 ] )
67
- [ "createGroup(uint256,uint256,uint256, address,uint256)" ] (
66
+ [ "createGroup(uint256,uint256,address,uint256)" ] (
68
67
groupId ,
69
68
treeDepth ,
70
- 0 ,
71
69
accounts [ 0 ] ,
72
70
5 // 5 seconds.
73
71
)
74
72
await semaphoreContract . addMember ( groupId , members [ 0 ] )
75
73
await semaphoreContract . addMember ( groupId , members [ 1 ] )
76
74
await semaphoreContract . addMember ( groupId , members [ 2 ] )
77
75
78
- await expect ( transaction ) . to . emit ( semaphoreContract , "GroupCreated" ) . withArgs ( groupId , treeDepth , 0 )
76
+ await expect ( transaction )
77
+ . to . emit ( semaphoreContract , "GroupCreated" )
78
+ . withArgs ( groupId , treeDepth , group . zeroValue )
79
79
await expect ( transaction )
80
80
. to . emit ( semaphoreContract , "GroupAdminUpdated" )
81
81
. withArgs ( groupId , constants . AddressZero , accounts [ 0 ] )
@@ -133,7 +133,7 @@ describe("Semaphore", () => {
133
133
} )
134
134
135
135
it ( "Should add a new member in an existing group" , async ( ) => {
136
- const group = new Group ( treeDepth )
136
+ const group = new Group ( groupId , treeDepth )
137
137
138
138
group . addMember ( members [ 0 ] )
139
139
@@ -149,11 +149,11 @@ describe("Semaphore", () => {
149
149
it ( "Should add new members to an existing group" , async ( ) => {
150
150
const groupId = 3
151
151
const members = [ BigInt ( 1 ) , BigInt ( 2 ) , BigInt ( 3 ) ]
152
- const group = new Group ( treeDepth )
152
+ const group = new Group ( groupId , treeDepth )
153
153
154
154
group . addMembers ( members )
155
155
156
- await semaphoreContract [ "createGroup(uint256,uint256,uint256, address)" ] ( groupId , treeDepth , 0 , accounts [ 0 ] )
156
+ await semaphoreContract [ "createGroup(uint256,uint256,address)" ] ( groupId , treeDepth , accounts [ 0 ] )
157
157
158
158
const transaction = semaphoreContract . addMembers ( groupId , members )
159
159
@@ -178,13 +178,13 @@ describe("Semaphore", () => {
178
178
it ( "Should update a member from an existing group" , async ( ) => {
179
179
const groupId = 4
180
180
const members = [ BigInt ( 1 ) , BigInt ( 2 ) , BigInt ( 3 ) ]
181
- const group = new Group ( treeDepth )
181
+ const group = new Group ( groupId , treeDepth )
182
182
183
183
group . addMembers ( members )
184
184
185
185
group . updateMember ( 0 , BigInt ( 4 ) )
186
186
187
- await semaphoreContract [ "createGroup(uint256,uint256,uint256, address)" ] ( groupId , treeDepth , 0 , accounts [ 0 ] )
187
+ await semaphoreContract [ "createGroup(uint256,uint256,address)" ] ( groupId , treeDepth , accounts [ 0 ] )
188
188
await semaphoreContract . addMembers ( groupId , members )
189
189
190
190
const { siblings, pathIndices, root } = group . generateMerkleProof ( 0 )
@@ -212,13 +212,13 @@ describe("Semaphore", () => {
212
212
it ( "Should remove a member from an existing group" , async ( ) => {
213
213
const groupId = 5
214
214
const members = [ BigInt ( 1 ) , BigInt ( 2 ) , BigInt ( 3 ) ]
215
- const group = new Group ( treeDepth )
215
+ const group = new Group ( groupId , treeDepth )
216
216
217
217
group . addMembers ( members )
218
218
219
219
group . removeMember ( 2 )
220
220
221
- await semaphoreContract [ "createGroup(uint256,uint256,uint256, address)" ] ( groupId , treeDepth , 0 , accounts [ 0 ] )
221
+ await semaphoreContract [ "createGroup(uint256,uint256,address)" ] ( groupId , treeDepth , accounts [ 0 ] )
222
222
await semaphoreContract . addMembers ( groupId , members )
223
223
224
224
const { siblings, pathIndices, root } = group . generateMerkleProof ( 2 )
@@ -233,7 +233,7 @@ describe("Semaphore", () => {
233
233
const signal = 2
234
234
const identity = new Identity ( "0" )
235
235
236
- const group = new Group ( treeDepth )
236
+ const group = new Group ( groupId , treeDepth )
237
237
238
238
group . addMembers ( members )
239
239
@@ -317,7 +317,7 @@ describe("Semaphore", () => {
317
317
318
318
it ( "Should not verify a proof if the Merkle tree root is expired" , async ( ) => {
319
319
const groupId = 2
320
- const group = new Group ( treeDepth )
320
+ const group = new Group ( groupId , treeDepth )
321
321
322
322
group . addMembers ( [ members [ 0 ] , members [ 1 ] ] )
323
323
0 commit comments