Merge PR #4230: Minor cleanup in tx tags and response format

This commit is contained in:
Alexander Bezobchuk 2019-04-29 23:50:44 -04:00 committed by GitHub
parent 5344e8d768
commit f0f7b7dab7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 8 deletions

View File

@ -0,0 +1 @@
#4230 Change the type of ABCIMessageLog#MsgIndex to uint16 for proper serialization.

View File

@ -0,0 +1 @@
#4230 Properly set and display the message index through the TxResponse.

View File

@ -698,7 +698,7 @@ func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, mode runTxMode) (re
tags = append(tags, sdk.MakeTag(sdk.TagAction, msg.Type()))
tags = append(tags, msgResult.Tags...)
idxLog := sdk.ABCIMessageLog{MsgIndex: msgIdx, Log: msgResult.Log}
idxLog := sdk.ABCIMessageLog{MsgIndex: uint16(msgIdx), Log: msgResult.Log}
// stop execution and return on first failed message
if !msgResult.IsOK() {

View File

@ -45,7 +45,7 @@ type ABCIMessageLogs []ABCIMessageLog
// ABCIMessageLog defines a structure containing an indexed tx ABCI message log.
type ABCIMessageLog struct {
MsgIndex int `json:"msg_index"`
MsgIndex uint16 `json:"msg_index"`
Success bool `json:"success"`
Log string `json:"log"`
}
@ -229,10 +229,6 @@ func (r TxResponse) String() string {
sb.WriteString(fmt.Sprintf(" GasUsed: %d\n", r.GasUsed))
}
if len(r.Tags) > 0 {
sb.WriteString(fmt.Sprintf(" Tags: \n%s\n", r.Tags.String()))
}
if r.Codespace != "" {
sb.WriteString(fmt.Sprintf(" Codespace: %s\n", r.Codespace))
}
@ -241,6 +237,10 @@ func (r TxResponse) String() string {
sb.WriteString(fmt.Sprintf(" Timestamp: %s\n", r.Timestamp))
}
if len(r.Tags) > 0 {
sb.WriteString(fmt.Sprintf(" Tags: \n%s\n", r.Tags.String()))
}
return strings.TrimSpace(sb.String())
}

View File

@ -24,6 +24,6 @@ func TestParseABCILog(t *testing.T) {
require.NoError(t, err)
require.Len(t, res, 1)
require.Equal(t, res[0].Log, "")
require.Equal(t, res[0].MsgIndex, 1)
require.Equal(t, res[0].MsgIndex, uint16(1))
require.True(t, res[0].Success)
}

View File

@ -96,7 +96,8 @@ func (st StringTags) String() string {
for _, t := range st {
sb.WriteString(fmt.Sprintf(" - %s\n", t.String()))
}
return sb.String()
return strings.TrimRight(sb.String(), "\n")
}
// Conversion function from a []byte tag to a string tag