-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/chain-go-sdk' into MX-16271-indexing-incoming-tokens
- Loading branch information
Showing
58 changed files
with
592 additions
and
478 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
15 changes: 2 additions & 13 deletions
15
epochStart/bootstrap/sovereignEpochStartBootstrapperFactory.go
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
44 changes: 9 additions & 35 deletions
44
epochStart/bootstrap/sovereignEpochStartBootstrapperFactory_test.go
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 |
---|---|---|
@@ -1,69 +1,43 @@ | ||
package bootstrap | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/multiversx/mx-chain-go/config" | ||
"github.com/multiversx/mx-chain-go/errors" | ||
|
||
"github.com/multiversx/mx-chain-core-go/data/endProcess" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/multiversx/mx-chain-go/config" | ||
) | ||
|
||
func TestNewSovereignEpochStartBootstrapperFactory(t *testing.T) { | ||
t.Parallel() | ||
|
||
sebf, err := NewSovereignEpochStartBootstrapperFactory(nil) | ||
|
||
require.Nil(t, sebf) | ||
require.Equal(t, errors.ErrNilEpochStartBootstrapperFactory, err) | ||
|
||
esbf := NewEpochStartBootstrapperFactory() | ||
sebf, err = NewSovereignEpochStartBootstrapperFactory(esbf) | ||
|
||
require.Nil(t, err) | ||
require.NotNil(t, sebf) | ||
sebf := NewSovereignEpochStartBootstrapperFactory() | ||
require.False(t, sebf.IsInterfaceNil()) | ||
} | ||
|
||
func TestSovereignEpochStartBootstrapperFactory_CreateEpochStartBootstrapper(t *testing.T) { | ||
t.Parallel() | ||
|
||
esbf := NewEpochStartBootstrapperFactory() | ||
sebf, _ := NewSovereignEpochStartBootstrapperFactory(esbf) | ||
|
||
sebf := NewSovereignEpochStartBootstrapperFactory() | ||
seb, err := sebf.CreateEpochStartBootstrapper(getDefaultArgs()) | ||
|
||
require.Nil(t, err) | ||
require.NotNil(t, seb) | ||
require.Equal(t, "*bootstrap.sovereignChainEpochStartBootstrap", fmt.Sprintf("%T", seb)) | ||
} | ||
|
||
func TestSovereignEpochStartBootstrapperFactory_CreateStorageEpochStartBootstrapper(t *testing.T) { | ||
t.Parallel() | ||
|
||
esbf := NewEpochStartBootstrapperFactory() | ||
sebf, _ := NewSovereignEpochStartBootstrapperFactory(esbf) | ||
|
||
sebf := NewSovereignEpochStartBootstrapperFactory() | ||
arg := ArgsStorageEpochStartBootstrap{ | ||
ArgsEpochStartBootstrap: getDefaultArgs(), | ||
ImportDbConfig: config.ImportDbConfig{}, | ||
ChanGracefullyClose: make(chan endProcess.ArgEndProcess, 1), | ||
TimeToWaitForRequestedData: 1, | ||
} | ||
esb, err := sebf.CreateStorageEpochStartBootstrapper(arg) | ||
|
||
require.Nil(t, err) | ||
require.NotNil(t, esb) | ||
|
||
} | ||
|
||
func TestSovereignEpochStartBootstrapperFactory_IsInterfaceNil(t *testing.T) { | ||
t.Parallel() | ||
|
||
esbf := NewEpochStartBootstrapperFactory() | ||
sebf, _ := NewSovereignEpochStartBootstrapperFactory(esbf) | ||
|
||
require.False(t, sebf.IsInterfaceNil()) | ||
require.Equal(t, "*bootstrap.storageEpochStartBootstrap", fmt.Sprintf("%T", esb)) | ||
|
||
sebf = (*sovereignEpochStartBootstrapperFactory)(nil) | ||
require.True(t, sebf.IsInterfaceNil()) | ||
} |
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,38 @@ | ||
package epochStartTrigger | ||
|
||
import ( | ||
"github.com/multiversx/mx-chain-core-go/core/check" | ||
|
||
"github.com/multiversx/mx-chain-go/dataRetriever" | ||
"github.com/multiversx/mx-chain-go/factory" | ||
"github.com/multiversx/mx-chain-go/process" | ||
) | ||
|
||
func checkNilArgs(args factory.ArgsEpochStartTrigger) error { | ||
if check.IfNil(args.DataComps) { | ||
return process.ErrNilDataComponentsHolder | ||
} | ||
if check.IfNil(args.DataComps.Datapool()) { | ||
return process.ErrNilDataPoolHolder | ||
} | ||
if check.IfNil(args.DataComps.Blockchain()) { | ||
return process.ErrNilBlockChain | ||
} | ||
if check.IfNil(args.DataComps.Datapool().MiniBlocks()) { | ||
return dataRetriever.ErrNilMiniblocksPool | ||
} | ||
if check.IfNil(args.DataComps.Datapool().ValidatorsInfo()) { | ||
return process.ErrNilValidatorInfoPool | ||
} | ||
if check.IfNil(args.BootstrapComponents) { | ||
return process.ErrNilBootstrapComponentsHolder | ||
} | ||
if check.IfNil(args.BootstrapComponents.ShardCoordinator()) { | ||
return process.ErrNilShardCoordinator | ||
} | ||
if check.IfNil(args.RequestHandler) { | ||
return process.ErrNilRequestHandler | ||
} | ||
|
||
return nil | ||
} |
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,82 @@ | ||
package epochStartTrigger | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/multiversx/mx-chain-go/dataRetriever" | ||
"github.com/multiversx/mx-chain-go/process" | ||
"github.com/multiversx/mx-chain-go/storage" | ||
) | ||
|
||
func TestCheckNilArgs(t *testing.T) { | ||
t.Parallel() | ||
|
||
t.Run("nil data comps", func(t *testing.T) { | ||
args := createArgs(0) | ||
args.DataComps = nil | ||
err := checkNilArgs(args) | ||
require.Equal(t, process.ErrNilDataComponentsHolder, err) | ||
}) | ||
t.Run("nil data pool", func(t *testing.T) { | ||
args := createArgs(0) | ||
dataComps := createDataCompsMock() | ||
dataComps.DataPool = nil | ||
args.DataComps = dataComps | ||
err := checkNilArgs(args) | ||
require.Equal(t, process.ErrNilDataPoolHolder, err) | ||
}) | ||
t.Run("nil blockchain", func(t *testing.T) { | ||
args := createArgs(0) | ||
dataComps := createDataCompsMock() | ||
dataComps.BlockChain = nil | ||
args.DataComps = dataComps | ||
err := checkNilArgs(args) | ||
require.Equal(t, process.ErrNilBlockChain, err) | ||
}) | ||
t.Run("nil mb pool", func(t *testing.T) { | ||
args := createArgs(0) | ||
dataComps := createDataCompsMock() | ||
dataPool := createDataPoolMock() | ||
dataPool.MiniBlocksCalled = func() storage.Cacher { | ||
return nil | ||
} | ||
dataComps.DataPool = dataPool | ||
args.DataComps = dataComps | ||
err := checkNilArgs(args) | ||
require.Equal(t, dataRetriever.ErrNilMiniblocksPool, err) | ||
}) | ||
t.Run("nil validator pool", func(t *testing.T) { | ||
args := createArgs(0) | ||
dataComps := createDataCompsMock() | ||
dataPool := createDataPoolMock() | ||
dataPool.ValidatorsInfoCalled = func() dataRetriever.ShardedDataCacherNotifier { | ||
return nil | ||
} | ||
dataComps.DataPool = dataPool | ||
args.DataComps = dataComps | ||
err := checkNilArgs(args) | ||
require.Equal(t, process.ErrNilValidatorInfoPool, err) | ||
}) | ||
t.Run("nil bootstrap comps", func(t *testing.T) { | ||
args := createArgs(0) | ||
args.BootstrapComponents = nil | ||
err := checkNilArgs(args) | ||
require.Equal(t, process.ErrNilBootstrapComponentsHolder, err) | ||
}) | ||
t.Run("nil shard coordinator", func(t *testing.T) { | ||
args := createArgs(0) | ||
bootStrapComps := createBootstrapComps(0) | ||
bootStrapComps.ShardCoordinatorCalled = nil | ||
args.BootstrapComponents = bootStrapComps | ||
err := checkNilArgs(args) | ||
require.Equal(t, process.ErrNilShardCoordinator, err) | ||
}) | ||
t.Run("nil request handler", func(t *testing.T) { | ||
args := createArgs(0) | ||
args.RequestHandler = nil | ||
err := checkNilArgs(args) | ||
require.Equal(t, process.ErrNilRequestHandler, err) | ||
}) | ||
} |
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.