Skip to content
This repository was archived by the owner on Nov 30, 2021. It is now read-only.

Commit dce0b0c

Browse files
evm: fix pointer in ResultData.String() (#733)
1 parent 0fe6353 commit dce0b0c

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

x/evm/types/utils.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,19 @@ type ResultData struct {
6868

6969
// String implements fmt.Stringer interface.
7070
func (rd ResultData) String() string {
71+
var logsStr string
72+
logsLen := len(rd.Logs)
73+
for i := 0; i < logsLen; i++ {
74+
logsStr = fmt.Sprintf("%s\t\t%v\n ", logsStr, *rd.Logs[i])
75+
}
76+
7177
return strings.TrimSpace(fmt.Sprintf(`ResultData:
7278
ContractAddress: %s
7379
Bloom: %s
74-
Logs: %v
7580
Ret: %v
76-
TxHash: %s
77-
`, rd.ContractAddress.String(), rd.Bloom.Big().String(), rd.Logs, rd.Ret, rd.TxHash.String()))
81+
TxHash: %s
82+
Logs:
83+
%s`, rd.ContractAddress.String(), rd.Bloom.Big().String(), rd.Ret, rd.TxHash.String(), logsStr))
7884
}
7985

8086
// EncodeResultData takes all of the necessary data from the EVM execution

x/evm/types/utils_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package types
22

33
import (
4+
"strings"
45
"testing"
56

67
"github.com/stretchr/testify/require"
@@ -34,3 +35,34 @@ func TestEvmDataEncoding(t *testing.T) {
3435
require.Equal(t, data.Logs, res.Logs)
3536
require.Equal(t, ret, res.Ret)
3637
}
38+
39+
func TestResultData_String(t *testing.T) {
40+
const expectedResultDataStr = `ResultData:
41+
ContractAddress: 0x5dE8a020088a2D6d0a23c204FFbeD02790466B49
42+
Bloom: 259
43+
Ret: [5 8]
44+
TxHash: 0x0000000000000000000000000000000000000000000000000000000000000000
45+
Logs:
46+
{0x0000000000000000000000000000000000000000 [] [1 2 3 4] 17 0x0000000000000000000000000000000000000000000000000000000000000000 0 0x0000000000000000000000000000000000000000000000000000000000000000 0 false}
47+
{0x0000000000000000000000000000000000000000 [] [5 6 7 8] 18 0x0000000000000000000000000000000000000000000000000000000000000000 0 0x0000000000000000000000000000000000000000000000000000000000000000 0 false}`
48+
addr := ethcmn.HexToAddress("0x5dE8a020088a2D6d0a23c204FFbeD02790466B49")
49+
bloom := ethtypes.BytesToBloom([]byte{0x1, 0x3})
50+
ret := []byte{0x5, 0x8}
51+
52+
data := ResultData{
53+
ContractAddress: addr,
54+
Bloom: bloom,
55+
Logs: []*ethtypes.Log{
56+
{
57+
Data: []byte{1, 2, 3, 4},
58+
BlockNumber: 17,
59+
},
60+
{
61+
Data: []byte{5, 6, 7, 8},
62+
BlockNumber: 18,
63+
}},
64+
Ret: ret,
65+
}
66+
67+
require.True(t, strings.EqualFold(expectedResultDataStr, data.String()))
68+
}

0 commit comments

Comments
 (0)