fix(x/distribution): add nil check in Params.ValidateBasic (backport #17236) (#17241)

Co-authored-by: n0b0dy <n0b0dyCN@users.noreply.github.com>
This commit is contained in:
mergify[bot]
2023-08-01 10:56:00 +00:00
committed by GitHub
co-authored by n0b0dy
parent ff6a9a6a7c
commit 5624447be5
4 changed files with 19 additions and 9 deletions
@@ -681,6 +681,20 @@ func TestMsgUpdateParams(t *testing.T) {
expErr: true,
expErrMsg: "invalid authority",
},
{
name: "community tax is nil",
msg: &distrtypes.MsgUpdateParams{
Authority: f.distrKeeper.GetAuthority(),
Params: distrtypes.Params{
CommunityTax: math.LegacyDec{},
WithdrawAddrEnabled: withdrawAddrEnabled,
BaseProposerReward: math.LegacyZeroDec(),
BonusProposerReward: math.LegacyZeroDec(),
},
},
expErr: true,
expErrMsg: "community tax must be not nil",
},
{
name: "community tax > 1",
msg: &distrtypes.MsgUpdateParams{
@@ -693,7 +707,7 @@ func TestMsgUpdateParams(t *testing.T) {
},
},
expErr: true,
expErrMsg: "community tax should be non-negative and less than one",
expErrMsg: "community tax too large: 2.000000000000000000",
},
{
name: "negative community tax",
@@ -707,7 +721,7 @@ func TestMsgUpdateParams(t *testing.T) {
},
},
expErr: true,
expErrMsg: "community tax should be non-negative and less than one",
expErrMsg: "community tax must be positive: -0.200000000000000000",
},
{
name: "base proposer reward set",