Skip to content

Commit

Permalink
Merge branch 'MX-15407-sovereign-config-runtype-components' into MX-1…
Browse files Browse the repository at this point in the history
…5407-tx-notarization-checker

# Conflicts:
#	factory/runType/runTypeComponents.go
  • Loading branch information
axenteoctavian committed Nov 22, 2024
2 parents fa31f97 + f7e8f78 commit 5cb3271
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 20 deletions.
12 changes: 6 additions & 6 deletions cmd/proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
Expand Down Expand Up @@ -192,7 +192,7 @@ func main() {
workingDirectory,
memBallast,
startSwaggerUI,
sovereignConfig,
sovereign,
}
app.Authors = []cli.Author{
{
Expand Down Expand Up @@ -381,8 +381,8 @@ func createVersionsRegistryTestOrProduction(
statusMetricsHandler,
ctx.GlobalString(walletKeyPemFile.Name),
ctx.GlobalString(apiConfigDirectory.Name),
ctx.GlobalBool(sovereign.Name),
closableComponents,
ctx.GlobalBool(sovereignConfig.Name),
)
}

Expand All @@ -392,8 +392,8 @@ func createVersionsRegistryTestOrProduction(
statusMetricsHandler,
ctx.GlobalString(walletKeyPemFile.Name),
ctx.GlobalString(apiConfigDirectory.Name),
ctx.GlobalBool(sovereign.Name),
closableComponents,
ctx.GlobalBool(sovereignConfig.Name),
)
}

Expand All @@ -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 {
Expand Down
8 changes: 0 additions & 8 deletions factory/errors.go

This file was deleted.

2 changes: 1 addition & 1 deletion factory/runType/interface.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 4 additions & 0 deletions factory/runType/runTypeComponents.go
Original file line number Diff line number Diff line change
@@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions factory/runType/runTypeComponentsHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions factory/runType/runTypeComponentsHandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5cb3271

Please sign in to comment.