Skip to content

Commit

Permalink
unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
miiu96 committed Oct 7, 2024
1 parent fdeb371 commit 9e25a5f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
2 changes: 1 addition & 1 deletion integrationtests/testdata/relayedTxV3/innerTx1.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"chainID": "",
"version": 0,
"relayedTxHash": "72656c6179656454785633"
}
}
2 changes: 1 addition & 1 deletion integrationtests/testdata/relayedTxV3/innerTx2.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"chainID": "",
"version": 0,
"relayedTxHash": "72656c6179656454785633"
}
}
2 changes: 1 addition & 1 deletion process/elasticproc/elasticProcessor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"encoding/hex"
"errors"
"github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/innerTxs"
"strings"
"testing"

Expand All @@ -19,6 +18,7 @@ import (
"github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/accounts"
"github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/block"
"github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/converters"
"github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/innerTxs"
"github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/logsevents"
"github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/miniblocks"
"github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/operations"
Expand Down
33 changes: 33 additions & 0 deletions process/elasticproc/innerTxs/serialize_test.go
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
package innerTxs

import (
"testing"

"github.com/multiversx/mx-chain-es-indexer-go/data"
"github.com/multiversx/mx-chain-es-indexer-go/process/dataindexer"
"github.com/stretchr/testify/require"
)

func TestInnerTxsProcessor_SerializeInnerTxs(t *testing.T) {
t.Parallel()

innerTxs := []*data.InnerTransaction{
{
Hash: "h1",
Type: InnerTxType,
},
{
Hash: "h2",
Type: InnerTxType,
},
}

innerTxsProc := NewInnerTxsProcessor()
buffSlice := data.NewBufferSlice(0)
err := innerTxsProc.SerializeInnerTxs(innerTxs, buffSlice, dataindexer.OperationsIndex)
require.Nil(t, err)
require.Equal(t, `{ "index" : { "_index":"operations","_id" : "h1" } }
{"type":"innerTx","nonce":0,"value":"","receiver":"","sender":"","gasPrice":0,"gasLimit":0,"chainID":"","version":0}
{ "index" : { "_index":"operations","_id" : "h2" } }
{"type":"innerTx","nonce":0,"value":"","receiver":"","sender":"","gasPrice":0,"gasLimit":0,"chainID":"","version":0}
`, buffSlice.Buffers()[0].String())
}

0 comments on commit 9e25a5f

Please sign in to comment.