Skip to content

Commit 184a361

Browse files
MichaelMichael
authored andcommitted
test: added unchanged dsf checks
1 parent 5a1d0b6 commit 184a361

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

src/test/integration/IntegrationBase.t.sol

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,6 +1602,19 @@ abstract contract IntegrationBase is IntegrationDeployer, TypeImporter {
16021602
}
16031603
}
16041604

1605+
function assert_Snap_Unchanged_DSF(
1606+
User staker,
1607+
IStrategy[] memory strategies,
1608+
string memory err
1609+
) internal {
1610+
uint[] memory curDSFs = _getDepositScalingFactors(staker, strategies);
1611+
uint[] memory prevDSFs = _getPrevDepositScalingFactors(staker, strategies);
1612+
1613+
for (uint i = 0; i < strategies.length; i++) {
1614+
assertEq(prevDSFs[i], curDSFs[i], err);
1615+
}
1616+
}
1617+
16051618
/*******************************************************************************
16061619
SNAPSHOT ASSERTIONS: STRATEGY SHARES
16071620
*******************************************************************************/

src/test/integration/IntegrationChecks.t.sol

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import "src/test/integration/users/User_M2.t.sol";
99
/// @notice Contract that provides utility functions to reuse common test blocks & checks
1010
contract IntegrationCheckUtils is IntegrationBase {
1111
using ArrayLib for IStrategy[];
12+
using ArrayLib for IStrategy;
1213
using SlashingLib for *;
1314
using StdStyle for *;
1415

@@ -178,7 +179,7 @@ contract IntegrationCheckUtils is IntegrationBase {
178179

179180
function check_Delegation_State(
180181
User staker,
181-
User operator,
182+
User operator,
182183
IStrategy[] memory strategies,
183184
uint[] memory shares
184185
) internal {
@@ -193,6 +194,7 @@ contract IntegrationCheckUtils is IntegrationBase {
193194
assert_Snap_Expected_Staker_WithdrawableShares_Delegation(staker, operator, strategies, shares, "withdrawable shares should be unchanged within rounding error after delegating");
194195
uint256[] memory delegatableShares = _getPrevStakerWithdrawableShares(staker, strategies);
195196
assert_Snap_Added_OperatorShares(operator, strategies, delegatableShares, "operator should have received shares");
197+
//assert_Snap_Added_SlashableStake(operator, operatorSet, strategies, delegatableShares, "operator slashable stake should increase");
196198
}
197199

198200
function check_QueuedWithdrawal_State(
@@ -221,6 +223,19 @@ contract IntegrationCheckUtils is IntegrationBase {
221223
"check_QueuedWithdrawal_State: failed to remove staker shares");
222224
assert_Snap_Removed_Staker_WithdrawableShares(staker, strategies, shares,
223225
"check_QueuedWithdrawal_State: failed to remove staker withdrawable shares");
226+
// Check that the dsf is either reset to wad or unchanged
227+
for (uint i = 0; i < strategies.length; i++) {
228+
// For a full withdrawal, the dsf should be reset to wad
229+
if (_getStakerDepositShares(staker, strategies[i].toArray())[0] == 0) {
230+
assert_DSF_Reset(staker, strategies[i].toArray(),
231+
"check_QueuedWithdrawal_State: dsf should be reset to wad");
232+
}
233+
// For a partial withdrawal, the dsf should not be changed
234+
else {
235+
assert_Snap_Unchanged_DSF(staker, strategies[i].toArray(),
236+
"check_QueuedWithdrawal_State: dsf should not be changed");
237+
}
238+
}
224239
}
225240

226241
function check_Undelegate_State(
@@ -257,7 +272,8 @@ contract IntegrationCheckUtils is IntegrationBase {
257272

258273
function check_Redelegate_State(
259274
User staker,
260-
User operator,
275+
User oldOperator,
276+
User newOperator,
261277
IDelegationManagerTypes.Withdrawal[] memory withdrawals,
262278
bytes32[] memory withdrawalRoots,
263279
IStrategy[] memory strategies,
@@ -277,12 +293,14 @@ contract IntegrationCheckUtils is IntegrationBase {
277293
"check_Redelegate_State: stakers withdrawal should now be pending");
278294
assert_Snap_Added_QueuedWithdrawals(staker, withdrawals,
279295
"check_Redelegate_State: staker should have increased nonce by withdrawals.length");
280-
assert_Snap_Removed_OperatorShares(operator, strategies, stakerDelegatedShares,
296+
assert_Snap_Removed_OperatorShares(oldOperator, strategies, stakerDelegatedShares,
281297
"check_Redelegate_State: failed to remove operator shares");
282298
assert_Snap_Removed_Staker_DepositShares(staker, strategies, stakerDepositShares,
283299
"check_Redelegate_State: failed to remove staker shares");
284300
assert_Snap_RemovedAll_Staker_WithdrawableShares(staker, strategies,
285301
"check_QueuedWithdrawal_State: failed to remove staker withdrawable shares");
302+
assert_Snap_Unchanged_OperatorShares(newOperator,
303+
"check_Redelegate_State: new operator shares should not have changed");
286304
}
287305

288306
/**
@@ -309,6 +327,7 @@ contract IntegrationCheckUtils is IntegrationBase {
309327

310328
assert_Snap_Added_TokenBalances(staker, tokens, expectedTokens, "staker should have received expected tokens");
311329
assert_Snap_Unchanged_Staker_DepositShares(staker, "staker shares should not have changed");
330+
assert_Snap_Unchanged_DSF(staker, strategies, "dsf should not be changed");
312331
assert_Snap_Removed_StrategyShares(strategies, shares, "strategies should have total shares decremented");
313332

314333
// Checks specific to an operator that the Staker has delegated to
@@ -331,6 +350,7 @@ contract IntegrationCheckUtils is IntegrationBase {
331350
assert_WithdrawalNotPending(delegationManager.calculateWithdrawalRoot(withdrawal), "staker withdrawal should no longer be pending");
332351
assert_Snap_Unchanged_TokenBalances(staker, "staker should not have any change in underlying token balances");
333352
assert_Snap_Added_Staker_DepositShares(staker, strategies, shares, "staker should have received expected shares");
353+
assert_Snap_Added_Staker_WithdrawableShares(staker, strategies, shares, "staker should have received expected withdrawable shares");
334354
assert_Snap_Unchanged_StrategyShares(strategies, "strategies should have total shares unchanged");
335355

336356
// Additional checks or handling for the non-user operator scenario

src/test/integration/tests/Slashed_Eigenpod.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ contract Integration_SlashedEigenpod is IntegrationCheckUtils {
236236
// Undelegate from an operator
237237
IDelegationManagerTypes.Withdrawal[] memory withdrawals = staker.redelegate(operator2);
238238
bytes32[] memory withdrawalRoots = _getWithdrawalHashes(withdrawals);
239-
check_Redelegate_State(staker, operator, withdrawals, withdrawalRoots, strategies, initDepositShares, delegatedShares);
239+
check_Redelegate_State(staker, operator, operator2, withdrawals, withdrawalRoots, strategies, initDepositShares, delegatedShares);
240240

241241
// Complete withdrawal as shares
242242
// Fast forward to when we can complete the withdrawal

0 commit comments

Comments
 (0)