Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Automate
Agent sessions
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
085eee01
Commit
085eee01
authored
Apr 5, 2022
by
Jono Wenger
Browse files
Options
Downloads
Patches
Plain Diff
Fix backup Contacts bug adn add test
parent
994ca738
No related branches found
No related tags found
2 merge requests
!233
Modify restore to call user-defined bindings callback. Add Sent requests to...
,
!231
Revert "Update store to print changes to the partners list"
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
backup/backup.go
+1
-1
1 addition, 1 deletion
backup/backup.go
backup/backup_test.go
+32
-0
32 additions, 0 deletions
backup/backup_test.go
storage/e2e/store.go
+2
-1
2 additions, 1 deletion
storage/e2e/store.go
with
35 additions
and
2 deletions
backup/backup.go
+
1
−
1
View file @
085eee01
...
...
@@ -303,7 +303,7 @@ func (b *Backup) assembleBackup() backup.Backup {
// Get contacts
bu
.
Contacts
.
Identities
=
b
.
store
.
E2e
()
.
GetPartners
()
//
a
dd the memoized
json
params
//
A
dd the memoized
JSON
params
bu
.
JSONParams
=
b
.
jsonParams
return
bu
...
...
This diff is collapsed.
Click to expand it.
backup/backup_test.go
+
32
−
0
View file @
085eee01
...
...
@@ -9,7 +9,13 @@ package backup
import
(
"bytes"
"github.com/cloudflare/circl/dh/sidh"
"gitlab.com/elixxir/client/interfaces/params"
util
"gitlab.com/elixxir/client/storage/utility"
"gitlab.com/elixxir/crypto/diffieHellman"
"gitlab.com/xx_network/primitives/id"
"reflect"
"sort"
"strings"
"testing"
"time"
...
...
@@ -376,6 +382,22 @@ func TestBackup_assembleBackup(t *testing.T) {
b
:=
newTestBackup
(
"MySuperSecurePassword"
,
nil
,
t
)
s
:=
b
.
store
rng
:=
csprng
.
NewSystemRNG
()
for
i
:=
0
;
i
<
10
;
i
++
{
recipient
,
_
:=
id
.
NewRandomID
(
rng
,
id
.
User
)
dhKey
:=
s
.
E2e
()
.
GetGroup
()
.
NewInt
(
int64
(
i
+
10
))
pubKey
:=
diffieHellman
.
GeneratePublicKey
(
dhKey
,
s
.
E2e
()
.
GetGroup
())
_
,
mySidhPriv
:=
util
.
GenerateSIDHKeyPair
(
sidh
.
KeyVariantSidhA
,
rng
)
theirSidhPub
,
_
:=
util
.
GenerateSIDHKeyPair
(
sidh
.
KeyVariantSidhB
,
rng
)
p
:=
params
.
GetDefaultE2ESessionParams
()
err
:=
s
.
E2e
()
.
AddPartner
(
recipient
,
pubKey
,
dhKey
,
mySidhPriv
,
theirSidhPub
,
p
,
p
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to add partner %s: %+v"
,
recipient
,
err
)
}
}
expectedCollatedBackup
:=
backup
.
Backup
{
RegistrationTimestamp
:
s
.
GetUser
()
.
RegistrationTimestamp
,
TransmissionIdentity
:
backup
.
TransmissionIdentity
{
...
...
@@ -400,6 +422,16 @@ func TestBackup_assembleBackup(t *testing.T) {
collatedBackup
:=
b
.
assembleBackup
()
sort
.
Slice
(
expectedCollatedBackup
.
Contacts
.
Identities
,
func
(
i
,
j
int
)
bool
{
return
bytes
.
Compare
(
expectedCollatedBackup
.
Contacts
.
Identities
[
i
]
.
Bytes
(),
expectedCollatedBackup
.
Contacts
.
Identities
[
j
]
.
Bytes
())
==
-
1
})
sort
.
Slice
(
collatedBackup
.
Contacts
.
Identities
,
func
(
i
,
j
int
)
bool
{
return
bytes
.
Compare
(
collatedBackup
.
Contacts
.
Identities
[
i
]
.
Bytes
(),
collatedBackup
.
Contacts
.
Identities
[
j
]
.
Bytes
())
==
-
1
})
if
!
reflect
.
DeepEqual
(
expectedCollatedBackup
,
collatedBackup
)
{
t
.
Errorf
(
"Collated backup does not match expected."
+
"
\n
expected: %+v
\n
received: %+v"
,
...
...
This diff is collapsed.
Click to expand it.
storage/e2e/store.go
+
2
−
1
View file @
085eee01
...
...
@@ -255,7 +255,8 @@ func (s *Store) GetPartners() []*id.ID {
partnerIds
:=
make
([]
*
id
.
ID
,
0
,
len
(
s
.
managers
))
for
partnerId
:=
range
s
.
managers
{
partnerIds
=
append
(
partnerIds
,
&
partnerId
)
pid
:=
partnerId
partnerIds
=
append
(
partnerIds
,
&
pid
)
}
return
partnerIds
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment