From 9b1509d629399045e3d32a45a7b27b6ed15836a5 Mon Sep 17 00:00:00 2001 From: wadealexc Date: Fri, 13 Oct 2023 16:20:20 +0000 Subject: [PATCH] Remove tests that were failing due to deleted slasher checks, and fixed broken EigenPod test --- src/test/DepositWithdraw.t.sol | 28 +----------- src/test/EigenPod.t.sol | 6 --- src/test/unit/DelegationUnit.t.sol | 57 ------------------------- src/test/unit/StrategyManagerUnit.t.sol | 51 ---------------------- 4 files changed, 1 insertion(+), 141 deletions(-) diff --git a/src/test/DepositWithdraw.t.sol b/src/test/DepositWithdraw.t.sol index d0cdf5da2..28525e434 100644 --- a/src/test/DepositWithdraw.t.sol +++ b/src/test/DepositWithdraw.t.sol @@ -135,33 +135,7 @@ contract DepositWithdrawTests is EigenLayerTestHelper { 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"); - - //move timestamp to 6, one middleware is past newServeUntilBlock but the second middleware is still using the restaked funds. - cheats.warp(8); - //Also move the current block ahead one - cheats.roll(4); - - cheats.startPrank(staker); - //when called with the correct middlewareTimesIndex the call reverts - - slasher.getMiddlewareTimesIndexStalestUpdateBlock(staker, 3); - - - { - uint256 correctMiddlewareTimesIndex = 4; - cheats.expectRevert("DelegationManager.completeQueuedAction: pending action is still slashable"); - delegation.completeQueuedWithdrawal(queuedWithdrawal, tokensArray, correctMiddlewareTimesIndex, false); - } - - //When called with a stale index the call should also revert. - { - uint256 staleMiddlewareTimesIndex = 2; - cheats.expectRevert("DelegationManager.completeQueuedAction: pending action is still slashable"); - delegation.completeQueuedWithdrawal(queuedWithdrawal, tokensArray, staleMiddlewareTimesIndex, false); - } - - + require(slasher.getMiddlewareTimesIndexServeUntilBlock(staker, 4) == 10, "middleware serveUntil update incorrect"); } diff --git a/src/test/EigenPod.t.sol b/src/test/EigenPod.t.sol index f53395c6f..8ca5ac9fd 100644 --- a/src/test/EigenPod.t.sol +++ b/src/test/EigenPod.t.sol @@ -701,17 +701,11 @@ contract EigenPodTests is ProofParsing, EigenPodPausingConstants { // // validator status should be marked as ACTIVE function testProveSingleWithdrawalCredential() public { - // get beaconChainETH shares - int256 beaconChainETHBefore = eigenPodManager.podOwnerShares(podOwner); - // ./solidityProofGen "ValidatorFieldsProof" 302913 true "data/withdrawal_proof_goerli/goerli_block_header_6399998.json" "data/withdrawal_proof_goerli/goerli_slot_6399998.json" "withdrawal_credential_proof_302913.json" setJSON("./src/test/test-data/withdrawal_credential_proof_302913.json"); setJSON("./src/test/test-data/withdrawal_credential_proof_302913.json"); IEigenPod pod = _testDeployAndVerifyNewEigenPod(podOwner, signature, depositDataRoot); bytes32 validatorPubkeyHash = getValidatorPubkeyHash(); - - int256 beaconChainETHAfter = eigenPodManager.podOwnerShares(pod.podOwner()); - assertTrue(beaconChainETHAfter - beaconChainETHBefore == int256(_calculateRestakedBalanceGwei(pod.MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR())*GWEI_TO_WEI), "pod balance not updated correcty"); assertTrue(pod.validatorStatus(validatorPubkeyHash) == IEigenPod.VALIDATOR_STATUS.ACTIVE, "wrong validator status"); } diff --git a/src/test/unit/DelegationUnit.t.sol b/src/test/unit/DelegationUnit.t.sol index b8f6eb0a5..9e80ab90a 100644 --- a/src/test/unit/DelegationUnit.t.sol +++ b/src/test/unit/DelegationUnit.t.sol @@ -1196,27 +1196,6 @@ contract DelegationUnitTests is EigenLayerTestHelper { delegationManager.decreaseDelegatedShares(operator, strategy, shares); } - // @notice Verifies that it is not possible for a staker to delegate to an operator when the operator is frozen in EigenLayer - function testCannotDelegateWhenOperatorIsFrozen(address operator, address staker) public fuzzedAddress(operator) fuzzedAddress(staker) { - cheats.assume(operator != staker); - - cheats.startPrank(operator); - IDelegationManager.OperatorDetails memory operatorDetails = IDelegationManager.OperatorDetails({ - earningsReceiver: operator, - delegationApprover: address(0), - stakerOptOutWindowBlocks: 0 - }); - delegationManager.registerAsOperator(operatorDetails, emptyStringForMetadataURI); - cheats.stopPrank(); - - slasherMock.setOperatorFrozenStatus(operator, true); - cheats.expectRevert(bytes("DelegationManager._delegate: cannot delegate to a frozen operator")); - cheats.startPrank(staker); - IDelegationManager.SignatureWithExpiry memory signatureWithExpiry; - delegationManager.delegateTo(operator, signatureWithExpiry, emptySalt); - cheats.stopPrank(); - } - // @notice Verifies that it is not possible for a staker to delegate to an operator when they are already delegated to an operator function testCannotDelegateWhenStakerHasExistingDelegation(address staker, address operator, address operator2) public fuzzedAddress(staker) @@ -1748,42 +1727,6 @@ contract DelegationUnitTests is EigenLayerTestHelper { delegationManager.completeQueuedWithdrawal(withdrawal, tokensArray, middlewareTimesIndex, receiveAsTokens); } - function testCompleteQueuedWithdrawalRevertsWhenCanWithdrawReturnsFalse( - uint256 depositAmount, - uint256 withdrawalAmount - ) external { - cheats.assume(withdrawalAmount != 0 && withdrawalAmount <= depositAmount); - _tempStakerStorage = address(this); - - ( - IDelegationManager.Withdrawal memory withdrawal, - IERC20[] memory tokensArray, - ) = testQueueWithdrawal_ToSelf(depositAmount, withdrawalAmount); - - IStrategy strategy = withdrawal.strategies[0]; - IERC20 token = tokensArray[0]; - - uint256 sharesBefore = strategyManager.stakerStrategyShares(address(this), strategy); - uint256 balanceBefore = token.balanceOf(address(_tempStakerStorage)); - - uint256 middlewareTimesIndex = 0; - bool receiveAsTokens = false; - - // prepare mock - slasherMock.setCanWithdrawResponse(false); - - cheats.expectRevert( - bytes("DelegationManager.completeQueuedAction: pending action is still slashable") - ); - delegationManager.completeQueuedWithdrawal(withdrawal, tokensArray, middlewareTimesIndex, receiveAsTokens); - - uint256 sharesAfter = strategyManager.stakerStrategyShares(address(this), strategy); - uint256 balanceAfter = token.balanceOf(address(_tempStakerStorage)); - - require(sharesAfter == sharesBefore, "sharesAfter != sharesBefore"); - require(balanceAfter == balanceBefore, "balanceAfter != balanceBefore"); - } - function testCompleteQueuedWithdrawalRevertsWhenNotCallingFromWithdrawerAddress( uint256 depositAmount, uint256 withdrawalAmount diff --git a/src/test/unit/StrategyManagerUnit.t.sol b/src/test/unit/StrategyManagerUnit.t.sol index 06335c329..b0fe36b00 100644 --- a/src/test/unit/StrategyManagerUnit.t.sol +++ b/src/test/unit/StrategyManagerUnit.t.sol @@ -240,19 +240,6 @@ contract StrategyManagerUnitTests is Test, Utils { strategyManager.depositIntoStrategy(dummyStrat, dummyToken, amount); } - function testDepositIntoStrategyRevertsWhenStakerFrozen() public { - uint256 amount = 1e18; - address staker = address(this); - - // freeze the staker - slasherMock.freezeOperator(staker); - - cheats.expectRevert( - bytes("StrategyManager.onlyNotFrozen: staker has been frozen and may be subject to slashing") - ); - strategyManager.depositIntoStrategy(dummyStrat, dummyToken, amount); - } - function testDepositIntoStrategyRevertsWhenReentering() public { uint256 amount = 1e18; @@ -416,44 +403,6 @@ contract StrategyManagerUnitTests is Test, Utils { _depositIntoStrategyWithSignature(staker, 1e18, type(uint256).max, expectedRevertMessage); } - function testDepositIntoStrategyWithSignatureRevertsWhenStakerFrozen() public { - address staker = cheats.addr(privateKey); - IStrategy strategy = dummyStrat; - IERC20 token = dummyToken; - uint256 amount = 1e18; - - uint256 nonceBefore = strategyManager.nonces(staker); - uint256 expiry = type(uint256).max; - bytes memory signature; - - { - bytes32 structHash = keccak256( - abi.encode(strategyManager.DEPOSIT_TYPEHASH(), strategy, token, amount, nonceBefore, expiry) - ); - bytes32 digestHash = keccak256(abi.encodePacked("\x19\x01", strategyManager.domainSeparator(), structHash)); - - (uint8 v, bytes32 r, bytes32 s) = cheats.sign(privateKey, digestHash); - - signature = abi.encodePacked(r, s, v); - } - - uint256 sharesBefore = strategyManager.stakerStrategyShares(staker, strategy); - - // freeze the staker - slasherMock.freezeOperator(staker); - - cheats.expectRevert( - bytes("StrategyManager.onlyNotFrozen: staker has been frozen and may be subject to slashing") - ); - strategyManager.depositIntoStrategyWithSignature(strategy, token, amount, staker, expiry, signature); - - uint256 sharesAfter = strategyManager.stakerStrategyShares(staker, strategy); - uint256 nonceAfter = strategyManager.nonces(staker); - - require(sharesAfter == sharesBefore, "sharesAfter != sharesBefore"); - require(nonceAfter == nonceBefore, "nonceAfter != nonceBefore"); - } - function testDepositIntoStrategyWithSignatureRevertsWhenReentering() public { reenterer = new Reenterer();