@@ -55,80 +55,134 @@ describe("EASExcubia", function () {
55
55
} )
56
56
57
57
describe ( "EASExcubia" , function ( ) {
58
- it ( "should fail to set the gate when the caller is not the owner" , async ( ) => {
59
- const [ , notOwnerSigner ] = await ethers . getSigners ( )
60
-
61
- await expect ( easExcubia . connect ( notOwnerSigner ) . setGate ( gateAddress ) ) . to . be . revertedWithCustomError (
62
- easExcubia ,
63
- "OwnableUnauthorizedAccount"
64
- )
65
- } )
66
-
67
- it ( "should fail to set the gate when the gate address is zero" , async ( ) => {
68
- await expect ( easExcubia . setGate ( ZeroAddress ) ) . to . be . revertedWithCustomError ( easExcubia , "ZeroAddress" )
69
- } )
70
-
71
- it ( "Should set the gate contract address correctly" , async function ( ) {
72
- await easExcubia . setGate ( gateAddress ) . then ( ( tx ) => tx . wait ( ) )
73
-
74
- expect ( await easExcubia . gate ( ) ) . to . eq ( gateAddress )
75
- } )
76
-
77
- it ( "Should fail to set the gate if already set" , async function ( ) {
78
- await expect ( easExcubia . setGate ( gateAddress ) ) . to . be . revertedWithCustomError ( easExcubia , "GateAlreadySet" )
79
- } )
80
-
81
- it ( "should throw when the callee is not the gate" , async ( ) => {
82
- await expect (
83
- easExcubia . connect ( signer ) . pass ( signerAddress , invalidRecipientAttestationId )
84
- ) . to . be . revertedWithCustomError ( easExcubia , "GateOnly" )
85
- } )
86
-
87
- it ( "should throw when the attestation is not owned by the correct recipient" , async ( ) => {
88
- await expect (
89
- easExcubia . connect ( gate ) . pass ( signerAddress , invalidRecipientAttestationId )
90
- ) . to . be . revertedWithCustomError ( easExcubia , "UnexpectedRecipient" )
91
- } )
92
-
93
- it ( "should throw when the attestation has been revoked" , async ( ) => {
94
- await expect (
95
- easExcubia . connect ( gate ) . pass ( signerAddress , revokedAttestationId )
96
- ) . to . be . revertedWithCustomError ( easExcubia , "RevokedAttestation" )
97
- } )
58
+ describe ( "setGate()" , function ( ) {
59
+ it ( "should fail to set the gate when the caller is not the owner" , async ( ) => {
60
+ const [ , notOwnerSigner ] = await ethers . getSigners ( )
61
+
62
+ await expect ( easExcubia . connect ( notOwnerSigner ) . setGate ( gateAddress ) ) . to . be . revertedWithCustomError (
63
+ easExcubia ,
64
+ "OwnableUnauthorizedAccount"
65
+ )
66
+ } )
67
+
68
+ it ( "should fail to set the gate when the gate address is zero" , async ( ) => {
69
+ await expect ( easExcubia . setGate ( ZeroAddress ) ) . to . be . revertedWithCustomError ( easExcubia , "ZeroAddress" )
70
+ } )
71
+
72
+ it ( "Should set the gate contract address correctly" , async function ( ) {
73
+ const tx = await easExcubia . setGate ( gateAddress )
74
+ const receipt = await tx . wait ( )
75
+ const event = EASExcubiaContract . interface . parseLog (
76
+ receipt ?. logs [ 0 ] as unknown as { topics : string [ ] ; data : string }
77
+ ) as unknown as {
78
+ args : {
79
+ gate : string
80
+ }
81
+ }
98
82
99
- it ( "should throw when the attestation schema is not the one expected" , async ( ) => {
100
- await expect (
101
- easExcubia . connect ( gate ) . pass ( signerAddress , invalidSchemaAttestationId )
102
- ) . to . be . revertedWithCustomError ( easExcubia , "UnexpectedSchema" )
83
+ expect ( receipt ?. status ) . to . eq ( 1 )
84
+ expect ( event . args . gate ) . to . eq ( gateAddress )
85
+ expect ( await easExcubia . gate ( ) ) . to . eq ( gateAddress )
86
+ } )
87
+
88
+ it ( "Should fail to set the gate if already set" , async function ( ) {
89
+ await expect ( easExcubia . setGate ( gateAddress ) ) . to . be . revertedWithCustomError (
90
+ easExcubia ,
91
+ "GateAlreadySet"
92
+ )
93
+ } )
103
94
} )
104
95
105
- it ( "should throw when the attestation is not signed by the attestation owner" , async ( ) => {
106
- await expect (
107
- easExcubia . connect ( gate ) . pass ( signerAddress , invalidAttesterAttestationId )
108
- ) . to . be . revertedWithCustomError ( easExcubia , "UnexpectedAttester" )
96
+ describe ( "check()" , function ( ) {
97
+ it ( "should throw when the attestation is not owned by the correct recipient" , async ( ) => {
98
+ await expect (
99
+ easExcubia . check ( signerAddress , invalidRecipientAttestationId )
100
+ ) . to . be . revertedWithCustomError ( easExcubia , "UnexpectedRecipient" )
101
+ } )
102
+
103
+ it ( "should throw when the attestation has been revoked" , async ( ) => {
104
+ await expect ( easExcubia . check ( signerAddress , revokedAttestationId ) ) . to . be . revertedWithCustomError (
105
+ easExcubia ,
106
+ "RevokedAttestation"
107
+ )
108
+ } )
109
+
110
+ it ( "should throw when the attestation schema is not the one expected" , async ( ) => {
111
+ await expect ( easExcubia . check ( signerAddress , invalidSchemaAttestationId ) ) . to . be . revertedWithCustomError (
112
+ easExcubia ,
113
+ "UnexpectedSchema"
114
+ )
115
+ } )
116
+
117
+ it ( "should throw when the attestation is not signed by the attestation owner" , async ( ) => {
118
+ await expect (
119
+ easExcubia . check ( signerAddress , invalidAttesterAttestationId )
120
+ ) . to . be . revertedWithCustomError ( easExcubia , "UnexpectedAttester" )
121
+ } )
122
+
123
+ it ( "should pass the check" , async ( ) => {
124
+ const passed = await easExcubia . check ( signerAddress , validAttestationId )
125
+
126
+ expect ( passed ) . to . be . true
127
+ // check does NOT change the state of the contract (see pass()).
128
+ expect ( await easExcubia . registeredAttestations ( validAttestationId ) ) . to . be . false
129
+ } )
109
130
} )
110
131
111
- it ( "should pass the check" , async ( ) => {
112
- const tx = await easExcubia . connect ( gate ) . pass ( signerAddress , validAttestationId )
113
- const receipt = await tx . wait ( )
114
- const event = EASExcubiaContract . interface . parseLog (
115
- receipt ?. logs [ 0 ] as unknown as { topics : string [ ] ; data : string }
116
- ) as unknown as {
117
- args : {
118
- passerby : string
119
- gate : string
132
+ describe ( "pass()" , function ( ) {
133
+ it ( "should throw when the callee is not the gate" , async ( ) => {
134
+ await expect (
135
+ easExcubia . connect ( signer ) . pass ( signerAddress , invalidRecipientAttestationId )
136
+ ) . to . be . revertedWithCustomError ( easExcubia , "GateOnly" )
137
+ } )
138
+
139
+ it ( "should throw when the attestation is not owned by the correct recipient" , async ( ) => {
140
+ await expect (
141
+ easExcubia . connect ( gate ) . pass ( signerAddress , invalidRecipientAttestationId )
142
+ ) . to . be . revertedWithCustomError ( easExcubia , "UnexpectedRecipient" )
143
+ } )
144
+
145
+ it ( "should throw when the attestation has been revoked" , async ( ) => {
146
+ await expect (
147
+ easExcubia . connect ( gate ) . pass ( signerAddress , revokedAttestationId )
148
+ ) . to . be . revertedWithCustomError ( easExcubia , "RevokedAttestation" )
149
+ } )
150
+
151
+ it ( "should throw when the attestation schema is not the one expected" , async ( ) => {
152
+ await expect (
153
+ easExcubia . connect ( gate ) . pass ( signerAddress , invalidSchemaAttestationId )
154
+ ) . to . be . revertedWithCustomError ( easExcubia , "UnexpectedSchema" )
155
+ } )
156
+
157
+ it ( "should throw when the attestation is not signed by the attestation owner" , async ( ) => {
158
+ await expect (
159
+ easExcubia . connect ( gate ) . pass ( signerAddress , invalidAttesterAttestationId )
160
+ ) . to . be . revertedWithCustomError ( easExcubia , "UnexpectedAttester" )
161
+ } )
162
+
163
+ it ( "should pass the check" , async ( ) => {
164
+ const tx = await easExcubia . connect ( gate ) . pass ( signerAddress , validAttestationId )
165
+ const receipt = await tx . wait ( )
166
+ const event = EASExcubiaContract . interface . parseLog (
167
+ receipt ?. logs [ 0 ] as unknown as { topics : string [ ] ; data : string }
168
+ ) as unknown as {
169
+ args : {
170
+ passerby : string
171
+ gate : string
172
+ }
120
173
}
121
- }
122
-
123
- expect ( receipt ?. status ) . to . eq ( 1 )
124
- expect ( event . args . passerby ) . to . eq ( signerAddress )
125
- expect ( event . args . gate ) . to . eq ( gateAddress )
126
- } )
127
174
128
- it ( "should prevent to pass twice" , async ( ) => {
129
- await expect (
130
- easExcubia . connect ( gate ) . pass ( signerAddress , validAttestationId )
131
- ) . to . be . revertedWithCustomError ( easExcubia , "AlreadyRegistered" )
175
+ expect ( receipt ?. status ) . to . eq ( 1 )
176
+ expect ( event . args . passerby ) . to . eq ( signerAddress )
177
+ expect ( event . args . gate ) . to . eq ( gateAddress )
178
+ expect ( await easExcubia . registeredAttestations ( validAttestationId ) ) . to . be . true
179
+ } )
180
+
181
+ it ( "should prevent to pass twice" , async ( ) => {
182
+ await expect (
183
+ easExcubia . connect ( gate ) . pass ( signerAddress , validAttestationId )
184
+ ) . to . be . revertedWithCustomError ( easExcubia , "AlreadyRegistered" )
185
+ } )
132
186
} )
133
187
} )
134
188
} )
0 commit comments