Fix GetIdentity()

xuu/aahha
James Mills 9 months ago
parent f5d022df56
commit fa26923d54
  1. 3
      identity.go
  2. 10
      identity_test.go

@ -118,9 +118,6 @@ func GetIdentity(options ...IdentityOption) (*Identity, error) {
ident.key = key
me, err := readUser(bytes.NewBuffer(ident.contents))
if err := me.Refresh(); err != nil {
return nil, fmt.Errorf("error looking up identity's user addr %q: %w", ident.Source(), err)
}
ident.addr = me
return ident, err

@ -27,7 +27,13 @@ func TestIdentity(t *testing.T) {
require.NoError(err)
fn := filepath.Join(dir, testIdentityPath)
ident, err := CreateIdentity(WithIdentityAddr(addr), WithIdentityPath(fn))
ident1, err := CreateIdentity(WithIdentityAddr(addr), WithIdentityPath(fn))
require.NoError(err)
assert.NotNil(ident.Key())
assert.NotNil(ident1.Key())
assert.Equal(addr.String(), ident1.Addr().String())
ident2, err := GetIdentity(WithIdentityAddr(addr), WithIdentityPath(fn))
require.NoError(err)
assert.NotNil(ident2.Key())
assert.Equal(addr.String(), ident2.Addr().String())
}

Loading…
Cancel
Save