Skip to content

Commit

Permalink
fix: permit zero rewards in validatorselectionrewardscallback (#978)
Browse files Browse the repository at this point in the history
* fix: permit zero rewards in validatorselectionrewardscallback; fixes #977

* fix: test should no longer expect err on zero rewards
  • Loading branch information
Joe Bowman authored Dec 29, 2023
1 parent 8ff511f commit ccfea16
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 2 additions & 6 deletions x/participationrewards/keeper/rewards_validatorSelection.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,13 @@ func (k Keeper) CalcOverallScores(

rewards := delegatorRewards.GetRewards()
if rewards == nil {
err := errors.New("no delegator rewards")
k.Logger(ctx).Error(err.Error())
return err
return nil
}

total := delegatorRewards.GetTotal().AmountOf(zone.BaseDenom)

if total.IsZero() {
err := errors.New("no delegator rewards (2)")
k.Logger(ctx).Error(err.Error())
return err
return nil
}

expected := total.Quo(sdk.NewDec(int64(len(rewards))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ func (suite *KeeperTestSuite) TestCalcOverallScores() {
},
verify: func(_ types.ZoneScore, _ []distributiontypes.DelegationDelegatorReward, _ []icstypes.Validator) {
},
wantErr: true,
wantErr: false,
},
{
name: "zero total rewards",
Expand All @@ -454,7 +454,7 @@ func (suite *KeeperTestSuite) TestCalcOverallScores() {
},
verify: func(_ types.ZoneScore, _ []distributiontypes.DelegationDelegatorReward, _ []icstypes.Validator) {
},
wantErr: true,
wantErr: false,
},
{
name: "validator removed from active set - performance greater than limit",
Expand Down

0 comments on commit ccfea16

Please sign in to comment.