diff --git a/src/test/DepositWithdraw.t.sol b/src/test/DepositWithdraw.t.sol index fc2813d5e..28c3b5d04 100644 --- a/src/test/DepositWithdraw.t.sol +++ b/src/test/DepositWithdraw.t.sol @@ -18,126 +18,6 @@ contract DepositWithdrawTests is EigenLayerTestHelper { return _testDepositWeth(getOperatorAddress(0), amountToDeposit); } - function testWithdrawalSequences() public { - //use preexisting helper function to set up a withdrawal - address middleware = address(0xdeadbeef); - address middleware_2 = address(0x009849); - address staker = getOperatorAddress(0); - IDelegationManager.Withdrawal memory queuedWithdrawal; - - uint256 depositAmount = 1 ether; - IStrategy strategy = wethStrat; - IERC20 underlyingToken = weth; - IStrategy[] memory strategyArray = new IStrategy[](1); - strategyArray[0] = strategy; - IERC20[] memory tokensArray = new IERC20[](1); - tokensArray[0] = underlyingToken; - { - uint256[] memory shareAmounts = new uint256[](1); - shareAmounts[0] = depositAmount - 1 gwei; //leave some shares behind so we don't get undelegation issues - uint256[] memory strategyIndexes = new uint256[](1); - strategyIndexes[0] = 0; - address withdrawer = staker; - - { - assertTrue(!delegation.isDelegated(staker), "_createQueuedWithdrawal: staker is already delegated"); - IDelegationManager.OperatorDetails memory operatorDetails = IDelegationManager.OperatorDetails({ - earningsReceiver: staker, - delegationApprover: address(0), - stakerOptOutWindowBlocks: 0 - }); - _testRegisterAsOperator(staker, operatorDetails); - assertTrue( - delegation.isDelegated(staker), "_createQueuedWithdrawal: staker isn't delegated when they should be" - ); - - //make deposit in WETH strategy - uint256 amountDeposited = _testDepositWeth(staker, depositAmount); - // We can't withdraw more than we deposit - if (shareAmounts[0] > amountDeposited) { - cheats.expectRevert("StrategyManager._removeShares: shareAmount too high"); - } - } - - - cheats.startPrank(staker); - //opt in staker to restake for the two middlewares we are using - slasher.optIntoSlashing(middleware); - slasher.optIntoSlashing(middleware_2); - cheats.stopPrank(); - - cheats.startPrank(middleware); - // first stake update with updateBlock = 1, serveUntilBlock = 5 - - uint32 serveUntilBlock = 5; - slasher.recordFirstStakeUpdate(staker, serveUntilBlock); - cheats.stopPrank(); - //check middlewareTimes entry is correct - require(slasher.getMiddlewareTimesIndexStalestUpdateBlock(staker, 0) == 1, "middleware updateBlock update incorrect"); - require(slasher.getMiddlewareTimesIndexServeUntilBlock(staker, 0) == 5, "middleware serveUntil update incorrect"); - - - cheats.startPrank(middleware_2); - // first stake update with updateBlock = 1, serveUntilBlock = 6 - slasher.recordFirstStakeUpdate(staker, serveUntilBlock+1); - cheats.stopPrank(); - //check middlewareTimes entry is correct - require(slasher.getMiddlewareTimesIndexStalestUpdateBlock(staker, 1) == 1, "middleware updateBlock update incorrect"); - require(slasher.getMiddlewareTimesIndexServeUntilBlock(staker, 1) == 6, "middleware serveUntil update incorrect"); - //check old entry has not changed - require(slasher.getMiddlewareTimesIndexStalestUpdateBlock(staker, 0) == 1, "middleware updateBlock update incorrect"); - require(slasher.getMiddlewareTimesIndexServeUntilBlock(staker, 0) == 5, "middleware serveUntil update incorrect"); - - //move ahead a block before queuing the withdrawal - cheats.roll(2); - //cheats.startPrank(staker); - //queue the withdrawal - ( ,queuedWithdrawal) = _createOnlyQueuedWithdrawal(staker, - true, - depositAmount, - strategyArray, - tokensArray, - shareAmounts, - strategyIndexes, - withdrawer - ); - - } - //Because the staker has queued a withdrawal both currently staked middlewares must issued an update as required for the completion of the withdrawal - //to be realistic we move ahead a block before updating middlewares - cheats.roll(3); - - cheats.startPrank(middleware); - // stake update with updateBlock = 3, newServeUntilBlock = 7 - uint32 newServeUntilBlock = 7; - uint32 updateBlock = 3; - uint256 insertAfter = 1; - slasher.recordStakeUpdate(staker, updateBlock, newServeUntilBlock, insertAfter); - cheats.stopPrank(); - //check middlewareTimes entry is correct - require(slasher.getMiddlewareTimesIndexStalestUpdateBlock(staker, 2) == 1, "middleware updateBlock update incorrect"); - require(slasher.getMiddlewareTimesIndexServeUntilBlock(staker, 2) == 7, "middleware serveUntil update incorrect"); - - cheats.startPrank(middleware_2); - // stake update with updateBlock = 3, newServeUntilBlock = 10 - slasher.recordStakeUpdate(staker, updateBlock, newServeUntilBlock+3, insertAfter); - cheats.stopPrank(); - //check middlewareTimes entry is correct - require(slasher.getMiddlewareTimesIndexStalestUpdateBlock(staker, 3) == 3, "middleware updateBlock update incorrect"); - require(slasher.getMiddlewareTimesIndexServeUntilBlock(staker, 3) == 10, "middleware serveUntil update incorrect"); - - cheats.startPrank(middleware); - // stake update with updateBlock = 3, newServeUntilBlock = 7 - newServeUntilBlock = 7; - updateBlock = 3; - insertAfter = 2; - slasher.recordStakeUpdate(staker, updateBlock, newServeUntilBlock, insertAfter); - cheats.stopPrank(); - //check middlewareTimes entry is correct - require(slasher.getMiddlewareTimesIndexStalestUpdateBlock(staker, 4) == 3, "middleware updateBlock update incorrect"); - require(slasher.getMiddlewareTimesIndexServeUntilBlock(staker, 4) == 10, "middleware serveUntil update incorrect"); - } - /// @notice deploys 'numStratsToAdd' strategies using '_testAddStrategy' and then deposits '1e18' to each of them from 'getOperatorAddress(0)' /// @param numStratsToAdd is the number of strategies being added and deposited into