Skip to content
Snippets Groups Projects
Commit 87da0af4 authored by Jake Taylor's avatar Jake Taylor
Browse files

fix some syntax

parent 7319ce2b
No related branches found
No related tags found
2 merge requests!510Release,!238Hotfix/e2e client
......@@ -7,7 +7,7 @@
// FIXME: This is placeholder, there's got to be a better place to put
// backup restoration than inside messenger.
package xxdk
package backup
import (
"github.com/pkg/errors"
......@@ -16,6 +16,7 @@ import (
"gitlab.com/elixxir/client/storage"
"gitlab.com/elixxir/client/storage/user"
"gitlab.com/elixxir/client/ud"
"gitlab.com/elixxir/client/xxdk"
cryptoBackup "gitlab.com/elixxir/crypto/backup"
"gitlab.com/elixxir/primitives/fact"
"gitlab.com/xx_network/primitives/id"
......@@ -39,16 +40,16 @@ func NewClientFromBackup(ndfJSON, storageDir string, sessionPassword,
usr := user.NewUserFromBackup(backUp)
def, err := ParseNDF(ndfJSON)
def, err := xxdk.ParseNDF(ndfJSON)
if err != nil {
return nil, "", err
}
cmixGrp, e2eGrp := DecodeGroups(def)
cmixGrp, e2eGrp := xxdk.DecodeGroups(def)
// Note we do not need registration here
storageSess, err := CheckVersionAndSetupStorage(def, storageDir,
[]byte(sessionPassword), usr, cmixGrp, e2eGrp,
storageSess, err := xxdk.CheckVersionAndSetupStorage(def, storageDir,
sessionPassword, usr, cmixGrp, e2eGrp,
backUp.RegistrationCode)
if err != nil {
return nil, "", err
......@@ -89,7 +90,6 @@ func NewClientFromBackup(ndfJSON, storageDir string, sessionPassword,
phone = f
}
}
ud.InitStoreFromBackup(storageSess.GetKV(), username, email, phone)
return backUp.Contacts.Identities, backUp.JSONParams, nil
err = ud.InitStoreFromBackup(storageSess.GetKV(), username, email, phone)
return backUp.Contacts.Identities, backUp.JSONParams, err
}
......@@ -9,6 +9,7 @@ package backup
import (
"bytes"
"gitlab.com/elixxir/client/xxdk"
"reflect"
"strings"
"testing"
......@@ -16,7 +17,6 @@ import (
"gitlab.com/elixxir/client/storage"
"gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/elixxir/client/xxdk/e2eApi"
"gitlab.com/elixxir/ekv"
"gitlab.com/elixxir/crypto/backup"
......@@ -32,7 +32,7 @@ func Test_InitializeBackup(t *testing.T) {
cbChan := make(chan []byte, 2)
cb := func(encryptedBackup []byte) { cbChan <- encryptedBackup }
expectedPassword := "MySuperSecurePassword"
b, err := InitializeBackup(expectedPassword, cb, &e2eApi.Container{},
b, err := InitializeBackup(expectedPassword, cb, &xxdk.Container{},
newMockE2e(t),
newMockSession(t), newMockUserDiscovery(), kv, rngGen)
if err != nil {
......@@ -84,7 +84,7 @@ func Test_ResumeBackup(t *testing.T) {
cbChan1 := make(chan []byte)
cb1 := func(encryptedBackup []byte) { cbChan1 <- encryptedBackup }
expectedPassword := "MySuperSecurePassword"
b, err := InitializeBackup(expectedPassword, cb1, &e2eApi.Container{},
b, err := InitializeBackup(expectedPassword, cb1, &xxdk.Container{},
newMockE2e(t), newMockSession(t), newMockUserDiscovery(), kv, rngGen)
if err != nil {
t.Errorf("Failed to initialize new Backup: %+v", err)
......@@ -106,7 +106,7 @@ func Test_ResumeBackup(t *testing.T) {
// Resume the backup with a new callback
cbChan2 := make(chan []byte)
cb2 := func(encryptedBackup []byte) { cbChan2 <- encryptedBackup }
b2, err := ResumeBackup(cb2, &e2eApi.Container{}, newMockE2e(t), newMockSession(t),
b2, err := ResumeBackup(cb2, &xxdk.Container{}, newMockE2e(t), newMockSession(t),
newMockUserDiscovery(), kv, rngGen)
if err != nil {
t.Errorf("ResumeBackup returned an error: %+v", err)
......@@ -149,7 +149,7 @@ func Test_resumeBackup_NoKeyError(t *testing.T) {
expectedErr := "object not found"
s := storage.InitTestingSession(t)
rngGen := fastRNG.NewStreamGenerator(1000, 10, csprng.NewSystemRNG)
_, err := ResumeBackup(nil, &e2eApi.Container{}, newMockE2e(t), newMockSession(t),
_, err := ResumeBackup(nil, &xxdk.Container{}, newMockE2e(t), newMockSession(t),
newMockUserDiscovery(), s.GetKV(), rngGen)
if err == nil || !strings.Contains(err.Error(), expectedErr) {
t.Errorf("ResumeBackup did not return the expected error when no "+
......@@ -392,7 +392,7 @@ func newTestBackup(password string, cb UpdateBackupFn, t *testing.T) *Backup {
b, err := InitializeBackup(
password,
cb,
&e2eApi.Container{},
&xxdk.Container{},
newMockE2e(t),
newMockSession(t),
newMockUserDiscovery(),
......@@ -416,7 +416,7 @@ func Benchmark_InitializeBackup(t *testing.B) {
expectedPassword := "MySuperSecurePassword"
for i := 0; i < t.N; i++ {
_, err := InitializeBackup(expectedPassword, cb,
&e2eApi.Container{},
&xxdk.Container{},
newMockE2e(t),
newMockSession(t), newMockUserDiscovery(), kv, rngGen)
if err != nil {
......
......@@ -35,6 +35,6 @@ func (c *Cmix) ConnectWithAuthentication(e2eId int, recipientContact []byte) (*A
return nil, err
}
connection, err := connect.ConnectWithAuthentication(cont, e2eClient, connect.GetDefaultParams())
connection, err := connect.ConnectWithAuthentication(cont, e2eClient.api, connect.GetDefaultParams())
return authenticatedConnectionTrackerSingleton.make(connection), nil
}
......@@ -44,7 +44,7 @@ func (c *Cmix) Connect(e2eId int, recipientContact []byte) (
return nil, err
}
connection, err := connect.Connect(cont, e2eClient, connect.GetDefaultParams())
connection, err := connect.Connect(cont, e2eClient.api, connect.GetDefaultParams())
if err != nil {
return nil, err
}
......
......@@ -558,7 +558,7 @@ func createClient() *xxdk.Cmix {
}
// Construct client from backup data
backupIdList, _, err := xxdk.NewClientFromBackup(string(ndfJSON), storeDir,
backupIdList, _, err := backup.NewClientFromBackup(string(ndfJSON), storeDir,
pass, backupPass, backupFile)
if err != nil {
jww.FATAL.Panicf("%+v", err)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment