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