Skip to content

Commit 7bf2055

Browse files
eigenmikemypatil12
authored andcommitted
chore: revert "Slashing integration tests (#1003)" (#1007)
This reverts commit e945d8d.
1 parent 4e02495 commit 7bf2055

File tree

5 files changed

+1
-509
lines changed

5 files changed

+1
-509
lines changed

src/test/integration/IntegrationBase.t.sol

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -186,36 +186,6 @@ abstract contract IntegrationBase is IntegrationDeployer {
186186

187187
return result;
188188
}
189-
190-
/// @dev Choose a random subset of validators (selects AT LEAST ONE but NOT ALL)
191-
function _chooseSubset(uint40[] memory validators) internal returns (uint40[] memory) {
192-
require(validators.length >= 2, "Need at least 2 validators to choose subset");
193-
194-
uint40[] memory result = new uint40[](validators.length);
195-
uint newLen;
196-
197-
uint rand = _randUint({ min: 1, max: validators.length ** 2 });
198-
for (uint i = 0; i < validators.length; i++) {
199-
if (rand >> i & 1 == 1) {
200-
result[newLen] = validators[i];
201-
newLen++;
202-
}
203-
}
204-
205-
// If we picked all, remove one random validator
206-
if (newLen == validators.length) {
207-
uint indexToRemove = _randUint({ min: 0, max: validators.length - 1 });
208-
for (uint i = indexToRemove; i < newLen - 1; i++) {
209-
result[i] = result[i + 1];
210-
}
211-
newLen--;
212-
}
213-
214-
// Update array length
215-
assembly { mstore(result, newLen) }
216-
217-
return result;
218-
}
219189

220190
function _getTokenName(IERC20 token) internal view returns (string memory) {
221191
if (token == NATIVE_ETH) {
@@ -591,11 +561,8 @@ abstract contract IntegrationBase is IntegrationDeployer {
591561
uint wadToSlash = slashingParams.wadsToSlash[slashingParams.strategies.indexOf(strat)];
592562
slashedShares = prevShares[i].mulWadRoundUp(allocateParams.newMagnitudes[i].mulWadRoundUp(wadToSlash));
593563
}
594-
console.log(prevShares[i]);
595-
console.log(slashedShares);
596-
console.log(curShares[i]);
597564

598-
assertApproxEqAbs(prevShares[i] - slashedShares, curShares[i], 1000, err);
565+
assertApproxEqAbs(prevShares[i] - slashedShares, curShares[i], 1, err);
599566
}
600567
}
601568

@@ -1166,21 +1133,6 @@ abstract contract IntegrationBase is IntegrationDeployer {
11661133

11671134
return (strategies.sort(), wadsToSlash);
11681135
}
1169-
1170-
function _strategiesAndWadsForFullSlash(
1171-
OperatorSet memory operatorSet
1172-
) internal view returns (IStrategy[] memory strategies, uint[] memory wadsToSlash) {
1173-
// Get list of all strategies in an operator set.
1174-
strategies = allocationManager.getStrategiesInOperatorSet(operatorSet);
1175-
1176-
wadsToSlash = new uint[](strategies.length);
1177-
1178-
for (uint i; i < strategies.length; ++i) {
1179-
wadsToSlash[i] = 1 ether;
1180-
}
1181-
1182-
return (strategies.sort(), wadsToSlash);
1183-
}
11841136

11851137
function _randMagnitudes(uint64 sum, uint256 len) internal returns (uint64[] memory magnitudes) {
11861138
magnitudes = new uint64[](len);
@@ -1199,18 +1151,6 @@ abstract contract IntegrationBase is IntegrationDeployer {
11991151
}
12001152
}
12011153

1202-
function _maxMagnitudes(OperatorSet memory operatorSet, User operator) internal view returns (uint64[] memory magnitudes) {
1203-
IStrategy[] memory strategies = allocationManager.getStrategiesInOperatorSet(operatorSet);
1204-
uint256 len = strategies.length;
1205-
magnitudes = new uint64[](len);
1206-
1207-
if (len == 0) return magnitudes;
1208-
1209-
for (uint256 i; i < len; ++i) {
1210-
magnitudes[i] = allocationManager.getMaxMagnitude(address(operator), strategies[i]);
1211-
}
1212-
}
1213-
12141154
function _randWithdrawal(
12151155
IStrategy[] memory strategies,
12161156
uint[] memory shares

src/test/integration/IntegrationChecks.t.sol

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -390,56 +390,6 @@ contract IntegrationCheckUtils is IntegrationBase {
390390
}
391391
}
392392

393-
function check_Withdrawal_AsTokens_State_AfterBeaconSlash(
394-
User staker,
395-
User operator,
396-
IDelegationManagerTypes.Withdrawal memory withdrawal,
397-
IAllocationManagerTypes.AllocateParams memory allocateParams,
398-
IAllocationManagerTypes.SlashingParams memory slashingParams,
399-
uint[] memory expectedTokens
400-
) internal {
401-
IERC20[] memory tokens = new IERC20[](withdrawal.strategies.length);
402-
403-
for (uint i; i < withdrawal.strategies.length; i++) {
404-
IStrategy strat = withdrawal.strategies[i];
405-
406-
bool isBeaconChainETHStrategy = strat == beaconChainETHStrategy;
407-
408-
tokens[i] = isBeaconChainETHStrategy ? NATIVE_ETH : withdrawal.strategies[i].underlyingToken();
409-
410-
if (slashingParams.strategies.contains(strat)) {
411-
uint wadToSlash = slashingParams.wadsToSlash[slashingParams.strategies.indexOf(strat)];
412-
413-
expectedTokens[i] -= expectedTokens[i]
414-
.mulWadRoundUp(allocateParams.newMagnitudes[i].mulWadRoundUp(wadToSlash));
415-
416-
uint256 max = allocationManager.getMaxMagnitude(address(operator), strat);
417-
418-
withdrawal.scaledShares[i] -= withdrawal.scaledShares[i].calcSlashedAmount(WAD, max);
419-
420-
// Round down to the nearest gwei for beaconchain ETH strategy.
421-
if (isBeaconChainETHStrategy) {
422-
expectedTokens[i] -= expectedTokens[i] % 1 gwei;
423-
}
424-
}
425-
}
426-
427-
// Common checks
428-
assert_WithdrawalNotPending(delegationManager.calculateWithdrawalRoot(withdrawal), "staker withdrawal should no longer be pending");
429-
430-
// assert_Snap_Added_TokenBalances(staker, tokens, expectedTokens, "staker should have received expected tokens");
431-
assert_Snap_Unchanged_StakerDepositShares(staker, "staker shares should not have changed");
432-
assert_Snap_Removed_StrategyShares(withdrawal.strategies, withdrawal.scaledShares, "strategies should have total shares decremented");
433-
434-
// Checks specific to an operator that the Staker has delegated to
435-
if (operator != User(payable(0))) {
436-
if (operator != staker) {
437-
assert_Snap_Unchanged_TokenBalances(operator, "operator token balances should not have changed");
438-
}
439-
assert_Snap_Unchanged_OperatorShares(operator, "operator shares should not have changed");
440-
}
441-
}
442-
443393
function check_Withdrawal_AsShares_State_AfterSlash(
444394
User staker,
445395
User operator,

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

Lines changed: 0 additions & 97 deletions
This file was deleted.

0 commit comments

Comments
 (0)