Skip to content

Commit

Permalink
refactor: replace error-handling code for potential wrapped errors (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
tuantran1702 committed Apr 30, 2024
1 parent 0a2481d commit 8a36d9d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion crypto/keys/secp256k1/internal/secp256k1/secp256_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"crypto/elliptic"
"crypto/rand"
"encoding/hex"
"errors"
"io"
"testing"
)
Expand Down Expand Up @@ -93,7 +94,7 @@ func TestInvalidRecoveryID(t *testing.T) {
sig, _ := Sign(msg, seckey)
sig[64] = 99
_, err := RecoverPubkey(msg, sig)
if err != ErrInvalidRecoveryID {
if !errors.Is(err, ErrInvalidRecoveryID) {
t.Fatalf("got %q, want %q", err, ErrInvalidRecoveryID)
}
}
Expand Down
7 changes: 4 additions & 3 deletions x/group/internal/orm/table_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package orm

import (
"errors"
"fmt"
"testing"

Expand All @@ -10,7 +11,7 @@ import (

errorsmod "cosmossdk.io/errors"
storetypes "cosmossdk.io/store/types"
"cosmossdk.io/x/group/errors"
grouperrors "cosmossdk.io/x/group/errors"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/address"
Expand Down Expand Up @@ -70,7 +71,7 @@ func TestCreate(t *testing.T) {
Id: 1,
Name: "some name",
},
expErr: errors.ErrORMEmptyKey,
expErr: grouperrors.ErrORMEmptyKey,
},
"happy path": {
rowID: EncodeSequence(1),
Expand Down Expand Up @@ -231,7 +232,7 @@ func TestDelete(t *testing.T) {

// then
var loaded testdata.TableModel
if spec.expErr == sdkerrors.ErrNotFound {
if errors.Is(spec.expErr, sdkerrors.ErrNotFound) {
require.NoError(t, myTable.GetOne(store, EncodeSequence(1), &loaded))
assert.Equal(t, initValue, loaded)
} else {
Expand Down
3 changes: 2 additions & 1 deletion x/upgrade/plan/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ func DownloadUpgrade(dstRoot, url, daemonName string) error {
// First try to download it as a single file. If there's no error, it's okay and we're done.
if err := getFile(url, target); err != nil {
// If it was a checksum error, no need to try as directory.
if _, ok := err.(*getter.ChecksumError); ok {
var checksumError *getter.ChecksumError
if errors.As(err, &checksumError) {
return err
}
// File download didn't work, try it as an archive.
Expand Down

0 comments on commit 8a36d9d

Please sign in to comment.