diff --git a/x/crud/internal/types/msgs.go b/x/crud/internal/types/msgs.go index cdae3ccd..4cf690dc 100644 --- a/x/crud/internal/types/msgs.go +++ b/x/crud/internal/types/msgs.go @@ -133,9 +133,15 @@ func (msg MsgBLZUpdate) ValidateBasic() sdk.Error { if msg.Owner.Empty() { return sdk.ErrInvalidAddress(msg.Owner.String()) } + if len(msg.UUID) == 0 || len(msg.Key) == 0 { return sdk.ErrInvalidPubKey("UUID or key Empty") } + + if len(msg.Value) > MaxValueSize { + return sdk.ErrInternal("Value too large") + } + return nil } diff --git a/x/crud/internal/types/msgs_test.go b/x/crud/internal/types/msgs_test.go index d17a4b71..1b133f11 100644 --- a/x/crud/internal/types/msgs_test.go +++ b/x/crud/internal/types/msgs_test.go @@ -64,7 +64,7 @@ func TestMsgBLZCreate_ValidateBasic(t *testing.T) { sut.Key = "Key" sut.UUID = "UUID" sut.Value = string(make([]byte, MaxValueSize+1)) - assert.Equal(t, sut.ValidateBasic(), sdk.ErrInternal("Value too large")) + assert.Equal(t, sdk.ErrInternal("Value too large"), sut.ValidateBasic()) } func TestMsgBLZCreate_GetSignBytes(t *testing.T) { @@ -160,6 +160,11 @@ func TestMsgBLZUpdate_ValidateBasic(t *testing.T) { sut.UUID = "uuid" sut.Key = "" assert.Equal(t, sut.ValidateBasic(), sdk.ErrInvalidPubKey("UUID or key Empty")) + + sut.Key = "Key" + sut.UUID = "UUID" + sut.Value = string(make([]byte, MaxValueSize+1)) + assert.Equal(t, sdk.ErrInternal("Value too large"), sut.ValidateBasic()) } func TestMsgBLZUpdate_GetSignBytes(t *testing.T) {