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

FIX: format errors in String() of QueryETHLogs #748

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 7 additions & 1 deletion x/evm/types/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions x/evm/types/querier_test.go
Original file line number Diff line number Diff line change
@@ -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()))
}