Skip to content

Commit

Permalink
fixes after review: nil checks and errors updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ssd04 committed Jul 28, 2022
1 parent a2f8e2c commit bb6e447
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions consensus/spos/bls/subroundSignature.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (sr *subroundSignature) doSignatureJob(_ context.Context) bool {
if !sr.CanDoSubroundJob(sr.Current()) {
return false
}
if sr.Header == nil {
if check.IfNil(sr.Header) {
log.Error("doSignatureJob", "error", spos.ErrNilHeader)
return false
}
Expand Down Expand Up @@ -172,7 +172,7 @@ func (sr *subroundSignature) receivedSignature(_ context.Context, cnsDta *consen
return false
}

if sr.Header == nil {
if check.IfNil(sr.Header) {
log.Error("receivedSignature", "error", spos.ErrNilHeader)
return false
}
Expand Down
3 changes: 3 additions & 0 deletions errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,9 @@ var ErrSignerNotSupported = errors.New("signer not supported")
// ErrMissingMultiSignerConfig signals that the multisigner config is missing
var ErrMissingMultiSignerConfig = errors.New("multisigner configuration missing")

// ErrMissingEpochZeroMultiSignerConfig signals that the multisigner config for epoch zero is missing
var ErrMissingEpochZeroMultiSignerConfig = errors.New("multisigner configuration missing for epoch zero")

// ErrNilMultiSignerContainer signals that the multisigner container is nil
var ErrNilMultiSignerContainer = errors.New("multisigner container is nil")

Expand Down
4 changes: 2 additions & 2 deletions factory/crypto/cryptoComponentsHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"sync"

"github.com/ElrondNetwork/elrond-go-core/core/check"
"github.com/ElrondNetwork/elrond-go-crypto"
crypto "github.com/ElrondNetwork/elrond-go-crypto"
cryptoCommon "github.com/ElrondNetwork/elrond-go/common/crypto"
"github.com/ElrondNetwork/elrond-go/errors"
"github.com/ElrondNetwork/elrond-go/factory"
Expand Down Expand Up @@ -202,7 +202,7 @@ func (mcc *managedCryptoComponents) MultiSignerContainer() cryptoCommon.MultiSig
return nil
}

return mcc.multiSignerContainer
return mcc.cryptoComponents.multiSignerContainer
}

// SetMultiSignerContainer sets the multiSigner container in the crypto components
Expand Down
2 changes: 1 addition & 1 deletion factory/crypto/multiSignerContainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func NewMultiSignerContainer(args MultiSigArgs, multiSignerConfig []config.Multi

sortedMultiSignerConfig := sortMultiSignerConfig(multiSignerConfig)
if sortedMultiSignerConfig[0].EnableEpoch != 0 {
return nil, errors.ErrNilMultiSigner
return nil, errors.ErrMissingEpochZeroMultiSignerConfig
}

for i, mConfig := range sortedMultiSignerConfig {
Expand Down
2 changes: 1 addition & 1 deletion factory/crypto/multiSignerContainer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func Test_NewMultiSignerContainer(t *testing.T) {
multiSigContainer, err := NewMultiSignerContainer(args, multiSigConfigClone)

require.Nil(t, multiSigContainer)
require.Equal(t, errors.ErrNilMultiSigner, err)
require.Equal(t, errors.ErrMissingEpochZeroMultiSignerConfig, err)
})
t.Run("invalid multiSigner type should err", func(t *testing.T) {
multiSigConfigClone := append([]config.MultiSignerConfig{}, multiSigConfig...)
Expand Down

0 comments on commit bb6e447

Please sign in to comment.