diff --git a/core/epochFlags.go b/core/epochFlags.go new file mode 100644 index 00000000..8a43202e --- /dev/null +++ b/core/epochFlags.go @@ -0,0 +1,25 @@ +package core + +import ( + "fmt" + + "github.com/multiversx/mx-chain-core-go/core/check" +) + +// EnableEpochFlag defines a flag specific to the enableEpochs.toml +type EnableEpochFlag string + +// CheckHandlerCompatibility checks if the provided handler is compatible with this mx-chain-core-go version +func CheckHandlerCompatibility(handler EnableEpochsHandler, requiredFlags []EnableEpochFlag) error { + if check.IfNil(handler) { + return ErrNilEnableEpochsHandler + } + + for _, flag := range requiredFlags { + if !handler.IsFlagDefined(flag) { + return fmt.Errorf("%w for flag %s", ErrInvalidEnableEpochsHandler, flag) + } + } + + return nil +} diff --git a/core/epochFlags_test.go b/core/epochFlags_test.go new file mode 100644 index 00000000..6a702fc9 --- /dev/null +++ b/core/epochFlags_test.go @@ -0,0 +1,45 @@ +package core_test + +import ( + "errors" + "strings" + "testing" + + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/mock" + "github.com/stretchr/testify/require" +) + +func TestCheckHandlerCompatibility(t *testing.T) { + t.Parallel() + + err := core.CheckHandlerCompatibility(nil, []core.EnableEpochFlag{}) + require.Equal(t, core.ErrNilEnableEpochsHandler, err) + + testFlags := []core.EnableEpochFlag{"f0", "f1", "f2"} + allFlagsDefinedHandler := &mock.EnableEpochsHandlerStub{ + IsFlagDefinedCalled: func(flag core.EnableEpochFlag) bool { + return true + }, + } + err = core.CheckHandlerCompatibility(allFlagsDefinedHandler, testFlags) + require.Nil(t, err) + + allFlagsUndefinedHandler := &mock.EnableEpochsHandlerStub{ + IsFlagDefinedCalled: func(flag core.EnableEpochFlag) bool { + return false + }, + } + err = core.CheckHandlerCompatibility(allFlagsUndefinedHandler, testFlags) + require.True(t, errors.Is(err, core.ErrInvalidEnableEpochsHandler)) + + missingFlag := testFlags[1] + oneFlagUndefinedHandler := &mock.EnableEpochsHandlerStub{ + IsFlagDefinedCalled: func(flag core.EnableEpochFlag) bool { + return flag != missingFlag + }, + } + err = core.CheckHandlerCompatibility(oneFlagUndefinedHandler, testFlags) + require.True(t, errors.Is(err, core.ErrInvalidEnableEpochsHandler)) + require.True(t, strings.Contains(err.Error(), string(missingFlag))) +} diff --git a/core/errors.go b/core/errors.go index a6e64c49..5a784900 100644 --- a/core/errors.go +++ b/core/errors.go @@ -19,7 +19,7 @@ var ErrInvalidValue = errors.New("invalid value provided") // ErrNilInputData signals that a nil data has been provided var ErrNilInputData = errors.New("nil input data") -//ErrNilUrl signals that the provided url is empty +// ErrNilUrl signals that the provided url is empty var ErrNilUrl = errors.New("url is empty") // ErrPemFileIsInvalid signals that a pem file is invalid @@ -118,3 +118,6 @@ var ErrDBIsClosed = errors.New("DB is closed") // ErrNilEnableEpochsHandler signals that a nil enable epochs handler has been provided var ErrNilEnableEpochsHandler = errors.New("nil enable epochs handler") + +// ErrInvalidEnableEpochsHandler signals that an invalid enable epochs handler has been provided +var ErrInvalidEnableEpochsHandler = errors.New("invalid enable epochs handler") diff --git a/core/export_test.go b/core/export_test.go index a4589a38..98fbbf93 100644 --- a/core/export_test.go +++ b/core/export_test.go @@ -2,10 +2,42 @@ package core import "time" +// GetContainingDuration - func (sw *StopWatch) GetContainingDuration() (map[string]time.Duration, []string) { return sw.getContainingDuration() } +// GetIdentifiers - +func (sw *StopWatch) GetIdentifiers() []string { + return sw.identifiers +} + +// SetIdentifiers - +func (sw *StopWatch) SetIdentifiers(identifiers []string) { + sw.identifiers = identifiers +} + +// GetStarted - +func (sw *StopWatch) GetStarted(identifier string) (time.Time, bool) { + s, has := sw.started[identifier] + return s, has +} + +// GetElapsed - +func (sw *StopWatch) GetElapsed(identifier string) (time.Duration, bool) { + e, has := sw.elapsed[identifier] + return e, has +} + +// SetElapsed - +func (sw *StopWatch) SetElapsed(identifier string, duration time.Duration) { + sw.elapsed[identifier] = duration +} + +// SplitExponentFraction - func SplitExponentFraction(val string) (string, string) { return splitExponentFraction(val) } + +// TestAutoBalanceDataTriesFlag - +const TestAutoBalanceDataTriesFlag = autoBalanceDataTriesFlag diff --git a/core/file.go b/core/file.go index a7300a53..bb1cb977 100644 --- a/core/file.go +++ b/core/file.go @@ -5,7 +5,7 @@ import ( "encoding/json" "encoding/pem" "fmt" - "io/ioutil" + "io" "os" "path/filepath" "strings" @@ -152,7 +152,7 @@ func LoadSkPkFromPemFile(relativePath string, skIndex int) ([]byte, string, erro _ = file.Close() }() - buff, err := ioutil.ReadAll(file) + buff, err := io.ReadAll(file) if err != nil { return nil, "", fmt.Errorf("%w while reading %s file", err, relativePath) } @@ -200,7 +200,7 @@ func LoadAllKeysFromPemFile(relativePath string) ([][]byte, []string, error) { _ = file.Close() }() - buff, err := ioutil.ReadAll(file) + buff, err := io.ReadAll(file) if err != nil { return nil, nil, fmt.Errorf("%w while reading %s file", err, relativePath) } diff --git a/core/file_test.go b/core/file_test.go index edaf0ead..bd2a8406 100644 --- a/core/file_test.go +++ b/core/file_test.go @@ -3,7 +3,6 @@ package core_test import ( "encoding/json" "errors" - "io/ioutil" "os" "path/filepath" "strings" @@ -146,7 +145,7 @@ func TestLoadJSonFile_FileExitsShouldPass(t *testing.T) { data, _ := json.MarshalIndent(TestStruct{A: 0, B: 0}, "", " ") - _ = ioutil.WriteFile(fileName, data, 0644) + _ = os.WriteFile(fileName, data, 0644) err = file.Close() assert.Nil(t, err) diff --git a/core/interface.go b/core/interface.go index 8bde1c04..27888e2b 100644 --- a/core/interface.go +++ b/core/interface.go @@ -144,6 +144,9 @@ type TrieNodeVersionVerifier interface { // EnableEpochsHandler defines the behavior of a component that can return if a feature is enabled or not type EnableEpochsHandler interface { - IsAutoBalanceDataTriesEnabled() bool + IsFlagDefined(flag EnableEpochFlag) bool + IsFlagEnabled(flag EnableEpochFlag) bool + IsFlagEnabledInEpoch(flag EnableEpochFlag, epoch uint32) bool + GetActivationEpoch(flag EnableEpochFlag) uint32 IsInterfaceNil() bool } diff --git a/core/loggingFunctions_test.go b/core/loggingFunctions_test.go index 6aed20a0..30a746cd 100644 --- a/core/loggingFunctions_test.go +++ b/core/loggingFunctions_test.go @@ -1,9 +1,10 @@ -package core +package core_test import ( "fmt" "testing" + "github.com/multiversx/mx-chain-core-go/core" "github.com/multiversx/mx-chain-core-go/core/mock" "github.com/stretchr/testify/require" ) @@ -18,12 +19,12 @@ func TestDumpGoRoutinesToLogShouldNotPanic(t *testing.T) { } }() - DumpGoRoutinesToLog(0, &mock.LoggerMock{}) + core.DumpGoRoutinesToLog(0, &mock.LoggerMock{}) } func TestGetRunningGoRoutines(t *testing.T) { t.Parallel() - res := GetRunningGoRoutines(&mock.LoggerMock{}) + res := core.GetRunningGoRoutines(&mock.LoggerMock{}) require.NotNil(t, res) } diff --git a/core/mock/enableEpochsHandlerMock.go b/core/mock/enableEpochsHandlerMock.go deleted file mode 100644 index 91abd5be..00000000 --- a/core/mock/enableEpochsHandlerMock.go +++ /dev/null @@ -1,20 +0,0 @@ -package mock - -// EnableEpochsHandlerStub - -type EnableEpochsHandlerStub struct { - IsAutoBalanceDataTriesEnabledCalled func() bool -} - -// IsAutoBalanceDataTriesEnabled - -func (e *EnableEpochsHandlerStub) IsAutoBalanceDataTriesEnabled() bool { - if e.IsAutoBalanceDataTriesEnabledCalled != nil { - return e.IsAutoBalanceDataTriesEnabledCalled() - } - - return false -} - -// IsInterfaceNil returns true if there is no value under the interface -func (e *EnableEpochsHandlerStub) IsInterfaceNil() bool { - return e == nil -} diff --git a/core/mock/enableEpochsHandlerStub.go b/core/mock/enableEpochsHandlerStub.go new file mode 100644 index 00000000..fb037b37 --- /dev/null +++ b/core/mock/enableEpochsHandlerStub.go @@ -0,0 +1,48 @@ +package mock + +import "github.com/multiversx/mx-chain-core-go/core" + +// EnableEpochsHandlerStub - +type EnableEpochsHandlerStub struct { + IsFlagDefinedCalled func(flag core.EnableEpochFlag) bool + IsFlagEnabledCalled func(flag core.EnableEpochFlag) bool + IsFlagEnabledInEpochCalled func(flag core.EnableEpochFlag, epoch uint32) bool + GetActivationEpochCalled func(flag core.EnableEpochFlag) uint32 +} + +// IsFlagDefined - +func (stub *EnableEpochsHandlerStub) IsFlagDefined(flag core.EnableEpochFlag) bool { + if stub.IsFlagDefinedCalled != nil { + return stub.IsFlagDefinedCalled(flag) + } + return false +} + +// IsFlagEnabled - +func (stub *EnableEpochsHandlerStub) IsFlagEnabled(flag core.EnableEpochFlag) bool { + if stub.IsFlagEnabledCalled != nil { + return stub.IsFlagEnabledCalled(flag) + } + return false +} + +// IsFlagEnabledInEpoch - +func (stub *EnableEpochsHandlerStub) IsFlagEnabledInEpoch(flag core.EnableEpochFlag, epoch uint32) bool { + if stub.IsFlagEnabledInEpochCalled != nil { + return stub.IsFlagEnabledInEpochCalled(flag, epoch) + } + return false +} + +// GetActivationEpoch - +func (stub *EnableEpochsHandlerStub) GetActivationEpoch(flag core.EnableEpochFlag) uint32 { + if stub.GetActivationEpochCalled != nil { + return stub.GetActivationEpochCalled(flag) + } + return 0 +} + +// IsInterfaceNil - +func (stub *EnableEpochsHandlerStub) IsInterfaceNil() bool { + return stub == nil +} diff --git a/core/stopWatch_test.go b/core/stopWatch_test.go index 135def96..54bd1ad9 100644 --- a/core/stopWatch_test.go +++ b/core/stopWatch_test.go @@ -1,9 +1,10 @@ -package core +package core_test import ( "testing" "time" + "github.com/multiversx/mx-chain-core-go/core" "github.com/multiversx/mx-chain-core-go/core/mock" "github.com/stretchr/testify/assert" ) @@ -15,20 +16,20 @@ var log = &mock.LoggerMock{} func TestStopWatch_Start(t *testing.T) { t.Parallel() - sw := NewStopWatch() + sw := core.NewStopWatch() sw.Start(identifier) - _, has := sw.started[identifier] + _, has := sw.GetStarted(identifier) assert.True(t, has) - assert.Equal(t, identifier, sw.identifiers[0]) + assert.Equal(t, identifier, sw.GetIdentifiers()[0]) } func TestStopWatch_DoubleStartShouldNotReAddInIdentifiers(t *testing.T) { t.Parallel() - sw := NewStopWatch() + sw := core.NewStopWatch() identifier1 := "identifier1" identifier2 := "identifier2" @@ -36,19 +37,19 @@ func TestStopWatch_DoubleStartShouldNotReAddInIdentifiers(t *testing.T) { sw.Start(identifier2) sw.Start(identifier1) - assert.Equal(t, identifier1, sw.identifiers[0]) - assert.Equal(t, identifier2, sw.identifiers[1]) - assert.Equal(t, 2, len(sw.identifiers)) + assert.Equal(t, identifier1, sw.GetIdentifiers()[0]) + assert.Equal(t, identifier2, sw.GetIdentifiers()[1]) + assert.Equal(t, 2, len(sw.GetIdentifiers())) } func TestStopWatch_StopNoStartShouldNotAddDuration(t *testing.T) { t.Parallel() - sw := NewStopWatch() + sw := core.NewStopWatch() sw.Stop(identifier) - _, has := sw.elapsed[identifier] + _, has := sw.GetElapsed(identifier) assert.False(t, has) } @@ -56,12 +57,12 @@ func TestStopWatch_StopNoStartShouldNotAddDuration(t *testing.T) { func TestStopWatch_StopWithStartShouldAddDuration(t *testing.T) { t.Parallel() - sw := NewStopWatch() + sw := core.NewStopWatch() sw.Start(identifier) sw.Stop(identifier) - _, has := sw.elapsed[identifier] + _, has := sw.GetElapsed(identifier) assert.True(t, has) } @@ -69,7 +70,7 @@ func TestStopWatch_StopWithStartShouldAddDuration(t *testing.T) { func TestStopWatch_GetMeasurementsNotFinishedShouldOmit(t *testing.T) { t.Parallel() - sw := NewStopWatch() + sw := core.NewStopWatch() sw.Start(identifier) @@ -82,7 +83,7 @@ func TestStopWatch_GetMeasurementsNotFinishedShouldOmit(t *testing.T) { func TestStopWatch_GetMeasurementsShouldWork(t *testing.T) { t.Parallel() - sw := NewStopWatch() + sw := core.NewStopWatch() sw.Start(identifier) sw.Stop(identifier) @@ -102,12 +103,12 @@ func TestStopWatch_AddShouldWork(t *testing.T) { identifier2 := "identifier2" duration2 := time.Duration(7) - swSrc := NewStopWatch() - swSrc.identifiers = []string{identifier1, identifier2} - swSrc.elapsed[identifier1] = duration1 - swSrc.elapsed[identifier2] = duration2 + swSrc := core.NewStopWatch() + swSrc.SetIdentifiers([]string{identifier1, identifier2}) + swSrc.SetElapsed(identifier1, duration1) + swSrc.SetElapsed(identifier2, duration2) - sw := NewStopWatch() + sw := core.NewStopWatch() sw.Add(swSrc) @@ -126,9 +127,9 @@ func TestStopWatch_GetMeasurement(t *testing.T) { t.Parallel() fooDuration := time.Duration(4243) * time.Millisecond - sw := NewStopWatch() - sw.identifiers = []string{"foo"} - sw.elapsed["foo"] = fooDuration + sw := core.NewStopWatch() + sw.SetIdentifiers([]string{"foo"}) + sw.SetElapsed("foo", fooDuration) assert.Equal(t, fooDuration, sw.GetMeasurement("foo")) assert.Equal(t, time.Duration(0), sw.GetMeasurement("bar")) diff --git a/core/trie.go b/core/trie.go index de462376..84331e5c 100644 --- a/core/trie.go +++ b/core/trie.go @@ -23,6 +23,8 @@ const ( // AutoBalanceEnabledString is the string representation of AutoBalanceEnabled trie node version AutoBalanceEnabledString = "auto balanced" + + autoBalanceDataTriesFlag = EnableEpochFlag("AutoBalanceDataTriesFlag") ) func (version TrieNodeVersion) String() string { @@ -40,10 +42,15 @@ type trieNodeVersionVerifier struct { enableEpochsHandler EnableEpochsHandler } +// NewTrieNodeVersionVerifier returns a new instance of trieNodeVersionVerifier func NewTrieNodeVersionVerifier(enableEpochsHandler EnableEpochsHandler) (*trieNodeVersionVerifier, error) { if check.IfNil(enableEpochsHandler) { return nil, ErrNilEnableEpochsHandler } + err := CheckHandlerCompatibility(enableEpochsHandler, []EnableEpochFlag{autoBalanceDataTriesFlag}) + if err != nil { + return nil, err + } return &trieNodeVersionVerifier{ enableEpochsHandler: enableEpochsHandler, @@ -52,7 +59,7 @@ func NewTrieNodeVersionVerifier(enableEpochsHandler EnableEpochsHandler) (*trieN // IsValidVersion returns true if the given trie node version is valid func (vv *trieNodeVersionVerifier) IsValidVersion(version TrieNodeVersion) bool { - if vv.enableEpochsHandler.IsAutoBalanceDataTriesEnabled() { + if vv.enableEpochsHandler.IsFlagEnabled(autoBalanceDataTriesFlag) { return version <= AutoBalanceEnabled } @@ -66,7 +73,7 @@ func (vv *trieNodeVersionVerifier) IsInterfaceNil() bool { // GetVersionForNewData returns the trie node version that should be used for new data func GetVersionForNewData(handler EnableEpochsHandler) TrieNodeVersion { - if handler.IsAutoBalanceDataTriesEnabled() { + if handler.IsFlagEnabled(autoBalanceDataTriesFlag) { return AutoBalanceEnabled } diff --git a/core/trie_test.go b/core/trie_test.go index d5332723..49deec9f 100644 --- a/core/trie_test.go +++ b/core/trie_test.go @@ -1,8 +1,11 @@ -package core +package core_test import ( + "errors" + "strings" "testing" + "github.com/multiversx/mx-chain-core-go/core" "github.com/multiversx/mx-chain-core-go/core/check" "github.com/multiversx/mx-chain-core-go/core/mock" "github.com/stretchr/testify/assert" @@ -14,14 +17,31 @@ func TestNewTrieNodeVersionVerifier(t *testing.T) { t.Run("nil enableEpochsHandler", func(t *testing.T) { t.Parallel() - vv, err := NewTrieNodeVersionVerifier(nil) + vv, err := core.NewTrieNodeVersionVerifier(nil) assert.Nil(t, vv) - assert.Equal(t, ErrNilEnableEpochsHandler, err) + assert.Equal(t, core.ErrNilEnableEpochsHandler, err) + }) + t.Run("incompatible enableEpochsHandler", func(t *testing.T) { + t.Parallel() + + vv, err := core.NewTrieNodeVersionVerifier(&mock.EnableEpochsHandlerStub{ + IsFlagDefinedCalled: func(flag core.EnableEpochFlag) bool { + assert.Equal(t, core.TestAutoBalanceDataTriesFlag, flag) + return false + }, + }) + assert.Nil(t, vv) + assert.True(t, errors.Is(err, core.ErrInvalidEnableEpochsHandler)) + assert.True(t, strings.Contains(err.Error(), string(core.TestAutoBalanceDataTriesFlag))) }) t.Run("new trieNodeVersionVerifier", func(t *testing.T) { t.Parallel() - vv, err := NewTrieNodeVersionVerifier(&mock.EnableEpochsHandlerStub{}) + vv, err := core.NewTrieNodeVersionVerifier(&mock.EnableEpochsHandlerStub{ + IsFlagDefinedCalled: func(flag core.EnableEpochFlag) bool { + return flag == core.TestAutoBalanceDataTriesFlag + }, + }) assert.Nil(t, err) assert.False(t, check.IfNil(vv)) }) @@ -33,40 +53,46 @@ func TestTrieNodeVersionVerifier_IsValidVersion(t *testing.T) { t.Run("auto balance enabled", func(t *testing.T) { t.Parallel() - vv, _ := NewTrieNodeVersionVerifier( + vv, _ := core.NewTrieNodeVersionVerifier( &mock.EnableEpochsHandlerStub{ - IsAutoBalanceDataTriesEnabledCalled: func() bool { - return true + IsFlagDefinedCalled: func(flag core.EnableEpochFlag) bool { + return flag == core.TestAutoBalanceDataTriesFlag + }, + IsFlagEnabledCalled: func(flag core.EnableEpochFlag) bool { + return flag == core.TestAutoBalanceDataTriesFlag }, }, ) - assert.True(t, vv.IsValidVersion(NotSpecified)) - assert.True(t, vv.IsValidVersion(AutoBalanceEnabled)) - assert.False(t, vv.IsValidVersion(AutoBalanceEnabled+1)) + assert.True(t, vv.IsValidVersion(core.NotSpecified)) + assert.True(t, vv.IsValidVersion(core.AutoBalanceEnabled)) + assert.False(t, vv.IsValidVersion(core.AutoBalanceEnabled+1)) }) t.Run("auto balance disabled", func(t *testing.T) { t.Parallel() - vv, _ := NewTrieNodeVersionVerifier( + vv, _ := core.NewTrieNodeVersionVerifier( &mock.EnableEpochsHandlerStub{ - IsAutoBalanceDataTriesEnabledCalled: func() bool { + IsFlagDefinedCalled: func(flag core.EnableEpochFlag) bool { + return flag == core.TestAutoBalanceDataTriesFlag + }, + IsFlagEnabledCalled: func(flag core.EnableEpochFlag) bool { return false }, }, ) - assert.True(t, vv.IsValidVersion(NotSpecified)) - assert.False(t, vv.IsValidVersion(AutoBalanceEnabled)) - assert.False(t, vv.IsValidVersion(AutoBalanceEnabled+1)) + assert.True(t, vv.IsValidVersion(core.NotSpecified)) + assert.False(t, vv.IsValidVersion(core.AutoBalanceEnabled)) + assert.False(t, vv.IsValidVersion(core.AutoBalanceEnabled+1)) }) } func TestTrieNodeVersion_String(t *testing.T) { t.Parallel() - assert.Equal(t, NotSpecifiedString, NotSpecified.String()) - assert.Equal(t, AutoBalanceEnabledString, AutoBalanceEnabled.String()) - assert.Equal(t, "unknown: 100", TrieNodeVersion(100).String()) + assert.Equal(t, core.NotSpecifiedString, core.NotSpecified.String()) + assert.Equal(t, core.AutoBalanceEnabledString, core.AutoBalanceEnabled.String()) + assert.Equal(t, "unknown: 100", core.TrieNodeVersion(100).String()) } func TestGetVersionForNewData(t *testing.T) { @@ -75,26 +101,32 @@ func TestGetVersionForNewData(t *testing.T) { t.Run("auto balance enabled", func(t *testing.T) { t.Parallel() - getVersionForNewData := GetVersionForNewData( + getVersionForNewData := core.GetVersionForNewData( &mock.EnableEpochsHandlerStub{ - IsAutoBalanceDataTriesEnabledCalled: func() bool { - return true + IsFlagDefinedCalled: func(flag core.EnableEpochFlag) bool { + return flag == core.TestAutoBalanceDataTriesFlag + }, + IsFlagEnabledCalled: func(flag core.EnableEpochFlag) bool { + return flag == core.TestAutoBalanceDataTriesFlag }, }, ) - assert.Equal(t, AutoBalanceEnabled, getVersionForNewData) + assert.Equal(t, core.AutoBalanceEnabled, getVersionForNewData) }) t.Run("auto balance disabled", func(t *testing.T) { t.Parallel() - getVersionForNewData := GetVersionForNewData( + getVersionForNewData := core.GetVersionForNewData( &mock.EnableEpochsHandlerStub{ - IsAutoBalanceDataTriesEnabledCalled: func() bool { + IsFlagDefinedCalled: func(flag core.EnableEpochFlag) bool { + return flag == core.TestAutoBalanceDataTriesFlag + }, + IsFlagEnabledCalled: func(flag core.EnableEpochFlag) bool { return false }, }, ) - assert.Equal(t, NotSpecified, getVersionForNewData) + assert.Equal(t, core.NotSpecified, getVersionForNewData) }) } diff --git a/data/outport/common_test.go b/data/outport/common_test.go index 434a64e1..0fe18b65 100644 --- a/data/outport/common_test.go +++ b/data/outport/common_test.go @@ -55,8 +55,7 @@ func TestGetBody(t *testing.T) { require.Nil(t, receivedBody) require.Equal(t, errNilBodyHandler, err) - var body data.BodyHandler - body = &block.Body{} + body := &block.Body{} receivedBody, err = GetBody(body) require.Nil(t, err) require.Equal(t, body, receivedBody) diff --git a/data/transaction/transaction_test.go b/data/transaction/transaction_test.go index 02306653..93151a32 100644 --- a/data/transaction/transaction_test.go +++ b/data/transaction/transaction_test.go @@ -351,8 +351,7 @@ func TestTransaction_CheckIntegrityShouldErr(t *testing.T) { func TestTransaction_ImplementsGuardedTransactionHandler(t *testing.T) { t.Parallel() - var tx data.TransactionHandler - tx = &transaction.Transaction{} + var tx data.TransactionHandler = &transaction.Transaction{} _, ok := tx.(data.GuardedTransactionHandler) assert.True(t, ok)