diff --git a/x/tier/keeper/msg_lock_test.go b/x/tier/keeper/msg_lock_test.go index 428a115..29661ea 100644 --- a/x/tier/keeper/msg_lock_test.go +++ b/x/tier/keeper/msg_lock_test.go @@ -82,11 +82,40 @@ func TestMsgLock(t *testing.T) { expErr: true, expErrMsg: "invalid amount", }, + { + name: "invalid delegator address", + input: &types.MsgLock{ + DelegatorAddress: "invalid-delegator-address", + ValidatorAddress: valAddr, + Stake: validCoin1, + }, + expErr: true, + expErrMsg: "delegator address", + }, + { + name: "invalid validator address", + input: &types.MsgLock{ + DelegatorAddress: delAddr, + ValidatorAddress: "invalid-validator-address", + Stake: validCoin1, + }, + expErr: true, + expErrMsg: "validator address", + }, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - _, err := ms.Lock(sdkCtx, tc.input) + err := tc.input.ValidateBasic() + if err != nil { + if tc.expErr { + require.Contains(t, err.Error(), tc.expErrMsg) + return + } + t.Fatalf("unexpected error in ValidateBasic: %v", err) + } + + _, err = ms.Lock(sdkCtx, tc.input) if tc.expErr { require.Error(t, err) diff --git a/x/tier/keeper/msg_server.go b/x/tier/keeper/msg_server.go index 89a7710..b6aaf8a 100644 --- a/x/tier/keeper/msg_server.go +++ b/x/tier/keeper/msg_server.go @@ -22,7 +22,7 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer { func (m msgServer) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { authority := m.Keeper.GetAuthority() if msg.Authority != authority { - return nil, types.ErrUnauthorized.Wrapf("expected authority: %s, got: %s", authority, msg.Authority) + return nil, types.ErrUnauthorized.Wrapf("invalid authority: %s", msg.Authority) } err := msg.Params.Validate() diff --git a/x/tier/keeper/msg_unlock_test.go b/x/tier/keeper/msg_unlock_test.go index 432aa59..68a140d 100644 --- a/x/tier/keeper/msg_unlock_test.go +++ b/x/tier/keeper/msg_unlock_test.go @@ -101,10 +101,39 @@ func TestMsgUnlock(t *testing.T) { expErr: true, expErrMsg: "subtract lockup", }, + { + name: "invalid delegator address", + input: &types.MsgUnlock{ + DelegatorAddress: "invalid-delegator-address", + ValidatorAddress: valAddr, + Stake: validCoin, + }, + expErr: true, + expErrMsg: "delegator address", + }, + { + name: "invalid validator address", + input: &types.MsgUnlock{ + DelegatorAddress: delAddr, + ValidatorAddress: "invalid-validator-address", + Stake: validCoin, + }, + expErr: true, + expErrMsg: "validator address", + }, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { + err := tc.input.ValidateBasic() + if err != nil { + if tc.expErr { + require.Contains(t, err.Error(), tc.expErrMsg) + return + } + t.Fatalf("unexpected error in ValidateBasic: %v", err) + } + resp, err := ms.Unlock(sdkCtx, tc.input) if tc.expErr { diff --git a/x/tier/keeper/msg_update_params_test.go b/x/tier/keeper/msg_update_params_test.go index 9cf293f..8ba5ec3 100644 --- a/x/tier/keeper/msg_update_params_test.go +++ b/x/tier/keeper/msg_update_params_test.go @@ -29,7 +29,7 @@ func TestMsgUpdateParams(t *testing.T) { Params: params, }, expErr: true, - expErrMsg: "expected authority: source10d07y265gmmuvt4z0w9aw880jnsr700ju32mxd, got: invalid: unauthorized", + expErrMsg: "invalid authority", }, { name: "send enabled param", diff --git a/x/tier/types/messages.go b/x/tier/types/messages.go index 869a681..f28d3c3 100644 --- a/x/tier/types/messages.go +++ b/x/tier/types/messages.go @@ -91,7 +91,7 @@ func NewMsgRedelegate(delAddress, srcValAddr, dstValAddr string, stake sdk.Coin) func (msg *MsgRedelegate) ValidateBasic() error { if msg.SrcValidatorAddress == msg.DstValidatorAddress { - return ErrInvalidAddress.Wrapf("src and dst validator addresses are the sames") + return ErrInvalidAddress.Wrapf("src and dst validator addresses are the same") } if err := validateAccAddr(msg.DelegatorAddress); err != nil { return err