Skip to content

Commit

Permalink
chore: In keybase_test.go, change GetByName and GetByAddress to HasBy…
Browse files Browse the repository at this point in the history
…Name and HasByAddress if possible

Signed-off-by: Jeff Thompson <jeff@thefirst.org>
  • Loading branch information
jefft0 committed Oct 31, 2023
1 parent 21e9172 commit c6d0075
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions tm2/pkg/crypto/keys/keybase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ func TestKeyManagement(t *testing.T) {
assert.Empty(t, l)

// create some keys
_, err = cstore.GetByName(n1)
require.Error(t, err)
has, err := cstore.HasByName(n1)
require.NoError(t, err)
require.False(t, has)
i, err := cstore.CreateAccount(n1, mn1, bip39Passphrase, p1, 0, 0)
require.NoError(t, err)
require.Equal(t, n1, i.GetName())
Expand All @@ -91,14 +92,17 @@ func TestKeyManagement(t *testing.T) {
// we can get these keys
i2, err := cstore.GetByName(n2)
require.NoError(t, err)
_, err = cstore.GetByName(n3)
require.NotNil(t, err)
_, err = cstore.GetByAddress(toAddr(i2))
has, err = cstore.HasByName(n3)
require.NoError(t, err)
require.False(t, has)
has, err = cstore.HasByAddress(toAddr(i2))
require.NoError(t, err)
require.True(t, has)
addr, err := crypto.AddressFromBech32("g1frtkxv37nq7arvyz5p0mtjqq7hwuvd4dnt892p")
require.NoError(t, err)
_, err = cstore.GetByAddress(addr)
require.NotNil(t, err)
has, err = cstore.HasByAddress(addr)
require.NoError(t, err)
require.False(t, has)

// list shows them in order
keyS, err := cstore.List()
Expand All @@ -117,8 +121,9 @@ func TestKeyManagement(t *testing.T) {
keyS, err = cstore.List()
require.NoError(t, err)
require.Equal(t, 1, len(keyS))
_, err = cstore.GetByName(n1)
require.Error(t, err)
has, err = cstore.HasByName(n1)
require.NoError(t, err)
require.False(t, has)

// create an offline key
o1 := "offline"
Expand Down Expand Up @@ -368,8 +373,9 @@ func TestSeedPhrase(t *testing.T) {
// now, let us delete this key
err = cstore.Delete(n1, p1, false)
require.Nil(t, err, "%+v", err)
_, err = cstore.GetByName(n1)
require.NotNil(t, err)
has, err := cstore.HasByName(n1)
require.NoError(t, err)
require.False(t, has)
}

func ExampleNew() {
Expand Down

0 comments on commit c6d0075

Please sign in to comment.