Skip to content

Commit

Permalink
fix: In Keybase GetByAddress, change generic error to NewErrKeyNotFound
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Thompson <[email protected]>
  • Loading branch information
jefft0 committed Oct 30, 2023
1 parent cb40737 commit bcb1dd9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tm2/pkg/crypto/keys/keybase.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func (kb dbKeybase) GetByName(name string) (Info, error) {
func (kb dbKeybase) GetByAddress(address crypto.Address) (Info, error) {
ik := kb.db.Get(addrKey(address))
if len(ik) == 0 {
return nil, fmt.Errorf("key with address %s not found", address)
return nil, keyerror.NewErrKeyNotFound(fmt.Sprintf("key with address %s not found", address))
}
bs := kb.db.Get(ik)
return readInfo(bs)
Expand Down
2 changes: 2 additions & 0 deletions tm2/pkg/crypto/keys/keybase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/gnolang/gno/tm2/pkg/crypto"
"github.com/gnolang/gno/tm2/pkg/crypto/ed25519"
"github.com/gnolang/gno/tm2/pkg/crypto/keys/keyerror"
)

func TestCreateAccountInvalidMnemonic(t *testing.T) {
Expand Down Expand Up @@ -99,6 +100,7 @@ func TestKeyManagement(t *testing.T) {
require.NoError(t, err)
_, err = cstore.GetByAddress(addr)
require.NotNil(t, err)
require.True(t, keyerror.IsErrKeyNotFound(err))

// list shows them in order
keyS, err := cstore.List()
Expand Down

0 comments on commit bcb1dd9

Please sign in to comment.