Skip to content

Commit

Permalink
Merge pull request cosmos#546 from CosmWasm/reply_result_545
Browse files Browse the repository at this point in the history
Empty (non nil) reply data can overwrites response
  • Loading branch information
alpe authored Jul 6, 2021
2 parents 273b57a + b0885b0 commit a29b298
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion x/wasm/keeper/msg_dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (d MessageDispatcher) DispatchSubmessages(ctx sdk.Context, contractAddr sdk
switch {
case err != nil:
return nil, sdkerrors.Wrap(err, "reply")
case len(rspData) != 0:
case rspData != nil:
rsp = rspData
}
}
Expand Down
6 changes: 3 additions & 3 deletions x/wasm/keeper/msg_dispatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func TestDispatchSubmessages(t *testing.T) {
expData: []byte("myReplyData:2"),
expCommits: []bool{false, false},
},
"multiple msg - last reply with non nil": {
"multiple msg - last non nil reply to overwrite responose": {
msgs: []wasmvmtypes.SubMsg{{ID: 1, ReplyOn: wasmvmtypes.ReplyError}, {ID: 2, ReplyOn: wasmvmtypes.ReplyError}},
replyer: &mockReplyer{
replyFn: func(ctx sdk.Context, contractAddress sdk.AccAddress, reply wasmvmtypes.Reply) ([]byte, error) {
Expand All @@ -184,7 +184,7 @@ func TestDispatchSubmessages(t *testing.T) {
expData: []byte("myReplyData:1"),
expCommits: []bool{false, false},
},
"multiple msg - last reply can be empty to overwrite": {
"multiple msg - empty reply can overwrite result": {
msgs: []wasmvmtypes.SubMsg{{ID: 1, ReplyOn: wasmvmtypes.ReplyError}, {ID: 2, ReplyOn: wasmvmtypes.ReplyError}},
replyer: &mockReplyer{
replyFn: func(ctx sdk.Context, contractAddress sdk.AccAddress, reply wasmvmtypes.Reply) ([]byte, error) {
Expand All @@ -199,7 +199,7 @@ func TestDispatchSubmessages(t *testing.T) {
return nil, nil, errors.New("my error")
},
},
expData: []byte("myReplyData:1"),
expData: []byte{},
expCommits: []bool{false, false},
},
"empty replyOn rejected": {
Expand Down

0 comments on commit a29b298

Please sign in to comment.