generated from multiversx/mx-chain-ws-connector-template-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'hyperblock-processor' into implement-blocks-pool
- Loading branch information
Showing
16 changed files
with
513 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package process_test | ||
|
||
// TODO: add tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package process_test | ||
|
||
import ( | ||
"encoding/hex" | ||
"testing" | ||
|
||
"github.com/multiversx/mx-chain-core-go/data/outport" | ||
"github.com/multiversx/mx-chain-ws-connector-template-go/process" | ||
"github.com/multiversx/mx-chain-ws-connector-template-go/testscommon" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestNewDataAggregator(t *testing.T) { | ||
t.Parallel() | ||
|
||
t.Run("nil blocks pool", func(t *testing.T) { | ||
t.Parallel() | ||
|
||
da, err := process.NewDataAggregator(nil) | ||
require.Nil(t, da) | ||
require.Equal(t, process.ErrNilBlocksPool, err) | ||
}) | ||
|
||
t.Run("should work", func(t *testing.T) { | ||
t.Parallel() | ||
|
||
da, err := process.NewDataAggregator(&testscommon.BlocksPoolStub{}) | ||
Check failure on line 27 in process/dataAggregator_test.go GitHub Actions / golangci linter
|
||
require.Nil(t, err) | ||
require.False(t, da.IsInterfaceNil()) | ||
}) | ||
} | ||
|
||
func TestDataAggregator_ProcessHyperBlock(t *testing.T) { | ||
t.Parallel() | ||
|
||
headerHash := []byte("headerHash1") | ||
|
||
shardOutportBlock := createOutportBlock() | ||
shardOutportBlock.BlockData.HeaderHash = headerHash | ||
|
||
blocksPoolStub := &testscommon.BlocksPoolStub{ | ||
GetBlockCalled: func(hash []byte) (*outport.OutportBlock, error) { | ||
|
||
return shardOutportBlock, nil | ||
}, | ||
} | ||
|
||
da, err := process.NewDataAggregator(blocksPoolStub) | ||
Check failure on line 48 in process/dataAggregator_test.go GitHub Actions / golangci linter
|
||
require.Nil(t, err) | ||
|
||
outportBlock := createMetaOutportBlock() | ||
outportBlock.NotarizedHeadersHashes = []string{hex.EncodeToString(headerHash)} | ||
|
||
hyperOutportBlock, err := da.ProcessHyperBlock(outportBlock) | ||
require.Nil(t, err) | ||
require.Equal(t, shardOutportBlock, hyperOutportBlock.NotarizedHeadersOutportData[0].OutportBlock) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.