Skip to content

Commit

Permalink
fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
axenteoctavian committed Nov 22, 2024
1 parent 51d7b9c commit fa31f97
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion process/factory/sovereignTxNotarizationChecker.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func NewSovereignTxNotarizationChecker() *sovereignTxNotarizationChecker {
return &sovereignTxNotarizationChecker{}
}

// IsNotarized returns if tx is notarized
// IsNotarized returns true
func (stnc *sovereignTxNotarizationChecker) IsNotarized(_ transaction.ApiTransactionResult) bool {
return true
}
Expand Down
21 changes: 14 additions & 7 deletions process/factory/txNotarizationChecker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@ func TestTxNotarizationChecker(t *testing.T) {
func TestTxNotarizationChecker_IsNotarized(t *testing.T) {
t.Parallel()

tnc := NewTxNotarizationChecker()
tx := transaction.ApiTransactionResult{
NotarizedAtSourceInMetaNonce: 1,
NotarizedAtDestinationInMetaNonce: 1,
}
isNotarized := tnc.IsNotarized(tx)
require.True(t, isNotarized)
t.Run("tx is notarized, should work", func(t *testing.T) {
tnc := NewTxNotarizationChecker()
tx := transaction.ApiTransactionResult{
NotarizedAtSourceInMetaNonce: 1,
NotarizedAtDestinationInMetaNonce: 1,
}
isNotarized := tnc.IsNotarized(tx)
require.True(t, isNotarized)
})
t.Run("tx is not notarized, should work", func(t *testing.T) {
tnc := NewTxNotarizationChecker()
isNotarized := tnc.IsNotarized(transaction.ApiTransactionResult{})
require.False(t, isNotarized)
})
}
3 changes: 2 additions & 1 deletion process/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/multiversx/mx-chain-core-go/data/transaction"
"github.com/multiversx/mx-chain-core-go/data/vm"
crypto "github.com/multiversx/mx-chain-crypto-go"

"github.com/multiversx/mx-chain-proxy-go/common"
"github.com/multiversx/mx-chain-proxy-go/data"
"github.com/multiversx/mx-chain-proxy-go/observer"
Expand Down Expand Up @@ -86,7 +87,7 @@ type HttpClient interface {
Do(req *http.Request) (*http.Response, error)
}

// TxNotarizationCheckerHandler defines a TxNotarizationCheckerHandler behavior
// TxNotarizationCheckerHandler defines what tx notarization checked should do
type TxNotarizationCheckerHandler interface {
IsNotarized(tx transaction.ApiTransactionResult) bool
IsInterfaceNil() bool
Expand Down
3 changes: 1 addition & 2 deletions process/transactionProcessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,7 @@ func checkIfCompleted(logs []*transaction.ApiLogs) bool {
}

func (tp *TransactionProcessor) checkIfMoveBalanceNotarized(tx *transaction.ApiTransactionResult) bool {
isNotarized := tp.txNotarizationChecker.IsNotarized(*tx)
if !isNotarized {
if !tp.txNotarizationChecker.IsNotarized(*tx) {
return false
}
isMoveBalance := tx.ProcessingTypeOnSource == moveBalanceDescriptor && tx.ProcessingTypeOnDestination == moveBalanceDescriptor
Expand Down

0 comments on commit fa31f97

Please sign in to comment.