diff --git a/x/manifest/keeper/msg_server.go b/x/manifest/keeper/msg_server.go index bcdb31a..2f459c0 100644 --- a/x/manifest/keeper/msg_server.go +++ b/x/manifest/keeper/msg_server.go @@ -32,7 +32,6 @@ func (ms msgServer) UpdateParams(ctx context.Context, req *types.MsgUpdateParams return nil, ms.k.Params.Set(ctx, req.Params) } -// PayoutStakeholders implements types.MsgServer. func (ms msgServer) Payout(ctx context.Context, req *types.MsgPayout) (*types.MsgPayoutResponse, error) { if ms.k.authority != req.Authority { return nil, fmt.Errorf("invalid authority; expected %s, got %s", ms.k.authority, req.Authority) @@ -45,7 +44,6 @@ func (ms msgServer) Payout(ctx context.Context, req *types.MsgPayout) (*types.Ms return nil, ms.k.PayoutStakeholders(ctx, req.PayoutPairs) } -// BurnHeldBalance implements types.MsgServer. func (ms msgServer) BurnHeldBalance(ctx context.Context, msg *types.MsgBurnHeldBalance) (*types.MsgBurnHeldBalanceResponse, error) { addr, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { diff --git a/x/manifest/types/msgs.go b/x/manifest/types/msgs.go index dc2a828..427440d 100644 --- a/x/manifest/types/msgs.go +++ b/x/manifest/types/msgs.go @@ -107,10 +107,6 @@ func (msg *MsgPayout) Validate() error { return fmt.Errorf("coin cannot be zero for address: %s", addr) } - if coin.IsNegative() { - return fmt.Errorf("coin cannot be negative for address: %s", addr) - } - if err := coin.Validate(); err != nil { return errors.Wrapf(err, "invalid coin: %v for address: %s", coin, addr) } diff --git a/x/manifest/types/msgs_test.go b/x/manifest/types/msgs_test.go index 540e84d..ff13307 100644 --- a/x/manifest/types/msgs_test.go +++ b/x/manifest/types/msgs_test.go @@ -11,6 +11,40 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) +func TestMsgUpdateParams(t *testing.T) { + _, _, acc := testdata.KeyTestPubAddr() + + type tc struct { + name string + msg *MsgUpdateParams + success bool + } + + for _, c := range []tc{ + { + name: "success; valid update params", + msg: NewMsgUpdateParams(acc), + success: true, + }, + { + name: "fail; bad address", + msg: &MsgUpdateParams{ + Authority: "bad", + Params: NewParams(), + }, + }, + } { + c := c + t.Run(c.name, func(t *testing.T) { + if c.success { + require.NoError(t, c.msg.Validate()) + } else { + require.Error(t, c.msg.Validate()) + } + }) + } +} + func TestMsgBurn(t *testing.T) { _, _, acc := testdata.KeyTestPubAddr() @@ -49,3 +83,52 @@ func TestMsgBurn(t *testing.T) { }) } } + +func TestMsgPayout(t *testing.T) { + _, _, authority := testdata.KeyTestPubAddr() + _, _, acc := testdata.KeyTestPubAddr() + + type tc struct { + name string + msg *MsgPayout + success bool + } + + for _, c := range []tc{ + { + name: "fail; no payouts", + msg: NewMsgPayout(authority, []PayoutPair{}), + }, + { + name: "fail; bad payout address", + msg: NewMsgPayout(authority, []PayoutPair{ + { + Address: "bad", + Coin: sdk.NewCoin("stake", sdkmath.NewInt(5)), + }, + }), + }, + { + name: "fail; 0 payout coins", + msg: NewMsgPayout(authority, []PayoutPair{ + NewPayoutPair(acc, "stake", 0), + }), + }, + { + name: "success; payout", + msg: NewMsgPayout(authority, []PayoutPair{ + NewPayoutPair(acc, "stake", 5), + }), + success: true, + }, + } { + c := c + t.Run(c.name, func(t *testing.T) { + if c.success { + require.NoError(t, c.msg.Validate()) + } else { + require.Error(t, c.msg.Validate()) + } + }) + } +}