Skip to content

Commit

Permalink
test: added check that dsf is reset on undelegation
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael authored and wadealexc committed Feb 19, 2025
1 parent 19cd370 commit a32a2d5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/test/integration/IntegrationBase.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,17 @@ abstract contract IntegrationBase is IntegrationDeployer, TypeImporter {
assertEq(slashableStake[i], 0, err);
}
}

function assert_DSF_Reset(
User staker,
IStrategy[] memory strategies,
string memory err
) internal {
uint[] memory depositScalingFactors = _getDepositScalingFactors(staker, strategies);
for (uint i = 0; i < strategies.length; i++) {
assertEq(depositScalingFactors[i], WAD, err);
}
}

/*******************************************************************************
SNAPSHOT ASSERTIONS
Expand Down Expand Up @@ -2760,6 +2771,18 @@ abstract contract IntegrationBase is IntegrationDeployer, TypeImporter {
return shares;
}

function _getDepositScalingFactors(User staker, IStrategy[] memory strategies) internal view returns (uint[] memory) {
uint[] memory depositScalingFactors = new uint[](strategies.length);
for (uint i=0; i < strategies.length; i++) {
depositScalingFactors[i] = _getDepositScalingFactor(staker, strategies[i]);
}
return depositScalingFactors;
}

function _getDepositScalingFactor(User staker, IStrategy strategy) internal view returns (uint) {
return delegationManager.depositScalingFactor(address(staker), strategy);
}

function _getExpectedDSFUndelegate(User staker) internal view returns (uint expectedDepositScalingFactor) {
return WAD.divWad(_getBeaconChainSlashingFactor(staker));
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/integration/IntegrationChecks.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ contract IntegrationCheckUtils is IntegrationBase {
"check_Undelegate_State: calculated withdrawal should match returned root");
assert_AllWithdrawalsPending(withdrawalRoots,
"check_Undelegate_State: stakers withdrawal should now be pending");
assert_DSF_Reset(staker, strategies,
"check_Undelegate_State: staker dsfs should be reset to wad");
assert_Snap_Added_QueuedWithdrawals(staker, withdrawals,
"check_Undelegate_State: staker should have increased nonce by withdrawals.length");
assert_Snap_Removed_OperatorShares(operator, strategies, stakerDelegatedShares,
Expand Down

0 comments on commit a32a2d5

Please sign in to comment.