@@ -4,23 +4,28 @@ const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers');
44
55const { packValidationData, UserOperation } = require ( '../../helpers/erc4337' ) ;
66const { MAX_UINT48 } = require ( '../../helpers/constants' ) ;
7- const time = require ( '../../helpers/time' ) ;
87const ADDRESS_ONE = '0x0000000000000000000000000000000000000001' ;
98
109const fixture = async ( ) => {
11- const [ authorizer , sender , factory , paymaster , other ] = await ethers . getSigners ( ) ;
10+ const [ authorizer , sender , factory , paymaster ] = await ethers . getSigners ( ) ;
1211 const utils = await ethers . deployContract ( '$ERC4337Utils' ) ;
1312 const SIG_VALIDATION_SUCCESS = await utils . $SIG_VALIDATION_SUCCESS ( ) ;
1413 const SIG_VALIDATION_FAILED = await utils . $SIG_VALIDATION_FAILED ( ) ;
1514
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 } ;
1716} ;
1817
1918describe ( 'ERC4337Utils' , function ( ) {
2019 beforeEach ( async function ( ) {
2120 Object . assign ( this , await loadFixture ( fixture ) ) ;
2221 } ) ;
2322
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+
2429 describe ( 'parseValidationData' , function ( ) {
2530 it ( 'parses the validation data' , async function ( ) {
2631 const authorizer = this . authorizer ;
@@ -285,68 +290,4 @@ describe('ERC4337Utils', function () {
285290 } ) ;
286291 } ) ;
287292 } ) ;
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- } ) ;
352293} ) ;
0 commit comments