Skip to content

Commit

Permalink
Slashing for non-validators work
Browse files Browse the repository at this point in the history
  • Loading branch information
martinvol committed Oct 13, 2024
1 parent 3410b9b commit da9cdc7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
3 changes: 1 addition & 2 deletions packages/protocol/contracts/governance/GovernanceSlasher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,8 @@ contract GovernanceSlasher is
electionIndices
);

IValidators validators = getValidators();

if (group != address(0)) {
IValidators validators = getValidators();
validators.forceDeaffiliateIfValidator(account);
validators.halveSlashingMultiplier(group);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,36 @@ contract GovernanceSlasherTest_slashL2_WhenL1 is GovernanceSlasherTest {
}
}

contract GovernanceSlasherTest_slashL2_WhenL2 is GovernanceSlasherTest, L2MakerAbstract {
// should work just like the deprecated version
contract GovernanceSlasherTest_slashL2_WhenL2_WhenNotGroup is
GovernanceSlasherTest,
L2MakerAbstract
{
address group = address(0);

function setUp() public {
super.setUp();
_whenL2();
}

// only onwer or multisig can call

function test_ShouldDecrementCelo() public {
governanceSlasher.approveSlashing(validator, 1000);
governanceSlasher.slashL2(validator, group, lessers, greaters, indices);
assertEq(mockLockedGold.accountTotalLockedGold(validator), 4000);
}

function test_ShouldHaveSetTheApprovedSlashingToZero() public {
governanceSlasher.approveSlashing(validator, 1000);
governanceSlasher.slashL2(validator, group, lessers, greaters, indices);
assertEq(governanceSlasher.getApprovedSlashing(validator), 0);
}

function test_EmitsGovernanceSlashPerformedEvent() public {
governanceSlasher.approveSlashing(validator, 1000);
vm.expectEmit(true, true, true, true);
emit GovernanceSlashPerformed(validator, 1000);
governanceSlasher.slashL2(validator, group, lessers, greaters, indices);
}
}

0 comments on commit da9cdc7

Please sign in to comment.