From d279dfa4475734007af611b8cc8537f4550926ac Mon Sep 17 00:00:00 2001 From: MichaelWang Date: Mon, 25 Jan 2021 14:47:49 +0800 Subject: [PATCH 1/2] FIX: format errors in String() of QueryETHLogs --- x/evm/types/querier.go | 8 +++++++- x/evm/types/querier_test.go | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 x/evm/types/querier_test.go diff --git a/x/evm/types/querier.go b/x/evm/types/querier.go index 5fdeb7c54..dca3f932a 100644 --- a/x/evm/types/querier.go +++ b/x/evm/types/querier.go @@ -71,7 +71,13 @@ type QueryETHLogs struct { } func (q QueryETHLogs) String() string { - return fmt.Sprintf("%+v", q.Logs) + var logsStr string + logsLen := len(q.Logs) + for i := 0; i < logsLen; i++ { + logsStr = fmt.Sprintf("%s%v\n", logsStr, *q.Logs[i]) + } + + return logsStr } // QueryBloomFilter is response type for tx logs query diff --git a/x/evm/types/querier_test.go b/x/evm/types/querier_test.go new file mode 100644 index 000000000..7f66fb220 --- /dev/null +++ b/x/evm/types/querier_test.go @@ -0,0 +1,26 @@ +package types + +import ( + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/stretchr/testify/require" + "strings" + "testing" +) + +func TestQueryETHLogs_String(t *testing.T) { + const expectedQueryETHLogsStr = `{0x0000000000000000000000000000000000000000 [] [1 2 3 4] 9 0x0000000000000000000000000000000000000000000000000000000000000000 0 0x0000000000000000000000000000000000000000000000000000000000000000 0 false} +{0x0000000000000000000000000000000000000000 [] [5 6 7 8] 10 0x0000000000000000000000000000000000000000000000000000000000000000 0 0x0000000000000000000000000000000000000000000000000000000000000000 0 false} +` + logs := []*ethtypes.Log{ + { + Data: []byte{1, 2, 3, 4}, + BlockNumber: 9, + }, + { + Data: []byte{5, 6, 7, 8}, + BlockNumber: 10, + }, + } + + require.True(t, strings.EqualFold(expectedQueryETHLogsStr, QueryETHLogs{logs}.String())) +} From f98efd78eb45cc5686cc9cfc728823284bfb78b9 Mon Sep 17 00:00:00 2001 From: MichaelWang Date: Mon, 25 Jan 2021 15:02:34 +0800 Subject: [PATCH 2/2] FINISH: add change log --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 263afeda2..16053bea4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +* (evm) [\#747](https://github.com/cosmos/ethermint/issues/747) Fix format errors in String() of QueryETHLogs * (evm) [\#687](https://github.com/cosmos/ethermint/issues/687) Fix nonce check to explicitly check for the correct nonce, rather than a simple 'greater than' comparison. * (api) [\#687](https://github.com/cosmos/ethermint/issues/687) Returns error for a transaction with an incorrect nonce. * (evm) [\#674](https://github.com/cosmos/ethermint/issues/674) Reset all cache after account data has been committed in `EndBlock` to make sure every node state consistent.