Skip to content

Commit 5e1b4a5

Browse files
authored
fix: use errors or string concat to avoid fmt (#919)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent dc1c861 commit 5e1b4a5

File tree

7 files changed

+18
-17
lines changed

7 files changed

+18
-17
lines changed

ledger/allegra/rules_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package allegra_test
1717
import (
1818
"crypto/rand"
1919
"encoding/hex"
20-
"fmt"
20+
"errors"
2121
"testing"
2222

2323
"github.com/blinklabs-io/gouroboros/ledger/allegra"
@@ -48,7 +48,7 @@ func (ls testLedgerState) UtxoById(
4848
}
4949
return tmpUtxo, nil
5050
}
51-
return common.Utxo{}, fmt.Errorf("not found")
51+
return common.Utxo{}, errors.New("not found")
5252
}
5353

5454
func TestUtxoValidateOutsideValidityIntervalUtxo(t *testing.T) {

ledger/mary/rules_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package mary_test
1717
import (
1818
"crypto/rand"
1919
"encoding/hex"
20-
"fmt"
20+
"errors"
2121
"testing"
2222

2323
"github.com/blinklabs-io/gouroboros/cbor"
@@ -50,7 +50,7 @@ func (ls testLedgerState) UtxoById(
5050
}
5151
return tmpUtxo, nil
5252
}
53-
return common.Utxo{}, fmt.Errorf("not found")
53+
return common.Utxo{}, errors.New("not found")
5454
}
5555

5656
func TestUtxoValidateOutsideValidityIntervalUtxo(t *testing.T) {

ledger/shelley/rules_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package shelley_test
1717
import (
1818
"crypto/rand"
1919
"encoding/hex"
20-
"fmt"
20+
"errors"
2121
"testing"
2222

2323
"github.com/blinklabs-io/gouroboros/ledger/common"
@@ -47,7 +47,7 @@ func (ls testLedgerState) UtxoById(
4747
}
4848
return tmpUtxo, nil
4949
}
50-
return common.Utxo{}, fmt.Errorf("not found")
50+
return common.Utxo{}, errors.New("not found")
5151
}
5252

5353
func TestUtxoValidateTimeToLive(t *testing.T) {

protocol/handshake/client_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ func TestClientNtNAcceptV11(t *testing.T) {
248248

249249
func TestClientNtCRefuseVersionMismatch(t *testing.T) {
250250
defer goleak.VerifyNone(t)
251-
expectedErr := fmt.Sprintf("%s: version mismatch", handshake.ProtocolName)
251+
expectedErr := handshake.ProtocolName + ": version mismatch"
252252
mockConn := ouroboros_mock.NewConnection(
253253
ouroboros_mock.ProtocolRoleClient,
254254
[]ouroboros_mock.ConversationEntry{
@@ -282,7 +282,7 @@ func TestClientNtCRefuseVersionMismatch(t *testing.T) {
282282

283283
func TestClientNtCRefuseDecodeError(t *testing.T) {
284284
defer goleak.VerifyNone(t)
285-
expectedErr := fmt.Sprintf("%s: decode error: foo", handshake.ProtocolName)
285+
expectedErr := handshake.ProtocolName + ": decode error: foo"
286286
mockConn := ouroboros_mock.NewConnection(
287287
ouroboros_mock.ProtocolRoleClient,
288288
[]ouroboros_mock.ConversationEntry{
@@ -317,7 +317,7 @@ func TestClientNtCRefuseDecodeError(t *testing.T) {
317317

318318
func TestClientNtCRefuseRefused(t *testing.T) {
319319
defer goleak.VerifyNone(t)
320-
expectedErr := fmt.Sprintf("%s: refused: foo", handshake.ProtocolName)
320+
expectedErr := handshake.ProtocolName + ": refused: foo"
321321
mockConn := ouroboros_mock.NewConnection(
322322
ouroboros_mock.ProtocolRoleClient,
323323
[]ouroboros_mock.ConversationEntry{

protocol/handshake/server_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 Blink Labs Software
1+
// Copyright 2025 Blink Labs Software
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
1515
package handshake_test
1616

1717
import (
18+
"errors"
1819
"fmt"
1920
"testing"
2021
"time"
@@ -97,9 +98,7 @@ func TestServerHandshakeRefuseVersionMismatch(t *testing.T) {
9798
defer func() {
9899
goleak.VerifyNone(t)
99100
}()
100-
expectedErr := fmt.Errorf(
101-
"handshake failed: refused due to version mismatch",
102-
)
101+
expectedErr := errors.New("handshake failed: refused due to version mismatch")
103102
mockConn := ouroboros_mock.NewConnection(
104103
ouroboros_mock.ProtocolRoleServer,
105104
[]ouroboros_mock.ConversationEntry{

protocol/keepalive/client_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 Blink Labs Software
1+
// Copyright 2025 Blink Labs Software
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
1515
package keepalive_test
1616

1717
import (
18+
"errors"
1819
"fmt"
1920
"testing"
2021
"time"
@@ -142,7 +143,7 @@ func TestServerKeepaliveHandlingWithWrongResponse(t *testing.T) {
142143
go func() {
143144
err := <-mockConn.ErrorChan()
144145
if err == nil {
145-
asyncErrChan <- fmt.Errorf("did not receive expected error")
146+
asyncErrChan <- errors.New("did not receive expected error")
146147
} else {
147148
if err.Error() != expectedErr {
148149
asyncErrChan <- fmt.Errorf("did not receive expected error\n got: %s\n wanted: %s", err, expectedErr)

protocol/localtxsubmission/client_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 Blink Labs Software
1+
// Copyright 2025 Blink Labs Software
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
1515
package localtxsubmission_test
1616

1717
import (
18+
"errors"
1819
"fmt"
1920
"testing"
2021
"time"
@@ -129,7 +130,7 @@ func TestSubmitTxRject(t *testing.T) {
129130
expectedErr := localtxsubmission.TransactionRejectedError{
130131
// [0, [1, ["foo"]]]
131132
ReasonCbor: test.DecodeHexString("820082018163666f6f"),
132-
Reason: fmt.Errorf("GenericError ([0 [1 [foo]]])"),
133+
Reason: errors.New("GenericError ([0 [1 [foo]]])"),
133134
}
134135
conversation := append(
135136
conversationHandshakeSubmitTx,

0 commit comments

Comments
 (0)