Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty message with media implementation #113

Merged
merged 9 commits into from
Mar 12, 2020
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#Version 0.4.0
- Added the support for posting empty-message posts with medias (#110)

# Version 0.3.0
## Changes
- Implemented the support for media posts (#36)
Expand Down
2 changes: 1 addition & 1 deletion cli_test/cli_posts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestDesmosCLIPostsCreateWithMedias(t *testing.T) {

// Later usage variables
subspace := "4e188d9c17150037d5199bbdb91ae1eb2a78a15aca04cb35530cccb81494b36e"
message := "message"
message := ""
leobragaz marked this conversation as resolved.
Show resolved Hide resolved
fooAcc := f.QueryAccount(fooAddr)
startTokens := sdk.TokensFromConsensusPower(140)
require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(denom))
Expand Down
2 changes: 1 addition & 1 deletion x/posts/internal/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (msg MsgCreatePost) ValidateBasic() error {
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, fmt.Sprintf("Invalid creator address: %s", msg.Creator))
}

if len(strings.TrimSpace(msg.Message)) == 0 {
if len(strings.TrimSpace(msg.Message)) == 0 && len(msg.Medias) == 0 {
leobragaz marked this conversation as resolved.
Show resolved Hide resolved
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Post message cannot be empty nor blank")
leobragaz marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down
4 changes: 2 additions & 2 deletions x/posts/internal/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestMsgCreatePost_ValidateBasic(t *testing.T) {
error: sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "Invalid creator address: "),
},
{
name: "Empty message returns error",
name: "Empty message returns error if medias are empty",
leobragaz marked this conversation as resolved.
Show resolved Hide resolved
msg: types.NewMsgCreatePost(
"",
types.PostID(0),
Expand All @@ -84,7 +84,7 @@ func TestMsgCreatePost_ValidateBasic(t *testing.T) {
map[string]string{},
creator,
date,
msgCreatePost.Medias,
nil,
msgCreatePost.PollData,
),
error: sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Post message cannot be empty nor blank"),
Expand Down