evm: fix format errors in String() of QueryEthLogs (#748)

* FIX: format errors in String() of QueryETHLogs

* FINISH: add change log
This commit is contained in:
MichaelWang 2021-01-25 22:09:28 +08:00 committed by GitHub
parent dce0b0cffb
commit bfa9a733e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 1 deletions

View File

@ -44,6 +44,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Bug Fixes ### 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. * (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. * (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. * (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.

View File

@ -71,7 +71,13 @@ type QueryETHLogs struct {
} }
func (q QueryETHLogs) String() string { 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 // QueryBloomFilter is response type for tx logs query

View File

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