Skip to content

Commit

Permalink
Code review rework
Browse files Browse the repository at this point in the history
  • Loading branch information
bruce-riley committed Jan 21, 2025
1 parent a5c0da0 commit 46fde63
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion node/pkg/accountant/accountant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func newAccountantForTest(
return acct
}

// Converts a string into a go-ethereum Hash object used as test input.
// Converts a TxHash string into a byte array to be used as a TxID.
func hashToTxID(str string) []byte {
if (len(str) > 2) && (str[0] == '0') && (str[1] == 'x') {
str = str[2:]
Expand Down
7 changes: 4 additions & 3 deletions node/pkg/common/chainlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/binary"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"math"
"time"
Expand Down Expand Up @@ -52,7 +53,7 @@ func (msg *MessagePublication) Marshal() ([]byte, error) {
buf := new(bytes.Buffer)

if len(msg.TxID) > math.MaxUint8 {
return nil, fmt.Errorf("TxID too long")
return nil, errors.New("TxID too long")
}
vaa.MustWrite(buf, binary.BigEndian, uint8(len(msg.TxID)))
buf.Write(msg.TxID)
Expand All @@ -73,7 +74,7 @@ func (msg *MessagePublication) Marshal() ([]byte, error) {
// This function can be deleted once all guardians have been upgraded. That's why the code is just duplicated.
func UnmarshalOldMessagePublicationWithTxHash(data []byte) (*MessagePublication, error) {
if len(data) < minMsgLength {
return nil, fmt.Errorf("message is too short")
return nil, errors.New("message is too short")
}

msg := &MessagePublication{}
Expand Down Expand Up @@ -131,7 +132,7 @@ func UnmarshalOldMessagePublicationWithTxHash(data []byte) (*MessagePublication,
// UnmarshalMessagePublication deserializes a MessagePublication
func UnmarshalMessagePublication(data []byte) (*MessagePublication, error) {
if len(data) < minMsgLength {
return nil, fmt.Errorf("message is too short")
return nil, errors.New("message is too short")
}

msg := &MessagePublication{}
Expand Down
2 changes: 1 addition & 1 deletion node/pkg/governor/governor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ func newChainGovernorForTestWithLogger(ctx context.Context, logger *zap.Logger)
return gov, nil
}

// Converts a string into a go-ethereum Hash object used as test input.
// Converts a TxHash string into a byte array to be used as a TxID.
func hashToTxID(str string) []byte {
if (len(str) > 2) && (str[0] == '0') && (str[1] == 'x') {
str = str[2:]
Expand Down

0 comments on commit 46fde63

Please sign in to comment.