This commit is contained in:
parent
385c5f3298
commit
a5cfbf854d
@ -35,7 +35,7 @@ type Identity struct {
|
||||
unlockedHiddenPeers PeerList
|
||||
}
|
||||
|
||||
func CreateIdentity(nickname string) *Identity {
|
||||
func CreateIdentity(nickname string) (*Identity, error) {
|
||||
var id Identity
|
||||
id.Nickname = nickname
|
||||
id.Uuid = uuid.New().String()
|
||||
@ -43,7 +43,11 @@ func CreateIdentity(nickname string) *Identity {
|
||||
GetConfig().me = &id
|
||||
id.MessageServers = ServerStorage{DbFile: uuid.NewString()}
|
||||
id.generateRandomHiddenStuff()
|
||||
return &id
|
||||
err := id.CreateFolder()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &id, nil
|
||||
}
|
||||
|
||||
func (id *Identity) CreateFolder() error {
|
||||
|
@ -24,8 +24,11 @@ func createId() *Identity {
|
||||
config.memoryPassword = "generalPassword"
|
||||
// ! Extension to quickly open db : Debug only !
|
||||
config.DbSuffix = ".sqlite"
|
||||
id := CreateIdentity("myname")
|
||||
err := id.Save()
|
||||
id, err := CreateIdentity("myname")
|
||||
if err != nil {
|
||||
log.Fatal("CreateIdentity failed")
|
||||
}
|
||||
err = id.Save()
|
||||
if err != nil {
|
||||
log.Fatal("Save failed")
|
||||
}
|
||||
@ -49,7 +52,10 @@ func TestLoad(t *testing.T) {
|
||||
}
|
||||
id, err := LoadIdentity("test.id", "toto")
|
||||
if err != nil {
|
||||
id := CreateIdentity("myname")
|
||||
id, err1 := CreateIdentity("myname")
|
||||
if err1 != nil {
|
||||
log.Fatal("CreateIdentity failed")
|
||||
}
|
||||
id.Save()
|
||||
} else {
|
||||
log.Println(id.Nickname)
|
||||
|
@ -8,7 +8,10 @@ import (
|
||||
)
|
||||
|
||||
func TestGetFromPublicKey(t *testing.T) {
|
||||
id := CreateIdentity("test")
|
||||
id, err := CreateIdentity("test")
|
||||
if err != nil {
|
||||
t.Fatal("CreateIdentity failed")
|
||||
}
|
||||
id.Save()
|
||||
for i := 1; i < 10; i++ {
|
||||
var p Peer
|
||||
|
Loading…
Reference in New Issue
Block a user