Skip to content

Commit

Permalink
test: uncommenting test in Slashed_Eigenpod
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael authored and Michael committed Feb 25, 2025
1 parent 14eb9d8 commit 2f934c6
Showing 1 changed file with 63 additions and 64 deletions.
127 changes: 63 additions & 64 deletions src/test/integration/tests/Slashed_Eigenpod.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -134,72 +134,71 @@ contract Integration_SlashedEigenpod is IntegrationCheckUtils {
assertApproxEqAbs(withdrawableSharesAfter[0], depositSharesAfter[0], 100, "Withdrawable shares should equal deposit shares after withdrawal");
}

// TODO: Fix this test
// function testFuzz_delegateSlashedStaker_slashedOperator(uint24 _random) public rand(_random) {


// (User staker2,,) = _newRandomStaker();
// (uint40[] memory validators2,) = staker2.startValidators();
// beaconChain.advanceEpoch_NoWithdrawNoRewards();
// staker2.verifyWithdrawalCredentials(validators2);
// staker2.startCheckpoint();
// staker2.completeCheckpoint();
// staker2.delegateTo(operator);

// //randomize additional deposit to eigenpod
// if(_randBool()){
// uint amount = 32 ether * _randUint({min: 1, max: 5});
// cheats.deal(address(staker), amount);
// (uint40[] memory validators,) = staker.startValidators();
// beaconChain.advanceEpoch_NoWithdrawNoRewards();
// staker.verifyWithdrawalCredentials(validators);
function testFuzz_delegateSlashedStaker_slashedOperator(uint24 _random) public rand(_random) {


(User staker2,,) = _newRandomStaker();
(uint40[] memory validators2,) = staker2.startValidators();
beaconChain.advanceEpoch_NoWithdrawNoRewards();
staker2.verifyWithdrawalCredentials(validators2);
staker2.startCheckpoint();
staker2.completeCheckpoint();
staker2.delegateTo(operator);

//randomize additional deposit to eigenpod
if(_randBool()){
uint amount = 32 ether * _randUint({min: 1, max: 5});
cheats.deal(address(staker), amount);
(uint40[] memory validators,) = staker.startValidators();
beaconChain.advanceEpoch_NoWithdrawNoRewards();
staker.verifyWithdrawalCredentials(validators);

// staker.startCheckpoint();
// staker.completeCheckpoint();
// }

// // Create an operator set and register an operator.
// operatorSet = avs.createOperatorSet(strategies);
// operator.registerForOperatorSet(operatorSet);
// check_Registration_State_NoAllocation(operator, operatorSet, strategies);

// // Allocate to operator set
// allocateParams = _genAllocation_AllAvailable(operator, operatorSet, strategies);
// operator.modifyAllocations(allocateParams);
// check_IncrAlloc_State_Slashable(operator, allocateParams);
// _rollBlocksForCompleteAllocation(operator, operatorSet, strategies);

// //Slash operator before delegation
// IAllocationManagerTypes.SlashingParams memory slashingParams;
// uint wadToSlash = _randWadToSlash();
// slashingParams = avs.slashOperator(operator, operatorSet.id, strategies, wadToSlash.toArrayU256());
// assert_Snap_Allocations_Slashed(slashingParams, operatorSet, true, "operator allocations should be slashed");

// uint256[] memory initDelegatableShares = _getWithdrawableShares(staker, strategies);
// uint256[] memory initDepositShares = _getStakerDepositShares(staker, strategies);

// // Delegate to an operator
// staker.delegateTo(operator);
// (uint256[] memory delegatedShares, ) = delegationManager.getWithdrawableShares(address(staker), strategies);
// check_Delegation_State(staker, operator, strategies, initDepositShares);
staker.startCheckpoint();
staker.completeCheckpoint();
}

// Create an operator set and register an operator.
operatorSet = avs.createOperatorSet(strategies);
operator.registerForOperatorSet(operatorSet);
check_Registration_State_NoAllocation(operator, operatorSet, strategies);

// Allocate to operator set
allocateParams = _genAllocation_AllAvailable(operator, operatorSet, strategies);
operator.modifyAllocations(allocateParams);
check_IncrAlloc_State_Slashable(operator, allocateParams);
_rollBlocksForCompleteAllocation(operator, operatorSet, strategies);

//Slash operator before delegation
IAllocationManagerTypes.SlashingParams memory slashingParams;
uint wadToSlash = _randWadToSlash();
slashingParams = avs.slashOperator(operator, operatorSet.id, strategies, wadToSlash.toArrayU256());
assert_Snap_Allocations_Slashed(slashingParams, operatorSet, true, "operator allocations should be slashed");

uint256[] memory initDelegatableShares = _getWithdrawableShares(staker, strategies);
uint256[] memory initDepositShares = _getStakerDepositShares(staker, strategies);

// Delegate to an operator
staker.delegateTo(operator);
(uint256[] memory delegatedShares, ) = delegationManager.getWithdrawableShares(address(staker), strategies);
check_Delegation_State(staker, operator, strategies, initDepositShares);

// // Undelegate from an operator
// IDelegationManagerTypes.Withdrawal[] memory withdrawals = staker.undelegate();
// bytes32[] memory withdrawalRoots = _getWithdrawalHashes(withdrawals);
// check_Undelegate_State(staker, operator, withdrawals, withdrawalRoots, strategies, initDepositShares, delegatedShares);

// // Complete withdrawal as shares
// // Fast forward to when we can complete the withdrawal
// _rollBlocksForCompleteWithdrawals(withdrawals);
// for (uint256 i = 0; i < withdrawals.length; ++i) {
// staker.completeWithdrawalAsShares(withdrawals[i]);
// check_Withdrawal_AsShares_Undelegated_State(staker, operator, withdrawals[i], withdrawals[i].strategies, delegatedShares);
// }

// (uint256[] memory withdrawableSharesAfter, uint256[] memory depositSharesAfter) = delegationManager.getWithdrawableShares(address(staker), strategies);
// assertEq(depositSharesAfter[0], delegatedShares[0], "Deposit shares should reset to reflect slash(es)");
// assertApproxEqAbs(withdrawableSharesAfter[0], depositSharesAfter[0], 100, "Withdrawable shares should equal deposit shares after withdrawal");
// }
// Undelegate from an operator
IDelegationManagerTypes.Withdrawal[] memory withdrawals = staker.undelegate();
bytes32[] memory withdrawalRoots = _getWithdrawalHashes(withdrawals);
check_Undelegate_State(staker, operator, withdrawals, withdrawalRoots, strategies, initDepositShares, delegatedShares);

// Complete withdrawal as shares
// Fast forward to when we can complete the withdrawal
_rollBlocksForCompleteWithdrawals(withdrawals);
for (uint256 i = 0; i < withdrawals.length; ++i) {
staker.completeWithdrawalAsShares(withdrawals[i]);
check_Withdrawal_AsShares_Undelegated_State(staker, operator, withdrawals[i], withdrawals[i].strategies, delegatedShares);
}

(uint256[] memory withdrawableSharesAfter, uint256[] memory depositSharesAfter) = delegationManager.getWithdrawableShares(address(staker), strategies);
assertEq(depositSharesAfter[0], delegatedShares[0], "Deposit shares should reset to reflect slash(es)");
assertApproxEqAbs(withdrawableSharesAfter[0], depositSharesAfter[0], 100, "Withdrawable shares should equal deposit shares after withdrawal");
}

function testFuzz_delegateSlashedStaker_redelegate_complete(uint24 _random) public rand(_random){

Expand Down

0 comments on commit 2f934c6

Please sign in to comment.