Merge pull request #546 from CosmWasm/reply_result_545

Empty (non nil) reply data can overwrites response
This commit is contained in:
Alexander Peters
2021-07-06 09:15:18 +02:00
committed by GitHub
2 changed files with 4 additions and 4 deletions

View File

@@ -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
}
}

View File

@@ -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) {
@@ -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) {
@@ -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": {