Skip to content

Commit 5b8a9d0

Browse files
committed
test: slasher
1 parent ab0f4d2 commit 5b8a9d0

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

src/test/unit/AllocationManagerUnit.t.sol

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,6 +1781,63 @@ contract AllocationManagerUnitTests_SlashOperator is AllocationManagerUnitTests
17811781
assertEq(0, allocationManager.getAllocatableMagnitude(defaultOperator, strategyMock), "Allocatable magnitude should be 0");
17821782
assertEq(0, allocationManager.getMaxMagnitude(defaultOperator, strategyMock), "Max magnitude should be 0");
17831783
}
1784+
1785+
/**
1786+
* @notice Tests that an AVS can update the slasher, and it can slash once the slasher is active
1787+
*/
1788+
function test_slash_updateSlasher_slashAgain() public {
1789+
// Allocate all magnitude
1790+
cheats.prank(defaultOperator);
1791+
allocationManager.modifyAllocations(defaultOperator, _newAllocateParams(defaultOperatorSet, WAD));
1792+
cheats.roll(block.number + DEFAULT_OPERATOR_ALLOCATION_DELAY);
1793+
1794+
SlashingParams memory slashingParams = SlashingParams({
1795+
operator: defaultOperator,
1796+
operatorSetId: defaultOperatorSet.id,
1797+
strategies: defaultStrategies,
1798+
wadsToSlash: 5e17.toArrayU256(),
1799+
description: "test"
1800+
});
1801+
1802+
// Slash the operator for half
1803+
cheats.prank(defaultAVS);
1804+
allocationManager.slashOperator(defaultAVS, slashingParams);
1805+
1806+
// Update the slasher
1807+
address appointee1 = address(0x1);
1808+
cheats.prank(defaultAVS);
1809+
allocationManager.setSlasher(defaultOperatorSet, appointee1);
1810+
1811+
// Warp to just before the effect block of the slasher - fail to slash
1812+
cheats.roll(block.number + ALLOCATION_CONFIGURATION_DELAY);
1813+
cheats.prank(appointee1);
1814+
cheats.expectRevert(InvalidCaller.selector);
1815+
allocationManager.slashOperator(defaultAVS, slashingParams);
1816+
1817+
// Warp to the effect block of the slasher
1818+
cheats.roll(block.number + 1);
1819+
1820+
// Slash the operator again for half
1821+
cheats.prank(appointee1);
1822+
allocationManager.slashOperator(defaultAVS, slashingParams);
1823+
1824+
// Sanity checks
1825+
_checkAllocationStorage({
1826+
operator: defaultOperator,
1827+
operatorSet: defaultOperatorSet,
1828+
strategy: strategyMock,
1829+
expectedAllocation: Allocation({currentMagnitude: 25e16, pendingDiff: 0, effectBlock: 0}),
1830+
expectedMagnitudes: Magnitudes({encumbered: 25e16, max: 25e16, allocatable: 0})
1831+
});
1832+
1833+
// Slashable stake should include first allocation and slashed magnitude
1834+
_checkSlashableStake({
1835+
operatorSet: defaultOperatorSet,
1836+
operator: defaultOperator,
1837+
strategies: defaultStrategies,
1838+
expectedSlashableStake: 25e16
1839+
});
1840+
}
17841841
}
17851842

17861843
contract AllocationManagerUnitTests_ModifyAllocations is AllocationManagerUnitTests {

0 commit comments

Comments
 (0)