From b6ec8a62574efe169516a5f7535972df07b087ce Mon Sep 17 00:00:00 2001 From: Jeff Thompson Date: Sun, 29 Oct 2023 14:57:12 +0100 Subject: [PATCH] fix: In Keybase GetByAddress, change generic error to NewErrKeyNotFound Signed-off-by: Jeff Thompson --- tm2/pkg/crypto/keys/keybase.go | 2 +- tm2/pkg/crypto/keys/keybase_test.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tm2/pkg/crypto/keys/keybase.go b/tm2/pkg/crypto/keys/keybase.go index 16b3631d188..a3300bbeffa 100644 --- a/tm2/pkg/crypto/keys/keybase.go +++ b/tm2/pkg/crypto/keys/keybase.go @@ -189,7 +189,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) diff --git a/tm2/pkg/crypto/keys/keybase_test.go b/tm2/pkg/crypto/keys/keybase_test.go index 987a271881b..ff18a4cf25c 100644 --- a/tm2/pkg/crypto/keys/keybase_test.go +++ b/tm2/pkg/crypto/keys/keybase_test.go @@ -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) { @@ -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()