Skip to content

Commit 5e19e13

Browse files
eigenmikemMichael
authored andcommitted
test: non-beacon-chain slashing integration tests (#1010)
* Slashing integration tests (#1003) * Validate that users who are slashed fully can redeposit once undelegated * removing arraylib use * test for updating eigenpod state -> slash/undelegate * removing unnecessary logging function * fixing strategy set * beacon chain tests in progress --------- Co-authored-by: Michael <[email protected]> * Revert "Slashing integration tests (#1003)" (#1007) This reverts commit e945d8d. * integration tests for full eigenlayer slashes * comment re: beacon chain eth partial deposits * fix: fixing 0 withdrawal issues (#1019) * fix: fixing 0 withdrawal issues * style: white space * docs: changing description for test --------- Co-authored-by: Michael <[email protected]> * test: withdraw as shares for random subset of strategies fully slashed * style: removing debugging stubs and updating comment --------- Co-authored-by: Michael <[email protected]>
1 parent f0f671e commit 5e19e13

File tree

2 files changed

+392
-0
lines changed

2 files changed

+392
-0
lines changed

src/test/integration/IntegrationBase.t.sol

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,45 @@ abstract contract IntegrationBase is IntegrationDeployer {
11291129

11301130
return (strategies.sort(), wadsToSlash);
11311131
}
1132+
1133+
function _strategiesAndWadsForFullSlash(
1134+
OperatorSet memory operatorSet
1135+
) internal view returns (IStrategy[] memory strategies, uint[] memory wadsToSlash) {
1136+
// Get list of all strategies in an operator set.
1137+
strategies = allocationManager.getStrategiesInOperatorSet(operatorSet);
1138+
1139+
wadsToSlash = new uint[](strategies.length);
1140+
1141+
for (uint i; i < strategies.length; ++i) {
1142+
wadsToSlash[i] = 1 ether;
1143+
}
1144+
1145+
return(strategies.sort(), wadsToSlash);
1146+
}
1147+
1148+
function _strategiesAndWadsForRandFullSlash(
1149+
OperatorSet memory operatorSet
1150+
) internal returns (IStrategy[] memory strategies, uint[] memory wadsToSlash) {
1151+
// Get list of all strategies in an operator set.
1152+
strategies = allocationManager.getStrategiesInOperatorSet(operatorSet);
1153+
1154+
// Randomly select a subset of strategies to slash.
1155+
uint len = _randUint({ min: 1, max: strategies.length-1 });
1156+
1157+
// Update length of strategies array.
1158+
assembly {
1159+
mstore(strategies, len)
1160+
}
1161+
1162+
wadsToSlash = new uint[](len);
1163+
1164+
// Fully slash each selected strategy
1165+
for (uint i; i < len; ++i) {
1166+
wadsToSlash[i] = 1 ether;
1167+
}
1168+
1169+
return (strategies.sort(), wadsToSlash);
1170+
}
11321171

11331172
function _randMagnitudes(uint64 sum, uint256 len) internal returns (uint64[] memory magnitudes) {
11341173
magnitudes = new uint64[](len);
@@ -1147,6 +1186,18 @@ abstract contract IntegrationBase is IntegrationDeployer {
11471186
}
11481187
}
11491188

1189+
function _maxMagnitudes(OperatorSet memory operatorSet, User operator) internal view returns (uint64[] memory magnitudes) {
1190+
IStrategy[] memory strategies = allocationManager.getStrategiesInOperatorSet(operatorSet);
1191+
uint256 len = strategies.length;
1192+
magnitudes = new uint64[](len);
1193+
1194+
if (len == 0) return magnitudes;
1195+
1196+
for (uint256 i; i < len; ++i) {
1197+
magnitudes[i] = allocationManager.getMaxMagnitude(address(operator), strategies[i]);
1198+
}
1199+
}
1200+
11501201
function _randWithdrawal(
11511202
IStrategy[] memory strategies,
11521203
uint[] memory shares

0 commit comments

Comments
 (0)