Skip to content

Commit

Permalink
validator limit: fix test to assert err
Browse files Browse the repository at this point in the history
  • Loading branch information
kien6034 committed Dec 6, 2024
1 parent 5c3372f commit 719eaf5
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions custom/staking/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,9 @@ func (s *StakingTestSuite) TestValidatorVPLimit() {
s.Require().True(found)
validators[0] = validator

// test that the code panic on a delegation that surpasses the 20% VP allowed
// raise voting power of validator 0 by 1 (2+1)/(11+1) = 0.250000 > 0.2
defer func() {
if r := recover(); r == nil {
s.T().Errorf("The code did not panic")
}
}()

s.App.StakingKeeper.SetDelegation(s.Ctx, stakingtypes.NewDelegation(s.TestAccs[0], valAddrs[0], sdk.NewDec(1000000)))
s.App.StakingKeeper.Delegate(s.Ctx, s.TestAccs[0], sdk.NewInt(1000000), stakingtypes.Unbonded, validators[0], true)
_, err = s.App.StakingKeeper.Delegate(s.Ctx, s.TestAccs[0], sdk.NewInt(1000000), stakingtypes.Unbonded, validators[0], true)
// Assert that an error was returned
s.Require().Error(err)
s.Require().Equal("validator power is over the allowed limit", err.Error())
}

0 comments on commit 719eaf5

Please sign in to comment.