diff --git a/cmd/proxy/main.go b/cmd/proxy/main.go index 3c013af9..13ddedb7 100644 --- a/cmd/proxy/main.go +++ b/cmd/proxy/main.go @@ -163,8 +163,8 @@ VERSION: Name: "start-swagger-ui", Usage: "If set to true, will start a Swagger UI on the root", } - // sovereignConfig defines a flag that specifies if what run type components should use - sovereignConfig = cli.BoolFlag{ + // sovereign defines a flag that specifies if what run type components should use + sovereign = cli.BoolFlag{ Name: "sovereign-config", Usage: "If set to true, will use sovereign run type components", } @@ -192,7 +192,7 @@ func main() { workingDirectory, memBallast, startSwaggerUI, - sovereignConfig, + sovereign, } app.Authors = []cli.Author{ { @@ -381,8 +381,8 @@ func createVersionsRegistryTestOrProduction( statusMetricsHandler, ctx.GlobalString(walletKeyPemFile.Name), ctx.GlobalString(apiConfigDirectory.Name), + ctx.GlobalBool(sovereign.Name), closableComponents, - ctx.GlobalBool(sovereignConfig.Name), ) } @@ -392,8 +392,8 @@ func createVersionsRegistryTestOrProduction( statusMetricsHandler, ctx.GlobalString(walletKeyPemFile.Name), ctx.GlobalString(apiConfigDirectory.Name), + ctx.GlobalBool(sovereign.Name), closableComponents, - ctx.GlobalBool(sovereignConfig.Name), ) } @@ -403,8 +403,8 @@ func createVersionsRegistry( statusMetricsHandler data.StatusMetricsProvider, pemFileLocation string, apiConfigDirectoryPath string, - closableComponents *data.ClosableComponentsHandler, isSovereignConfig bool, + closableComponents *data.ClosableComponentsHandler, ) (data.VersionsRegistryHandler, error) { pubKeyConverter, err := pubkeyConverter.NewBech32PubkeyConverter(cfg.AddressPubkeyConverter.Length, addressHRP) if err != nil { diff --git a/factory/errors.go b/factory/errors.go deleted file mode 100644 index 1b899847..00000000 --- a/factory/errors.go +++ /dev/null @@ -1,8 +0,0 @@ -package factory - -import ( - "errors" -) - -// ErrNilRunTypeComponents signals that nil run type components were provided -var ErrNilRunTypeComponents = errors.New("nil run type components") diff --git a/factory/runType/interface.go b/factory/runType/interface.go index d749ae48..37448d92 100644 --- a/factory/runType/interface.go +++ b/factory/runType/interface.go @@ -1,6 +1,6 @@ package runType -// RunTypeComponentsCreator is the interface for the runTypeComponentsCreator +// RunTypeComponentsCreator is the interface for creating run type components type RunTypeComponentsCreator interface { Create() *runTypeComponents IsInterfaceNil() bool diff --git a/factory/runType/runTypeComponents.go b/factory/runType/runTypeComponents.go index db4a7a5f..5e96d670 100644 --- a/factory/runType/runTypeComponents.go +++ b/factory/runType/runTypeComponents.go @@ -1,9 +1,13 @@ package runType import ( + "errors" + "github.com/multiversx/mx-chain-proxy-go/process" ) +var errNilRunTypeComponents = errors.New("nil run type components") + type runTypeComponents struct { txNotarizationCheckerHandlerCreator process.TxNotarizationCheckerHandler } diff --git a/factory/runType/runTypeComponentsHandler.go b/factory/runType/runTypeComponentsHandler.go index 4548cab0..b098f309 100644 --- a/factory/runType/runTypeComponentsHandler.go +++ b/factory/runType/runTypeComponentsHandler.go @@ -24,7 +24,7 @@ type managedRunTypeComponents struct { // NewManagedRunTypeComponents returns a news instance of managed runType core components func NewManagedRunTypeComponents(rtc RunTypeComponentsCreator) (*managedRunTypeComponents, error) { if rtc == nil { - return nil, factory.ErrNilRunTypeComponents + return nil, errNilRunTypeComponents } return &managedRunTypeComponents{ @@ -68,7 +68,7 @@ func (mrtc *managedRunTypeComponents) CheckSubcomponents() error { defer mrtc.mutRunTypeCoreComponents.RUnlock() if check.IfNil(mrtc.runTypeComponents) { - return factory.ErrNilRunTypeComponents + return errNilRunTypeComponents } if check.IfNil(mrtc.txNotarizationCheckerHandlerCreator) { return process.ErrNilTxNotarizationCheckerHandler diff --git a/factory/runType/runTypeComponentsHandler_test.go b/factory/runType/runTypeComponentsHandler_test.go index 9cd5d46a..3e1991d8 100644 --- a/factory/runType/runTypeComponentsHandler_test.go +++ b/factory/runType/runTypeComponentsHandler_test.go @@ -18,8 +18,8 @@ func TestNewManagedRunTypeComponents(t *testing.T) { t.Run("should error", func(t *testing.T) { managedRunTypeComponents, err := NewManagedRunTypeComponents(nil) - require.ErrorIs(t, err, factory.ErrNilRunTypeComponents) - require.True(t, managedRunTypeComponents.IsInterfaceNil()) + require.ErrorIs(t, err, errNilRunTypeComponents) + require.Nil(t, managedRunTypeComponents) }) t.Run("should work", func(t *testing.T) { rtcf := NewRunTypeComponentsFactory() @@ -68,7 +68,7 @@ func TestManagedRunTypeComponents_CheckSubcomponents(t *testing.T) { managedRunTypeComponents, _ := createComponents() err := managedRunTypeComponents.CheckSubcomponents() - require.Equal(t, factory.ErrNilRunTypeComponents, err) + require.Equal(t, errNilRunTypeComponents, err) err = managedRunTypeComponents.Create() require.NoError(t, err)