Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoded tx hash to hex format due to serializing issues in proto. #6688

Closed
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
3 changes: 2 additions & 1 deletion state/stateChanges/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package stateChanges

import (
"bytes"
"encoding/hex"
"encoding/json"
"fmt"
"sync"
Expand Down Expand Up @@ -100,7 +101,7 @@ func (c *collector) Publish() (map[string]*data.StateChanges, error) {

stateChangesForTxs := make(map[string]*data.StateChanges)
for _, stateChange := range c.stateChanges {
txHash := string(stateChange.GetTxHash())
txHash := hex.EncodeToString(stateChange.GetTxHash())

st, ok := stateChange.(*data.StateChange)
if !ok {
Expand Down
17 changes: 9 additions & 8 deletions state/stateChanges/collector_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package stateChanges

import (
"encoding/hex"
"fmt"
"math/big"
"strconv"
Expand Down Expand Up @@ -344,10 +345,10 @@ func TestStateChangesCollector_Publish(t *testing.T) {
require.NoError(t, err)

require.Len(t, stateChangesForTx, 1)
require.Len(t, stateChangesForTx["hash0"].StateChanges, 10)
require.Len(t, stateChangesForTx[hex.EncodeToString([]byte("hash0"))].StateChanges, 10)

require.Equal(t, stateChangesForTx, map[string]*data.StateChanges{
"hash0": {
hex.EncodeToString([]byte("hash0")): {
StateChanges: []*data.StateChange{
{Type: data.Write, TxHash: []byte("hash0")},
{Type: data.Write, TxHash: []byte("hash0")},
Expand Down Expand Up @@ -391,10 +392,10 @@ func TestStateChangesCollector_Publish(t *testing.T) {
require.NoError(t, err)

require.Len(t, stateChangesForTx, 1)
require.Len(t, stateChangesForTx["hash1"].StateChanges, 10)
require.Len(t, stateChangesForTx[hex.EncodeToString([]byte("hash1"))].StateChanges, 10)

require.Equal(t, stateChangesForTx, map[string]*data.StateChanges{
"hash1": {
hex.EncodeToString([]byte("hash1")): {
StateChanges: []*data.StateChange{
{Type: data.Read, TxHash: []byte("hash1")},
{Type: data.Read, TxHash: []byte("hash1")},
Expand Down Expand Up @@ -438,11 +439,11 @@ func TestStateChangesCollector_Publish(t *testing.T) {
require.NoError(t, err)

require.Len(t, stateChangesForTx, 2)
require.Len(t, stateChangesForTx["hash0"].StateChanges, 10)
require.Len(t, stateChangesForTx["hash1"].StateChanges, 10)
require.Len(t, stateChangesForTx[hex.EncodeToString([]byte("hash0"))].StateChanges, 10)
require.Len(t, stateChangesForTx[hex.EncodeToString([]byte("hash1"))].StateChanges, 10)

require.Equal(t, stateChangesForTx, map[string]*data.StateChanges{
"hash0": {
hex.EncodeToString([]byte("hash0")): {
StateChanges: []*data.StateChange{
{Type: data.Write, TxHash: []byte("hash0")},
{Type: data.Write, TxHash: []byte("hash0")},
Expand All @@ -456,7 +457,7 @@ func TestStateChangesCollector_Publish(t *testing.T) {
{Type: data.Write, TxHash: []byte("hash0")},
},
},
"hash1": {
hex.EncodeToString([]byte("hash1")): {
StateChanges: []*data.StateChange{
{Type: data.Read, TxHash: []byte("hash1")},
{Type: data.Read, TxHash: []byte("hash1")},
Expand Down
Loading