@@ -4,23 +4,28 @@ const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers');
4
4
5
5
const { packValidationData, UserOperation } = require ( '../../helpers/erc4337' ) ;
6
6
const { MAX_UINT48 } = require ( '../../helpers/constants' ) ;
7
- const time = require ( '../../helpers/time' ) ;
8
7
const ADDRESS_ONE = '0x0000000000000000000000000000000000000001' ;
9
8
10
9
const fixture = async ( ) => {
11
- const [ authorizer , sender , factory , paymaster , other ] = await ethers . getSigners ( ) ;
10
+ const [ authorizer , sender , factory , paymaster ] = await ethers . getSigners ( ) ;
12
11
const utils = await ethers . deployContract ( '$ERC4337Utils' ) ;
13
12
const SIG_VALIDATION_SUCCESS = await utils . $SIG_VALIDATION_SUCCESS ( ) ;
14
13
const SIG_VALIDATION_FAILED = await utils . $SIG_VALIDATION_FAILED ( ) ;
15
14
16
- return { utils, authorizer, sender, factory, paymaster, other , SIG_VALIDATION_SUCCESS , SIG_VALIDATION_FAILED } ;
15
+ return { utils, authorizer, sender, factory, paymaster, SIG_VALIDATION_SUCCESS , SIG_VALIDATION_FAILED } ;
17
16
} ;
18
17
19
18
describe ( 'ERC4337Utils' , function ( ) {
20
19
beforeEach ( async function ( ) {
21
20
Object . assign ( this , await loadFixture ( fixture ) ) ;
22
21
} ) ;
23
22
23
+ describe ( 'entrypoint' , function ( ) {
24
+ it ( 'v0.7.0' , async function ( ) {
25
+ await expect ( this . utils . $ENTRYPOINT_V07 ( ) ) . to . eventually . equal ( entrypoint ) ;
26
+ } ) ;
27
+ } ) ;
28
+
24
29
describe ( 'parseValidationData' , function ( ) {
25
30
it ( 'parses the validation data' , async function ( ) {
26
31
const authorizer = this . authorizer ;
@@ -285,68 +290,4 @@ describe('ERC4337Utils', function () {
285
290
} ) ;
286
291
} ) ;
287
292
} ) ;
288
-
289
- describe ( 'stake management' , function ( ) {
290
- const unstakeDelaySec = 3600n ;
291
-
292
- beforeEach ( async function ( ) {
293
- await this . authorizer . sendTransaction ( { to : this . utils , value : ethers . parseEther ( '1' ) } ) ;
294
- } ) ;
295
-
296
- it ( 'deposit & withdraw' , async function ( ) {
297
- await expect ( entrypoint . balanceOf ( this . utils ) ) . to . eventually . equal ( 0n ) ;
298
-
299
- // deposit
300
- await expect ( this . utils . $depositTo ( this . utils , 42n ) ) . to . changeEtherBalances (
301
- [ this . utils , entrypoint ] ,
302
- [ - 42n , 42n ] ,
303
- ) ;
304
-
305
- await expect ( entrypoint . balanceOf ( this . utils ) ) . to . eventually . equal ( 42n ) ;
306
-
307
- // withdraw
308
- await expect ( this . utils . $withdrawTo ( this . other , 17n ) ) . to . changeEtherBalances (
309
- [ entrypoint , this . other ] ,
310
- [ - 17n , 17n ] ,
311
- ) ;
312
-
313
- await expect ( entrypoint . balanceOf ( this . utils ) ) . to . eventually . equal ( 25n ) ; // 42 - 17
314
- } ) ;
315
-
316
- it ( 'stake, unlock & withdraw stake' , async function ( ) {
317
- await expect ( entrypoint . deposits ( this . utils ) ) . to . eventually . deep . equal ( [ 0n , false , 0n , 0n , 0n ] ) ;
318
-
319
- // stake
320
- await expect ( this . utils . $addStake ( 42n , unstakeDelaySec ) ) . to . changeEtherBalances (
321
- [ this . utils , entrypoint ] ,
322
- [ - 42n , 42n ] ,
323
- ) ;
324
-
325
- await expect ( entrypoint . deposits ( this . utils ) ) . to . eventually . deep . equal ( [ 0n , true , 42n , unstakeDelaySec , 0n ] ) ;
326
-
327
- // unlock
328
- const unlockTx = this . utils . $unlockStake ( ) ;
329
- await expect ( unlockTx ) . to . changeEtherBalances ( [ this . utils , entrypoint ] , [ 0n , 0n ] ) ; // no ether movement
330
-
331
- const timestamp = await time . clockFromReceipt . timestamp ( unlockTx ) ;
332
- await expect ( entrypoint . deposits ( this . utils ) ) . to . eventually . deep . equal ( [
333
- 0n ,
334
- false ,
335
- 42n ,
336
- unstakeDelaySec ,
337
- timestamp + unstakeDelaySec ,
338
- ] ) ;
339
-
340
- // wait
341
- await time . increaseBy . timestamp ( unstakeDelaySec ) ;
342
-
343
- // withdraw stake
344
- await expect ( this . utils . $withdrawStake ( this . other ) ) . to . changeEtherBalances (
345
- [ this . utils , entrypoint , this . other ] ,
346
- [ 0n , - 42n , 42n ] ,
347
- ) ;
348
-
349
- await expect ( entrypoint . deposits ( this . utils ) ) . to . eventually . deep . equal ( [ 0n , false , 0n , 0n , 0n ] ) ;
350
- } ) ;
351
- } ) ;
352
293
} ) ;
0 commit comments