cmd: use errrors.New instead of empty fmt.Errorf (#27329)

Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
Delweng
2023-05-24 12:21:29 +02:00
committed by GitHub
parent 9231770811
commit e9c3183c52
20 changed files with 50 additions and 38 deletions
+2 -1
View File
@@ -19,6 +19,7 @@ package ethtest
import (
"compress/gzip"
"encoding/json"
"errors"
"fmt"
"io"
"math/big"
@@ -98,7 +99,7 @@ func (c *Chain) Head() *types.Block {
func (c *Chain) GetHeaders(req *GetBlockHeaders) ([]*types.Header, error) {
if req.Amount < 1 {
return nil, fmt.Errorf("no block headers requested")
return nil, errors.New("no block headers requested")
}
headers := make([]*types.Header, req.Amount)
+2 -1
View File
@@ -17,6 +17,7 @@
package ethtest
import (
"errors"
"fmt"
"net"
"reflect"
@@ -185,7 +186,7 @@ loop:
}
// make sure eth protocol version is set for negotiation
if c.negotiatedProtoVersion == 0 {
return nil, fmt.Errorf("eth protocol version must be set in Conn")
return nil, errors.New("eth protocol version must be set in Conn")
}
if status == nil {
// default status message
+4 -3
View File
@@ -17,6 +17,7 @@
package ethtest
import (
"errors"
"fmt"
"math/big"
"strings"
@@ -39,7 +40,7 @@ func (s *Suite) sendSuccessfulTxs(t *utesting.T) error {
}
for i, tx := range tests {
if tx == nil {
return fmt.Errorf("could not find tx to send")
return errors.New("could not find tx to send")
}
t.Logf("Testing tx propagation %d: sending tx %v %v %v\n", i, tx.Hash().String(), tx.GasPrice(), tx.Gas())
// get previous tx if exists for reference in case of old tx propagation
@@ -348,7 +349,7 @@ func generateTxs(s *Suite, numTxs int) (map[common.Hash]common.Hash, []*types.Tr
nextTx := getNextTxFromChain(s)
if nextTx == nil {
return nil, nil, fmt.Errorf("failed to get the next transaction")
return nil, nil, errors.New("failed to get the next transaction")
}
gas := nextTx.Gas()
@@ -357,7 +358,7 @@ func generateTxs(s *Suite, numTxs int) (map[common.Hash]common.Hash, []*types.Tr
for i := 0; i < numTxs; i++ {
tx := generateTx(s.chain.chainConfig, nonce, gas)
if tx == nil {
return nil, nil, fmt.Errorf("failed to get the next transaction")
return nil, nil, errors.New("failed to get the next transaction")
}
txHashMap[tx.Hash()] = tx.Hash()
txs[i] = tx
+2 -1
View File
@@ -18,6 +18,7 @@ package ethtest
import (
"crypto/ecdsa"
"errors"
"fmt"
"time"
@@ -286,5 +287,5 @@ func (c *Conn) ReadSnap(id uint64) (Message, error) {
}
return snpMsg.(Message), nil
}
return nil, fmt.Errorf("request timed out")
return nil, errors.New("request timed out")
}
+2 -1
View File
@@ -19,6 +19,7 @@ package v4test
import (
"bytes"
"crypto/rand"
"errors"
"fmt"
"net"
"time"
@@ -119,7 +120,7 @@ func (te *testenv) checkPingPong(pingHash []byte) error {
// and a PING. The two packets do not have to be in any particular order.
func (te *testenv) checkPong(reply v4wire.Packet, pingHash []byte) error {
if reply == nil {
return fmt.Errorf("expected PONG reply, got nil")
return errors.New("expected PONG reply, got nil")
}
if reply.Kind() != v4wire.PongPacket {
return fmt.Errorf("expected PONG reply, got %v %v", reply.Name(), reply)