@@ -135,23 +135,29 @@ function shouldBehaveLikePaymaster({ postOp } = { postOp: false }) {
135
135
136
136
describe ( 'postOp' , function ( ) {
137
137
it ( 'reverts if the caller is not the entrypoint' , async function ( ) {
138
- await expect ( this . paymaster . connect ( this . other ) . postOp ( 0 , '0x' , 0 , 0 ) )
138
+ await expect ( this . paymaster . connect ( this . other ) . postOp ( 0n , '0x' , 0n , 0n ) )
139
139
. to . be . revertedWithCustomError ( this . paymaster , 'PaymasterUnauthorized' )
140
140
. withArgs ( this . other ) ;
141
141
} ) ;
142
142
} ) ;
143
143
144
144
describe ( 'deposit lifecycle' , function ( ) {
145
145
it ( 'deposits and withdraws effectively' , async function ( ) {
146
+ await expect ( entrypoint . balanceOf ( this . paymaster ) ) . to . eventually . equal ( 0n ) ;
147
+
146
148
await expect ( this . paymaster . connect ( this . other ) . deposit ( { value } ) ) . to . changeEtherBalances (
147
149
[ this . other , entrypoint ] ,
148
150
[ - value , value ] ,
149
151
) ;
150
152
151
- await expect ( this . paymaster . connect ( this . admin ) . withdraw ( this . receiver , value ) ) . to . changeEtherBalances (
153
+ await expect ( entrypoint . balanceOf ( this . paymaster ) ) . to . eventually . equal ( value ) ;
154
+
155
+ await expect ( this . paymaster . connect ( this . admin ) . withdraw ( this . receiver , 1n ) ) . to . changeEtherBalances (
152
156
[ entrypoint , this . receiver ] ,
153
- [ - value , value ] ,
157
+ [ - 1n , 1n ] ,
154
158
) ;
159
+
160
+ await expect ( entrypoint . balanceOf ( this . paymaster ) ) . to . eventually . equal ( value - 1n ) ;
155
161
} ) ;
156
162
157
163
it ( 'reverts when an unauthorized caller tries to withdraw' , async function ( ) {
@@ -163,20 +169,37 @@ function shouldBehaveLikePaymaster({ postOp } = { postOp: false }) {
163
169
164
170
describe ( 'stake lifecycle' , function ( ) {
165
171
it ( 'adds and removes stake effectively' , async function ( ) {
172
+ await expect ( entrypoint . deposits ( this . paymaster ) ) . to . eventually . deep . equal ( [ 0n , false , 0n , 0n , 0n ] ) ;
173
+
166
174
// stake
167
175
await expect ( this . paymaster . connect ( this . other ) . addStake ( delay , { value } ) ) . to . changeEtherBalances (
168
176
[ this . other , entrypoint ] ,
169
177
[ - value , value ] ,
170
178
) ;
179
+
180
+ await expect ( entrypoint . deposits ( this . paymaster ) ) . to . eventually . deep . equal ( [ 0n , true , 42n , delay , 0n ] ) ;
181
+
171
182
// unlock
172
- await this . paymaster . connect ( this . admin ) . unlockStake ( ) ;
183
+ const unlockTx = this . paymaster . connect ( this . admin ) . unlockStake ( ) ;
184
+
185
+ const timestamp = await time . clockFromReceipt . timestamp ( unlockTx ) ;
186
+ await expect ( entrypoint . deposits ( this . paymaster ) ) . to . eventually . deep . equal ( [
187
+ 0n ,
188
+ false ,
189
+ 42n ,
190
+ delay ,
191
+ timestamp + delay ,
192
+ ] ) ;
193
+
173
194
await time . increaseBy . timestamp ( delay ) ;
174
195
175
196
// withdraw stake
176
197
await expect ( this . paymaster . connect ( this . admin ) . withdrawStake ( this . receiver ) ) . to . changeEtherBalances (
177
198
[ entrypoint , this . receiver ] ,
178
199
[ - value , value ] ,
179
200
) ;
201
+
202
+ await expect ( entrypoint . deposits ( this . paymaster ) ) . to . eventually . deep . equal ( [ 0n , false , 0n , 0n , 0n ] ) ;
180
203
} ) ;
181
204
182
205
it ( 'reverts when an unauthorized caller tries to unlock stake' , async function ( ) {
0 commit comments