Skip to content

Commit ecd382e

Browse files
committed
fmt.Errorf -> errors.New
1 parent d05eb93 commit ecd382e

File tree

8 files changed

+31
-30
lines changed

8 files changed

+31
-30
lines changed

modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package controller_test
22

33
import (
4-
"fmt"
4+
"errors"
55
"strconv"
66
"testing"
77

@@ -146,9 +146,9 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenInit() {
146146
portID, channelID string,
147147
counterparty channeltypes.Counterparty, version string,
148148
) (string, error) {
149-
return "", fmt.Errorf("mock ica auth fails")
149+
return "", errors.New("mock ica auth fails")
150150
}
151-
}, fmt.Errorf("mock ica auth fails"),
151+
}, errors.New("mock ica auth fails"),
152152
},
153153
{
154154
"nil underlying app", func() {
@@ -163,7 +163,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenInit() {
163163
portID, channelID string,
164164
counterparty channeltypes.Counterparty, version string,
165165
) (string, error) {
166-
return "", fmt.Errorf("error should be unreachable")
166+
return "", errors.New("error should be unreachable")
167167
}
168168
}, nil,
169169
},
@@ -302,9 +302,9 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenAck() {
302302
suite.chainA.GetSimApp().ICAAuthModule.IBCApp.OnChanOpenAck = func(
303303
ctx sdk.Context, portID, channelID string, counterpartyChannelID string, counterpartyVersion string,
304304
) error {
305-
return fmt.Errorf("mock ica auth fails")
305+
return errors.New("mock ica auth fails")
306306
}
307-
}, fmt.Errorf("mock ica auth fails"),
307+
}, errors.New("mock ica auth fails"),
308308
},
309309
{
310310
"nil underlying app", func() {
@@ -318,7 +318,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenAck() {
318318
suite.chainA.GetSimApp().ICAAuthModule.IBCApp.OnChanOpenAck = func(
319319
ctx sdk.Context, portID, channelID string, counterpartyChannelID string, counterpartyVersion string,
320320
) error {
321-
return fmt.Errorf("error should be unreachable")
321+
return errors.New("error should be unreachable")
322322
}
323323
}, nil,
324324
},
@@ -576,9 +576,9 @@ func (suite *InterchainAccountsTestSuite) TestOnAcknowledgementPacket() {
576576
suite.chainA.GetSimApp().ICAAuthModule.IBCApp.OnAcknowledgementPacket = func(
577577
ctx sdk.Context, channelVersion string, packet channeltypes.Packet, acknowledgement []byte, relayer sdk.AccAddress,
578578
) error {
579-
return fmt.Errorf("mock ica auth fails")
579+
return errors.New("mock ica auth fails")
580580
}
581-
}, fmt.Errorf("mock ica auth fails"),
581+
}, errors.New("mock ica auth fails"),
582582
},
583583
{
584584
"nil underlying app", func() {
@@ -592,7 +592,7 @@ func (suite *InterchainAccountsTestSuite) TestOnAcknowledgementPacket() {
592592
suite.chainA.GetSimApp().ICAAuthModule.IBCApp.OnAcknowledgementPacket = func(
593593
ctx sdk.Context, channelVersion string, packet channeltypes.Packet, acknowledgement []byte, relayer sdk.AccAddress,
594594
) error {
595-
return fmt.Errorf("error should be unreachable")
595+
return errors.New("error should be unreachable")
596596
}
597597
}, nil,
598598
},
@@ -670,9 +670,9 @@ func (suite *InterchainAccountsTestSuite) TestOnTimeoutPacket() {
670670
suite.chainA.GetSimApp().ICAAuthModule.IBCApp.OnTimeoutPacket = func(
671671
ctx sdk.Context, channelVersion string, packet channeltypes.Packet, relayer sdk.AccAddress,
672672
) error {
673-
return fmt.Errorf("mock ica auth fails")
673+
return errors.New("mock ica auth fails")
674674
}
675-
}, fmt.Errorf("mock ica auth fails"),
675+
}, errors.New("mock ica auth fails"),
676676
},
677677
{
678678
"nil underlying app", func() {
@@ -686,7 +686,7 @@ func (suite *InterchainAccountsTestSuite) TestOnTimeoutPacket() {
686686
suite.chainA.GetSimApp().ICAAuthModule.IBCApp.OnTimeoutPacket = func(
687687
ctx sdk.Context, channelVersion string, packet channeltypes.Packet, relayer sdk.AccAddress,
688688
) error {
689-
return fmt.Errorf("error should be unreachable")
689+
return errors.New("error should be unreachable")
690690
}
691691
}, nil,
692692
},

modules/apps/callbacks/v2/ibc_middleware_test.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package v2_test
22

33
import (
4+
"errors"
45
"fmt"
6+
"reflect"
57
"time"
68

79
errorsmod "cosmossdk.io/errors"
@@ -41,35 +43,35 @@ func (s *CallbacksTestSuite) TestNewIBCMiddleware() {
4143
func() {
4244
_ = v2.NewIBCMiddleware(ibcmockv2.IBCModule{}, nil, simapp.ContractKeeper{}, &channelkeeperv2.Keeper{}, maxCallbackGas)
4345
},
44-
fmt.Errorf("write acknowledgement wrapper cannot be nil"),
46+
errors.New("write acknowledgement wrapper cannot be nil"),
4547
},
4648
{
4749
"panics with nil underlying app",
4850
func() {
4951
_ = v2.NewIBCMiddleware(nil, &channelkeeperv2.Keeper{}, simapp.ContractKeeper{}, &channelkeeperv2.Keeper{}, maxCallbackGas)
5052
},
51-
fmt.Errorf("underlying application does not implement %T", (*types.CallbacksCompatibleModule)(nil)),
53+
errors.New("underlying application does not implement " + reflect.TypeOf((*types.CallbacksCompatibleModule)(nil)).String()),
5254
},
5355
{
5456
"panics with nil contract keeper",
5557
func() {
5658
_ = v2.NewIBCMiddleware(ibcmockv2.IBCModule{}, &channelkeeperv2.Keeper{}, nil, &channelkeeperv2.Keeper{}, maxCallbackGas)
5759
},
58-
fmt.Errorf("contract keeper cannot be nil"),
60+
errors.New("contract keeper cannot be nil"),
5961
},
6062
{
6163
"panics with nil channel v2 keeper",
6264
func() {
6365
_ = v2.NewIBCMiddleware(ibcmockv2.IBCModule{}, &channelkeeperv2.Keeper{}, simapp.ContractKeeper{}, nil, maxCallbackGas)
6466
},
65-
fmt.Errorf("channel keeper v2 cannot be nil"),
67+
errors.New("channel keeper v2 cannot be nil"),
6668
},
6769
{
6870
"panics with zero maxCallbackGas",
6971
func() {
7072
_ = v2.NewIBCMiddleware(ibcmockv2.IBCModule{}, &channelkeeperv2.Keeper{}, simapp.ContractKeeper{}, &channelkeeperv2.Keeper{}, uint64(0))
7173
},
72-
fmt.Errorf("maxCallbackGas cannot be zero"),
74+
errors.New("maxCallbackGas cannot be zero"),
7375
},
7476
}
7577

modules/core/02-client/types/codec_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package types_test
22

33
import (
4-
"fmt"
4+
"errors"
55

66
errorsmod "cosmossdk.io/errors"
77

@@ -227,7 +227,7 @@ func (suite *TypesTestSuite) TestCodecTypeRegistration() {
227227
{
228228
"type not registered on codec",
229229
"ibc.invalid.MsgTypeURL",
230-
fmt.Errorf("unable to resolve type URL ibc.invalid.MsgTypeURL"),
230+
errors.New("unable to resolve type URL ibc.invalid.MsgTypeURL"),
231231
},
232232
}
233233

modules/core/02-client/types/msgs_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ func (suite *TypesTestSuite) TestMsgUpdateParamsValidateBasic() {
931931
{
932932
"failure: invalid allowed client",
933933
types.NewMsgUpdateParams(signer, types.NewParams("")),
934-
fmt.Errorf("client type 0 cannot be blank"),
934+
errors.New("client type 0 cannot be blank"),
935935
},
936936
}
937937

@@ -957,7 +957,7 @@ func TestMsgUpdateParamsGetSigners(t *testing.T) {
957957
expErr error
958958
}{
959959
{"success: valid address", sdk.AccAddress(ibctesting.TestAccAddress), nil},
960-
{"failure: nil address", nil, fmt.Errorf("empty address string is not allowed")},
960+
{"failure: nil address", nil, errors.New("empty address string is not allowed")},
961961
}
962962

963963
for _, tc := range testCases {

modules/core/03-connection/types/codec_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package types_test
22

33
import (
4-
"fmt"
4+
"errors"
55
"testing"
66

77
"github.com/stretchr/testify/require"
@@ -47,7 +47,7 @@ func TestCodecTypeRegistration(t *testing.T) {
4747
{
4848
"type not registered on codec",
4949
"ibc.invalid.MsgTypeURL",
50-
fmt.Errorf("unable to resolve type URL ibc.invalid.MsgTypeURL"),
50+
errors.New("unable to resolve type URL ibc.invalid.MsgTypeURL"),
5151
},
5252
}
5353

modules/core/04-channel/keeper/grpc_query_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,7 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() {
13681368
},
13691369
status.Error(
13701370
codes.InvalidArgument,
1371-
fmt.Errorf("packet sequence 0 cannot be 0").Error(),
1371+
errors.New("packet sequence 0 cannot be 0").Error(),
13721372
),
13731373
},
13741374
{

modules/core/04-channel/types/acknowledgement_test.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package types_test
22

33
import (
44
"errors"
5-
"fmt"
65

76
errorsmod "cosmossdk.io/errors"
87

@@ -38,7 +37,7 @@ func (suite *TypesTestSuite) TestAcknowledgement() {
3837
},
3938
{
4039
"valid failed ack",
41-
types.NewErrorAcknowledgement(fmt.Errorf("error")),
40+
types.NewErrorAcknowledgement(errors.New("error")),
4241
true,
4342
[]byte(`{"error":"ABCI code: 1: error handling packet: see events for details"}`),
4443
false,
@@ -52,7 +51,7 @@ func (suite *TypesTestSuite) TestAcknowledgement() {
5251
},
5352
{
5453
"empty failed ack",
55-
types.NewErrorAcknowledgement(fmt.Errorf(" ")),
54+
types.NewErrorAcknowledgement(errors.New(" ")),
5655
true,
5756
[]byte(`{"error":"ABCI code: 1: error handling packet: see events for details"}`),
5857
false,

modules/core/04-channel/types/codec_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package types_test
22

33
import (
4-
"fmt"
4+
"errors"
55
"testing"
66

77
"github.com/stretchr/testify/require"
@@ -77,7 +77,7 @@ func TestCodecTypeRegistration(t *testing.T) {
7777
{
7878
"type not registered on codec",
7979
"ibc.invalid.MsgTypeURL",
80-
fmt.Errorf("unable to resolve type URL ibc.invalid.MsgTypeURL"),
80+
errors.New("unable to resolve type URL ibc.invalid.MsgTypeURL"),
8181
},
8282
}
8383

0 commit comments

Comments
 (0)