diff --git a/x/emissions/types/errors.go b/x/emissions/types/errors.go index 274b2ceec6..c25f367391 100644 --- a/x/emissions/types/errors.go +++ b/x/emissions/types/errors.go @@ -10,6 +10,5 @@ var ( ErrUnableToWithdrawEmissions = errorsmod.Register(ModuleName, 1002, "Unable to withdraw emissions") ErrInvalidAddress = errorsmod.Register(ModuleName, 1003, "Invalid address") ErrRewardsPoolDoesNotHaveEnoughBalance = errorsmod.Register(ModuleName, 1004, "Rewards pool does not have enough balance") - - ErrInvalidAmount = errorsmod.Register(ModuleName, 1005, "Invalid amount") + ErrInvalidAmount = errorsmod.Register(ModuleName, 1005, "Invalid amount") ) diff --git a/x/emissions/types/message_withdraw_emissions.go b/x/emissions/types/message_withdraw_emissions.go index 34d02e8fa1..2d6759b792 100644 --- a/x/emissions/types/message_withdraw_emissions.go +++ b/x/emissions/types/message_withdraw_emissions.go @@ -43,8 +43,8 @@ func (msg *MsgWithdrawEmission) ValidateBasic() error { if err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } - if !msg.Amount.GTE(sdkmath.ZeroInt()) { - return errorsmod.Wrapf(sdkerrors.ErrInvalidCoins, "invalid amount (%s)", msg.Amount.String()) + if !msg.Amount.GT(sdkmath.ZeroInt()) { + return errorsmod.Wrapf(ErrInvalidAmount, "invalid amount (%s)", msg.Amount.String()) } return nil } diff --git a/x/emissions/types/message_withdraw_emissons_test.go b/x/emissions/types/message_withdraw_emissons_test.go index ad8f632188..280999cc3a 100644 --- a/x/emissions/types/message_withdraw_emissons_test.go +++ b/x/emissions/types/message_withdraw_emissons_test.go @@ -3,6 +3,7 @@ package types_test import ( "testing" + sdkmath "cosmossdk.io/math" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/testutil/sample" @@ -16,10 +17,16 @@ func TestMsgWithdrawEmission_ValidateBasic(t *testing.T) { require.ErrorIs(t, err, sdkerrors.ErrInvalidAddress) }) - t.Run("invalid amount", func(t *testing.T) { + t.Run("invalid negative amount", func(t *testing.T) { msg := emissionstypes.NewMsgWithdrawEmissions(sample.AccAddress(), sample.IntInRange(-100, -1)) err := msg.ValidateBasic() - require.ErrorIs(t, err, sdkerrors.ErrInvalidCoins) + require.ErrorIs(t, err, emissionstypes.ErrInvalidAmount) + }) + + t.Run("invalid zero amount", func(t *testing.T) { + msg := emissionstypes.NewMsgWithdrawEmissions(sample.AccAddress(), sdkmath.ZeroInt()) + err := msg.ValidateBasic() + require.ErrorIs(t, err, emissionstypes.ErrInvalidAmount) }) t.Run("valid withdraw message", func(t *testing.T) {