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
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
f613a8f1
Commit
f613a8f1
authored
3 years ago
by
Jono Wenger
Browse files
Options
Downloads
Plain Diff
Merge branch 'neworloadNegs' into 'release'
NewOrLoad negs See merge request
!173
parents
d1d1ad4e
106076cd
No related branches found
No related tags found
2 merge requests
!231
Revert "Update store to print changes to the partners list"
,
!173
NewOrLoad negs
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
storage/auth/previousNegotiations.go
+7
-3
7 additions, 3 deletions
storage/auth/previousNegotiations.go
storage/auth/previousNegotiations_test.go
+26
-6
26 additions, 6 deletions
storage/auth/previousNegotiations_test.go
storage/auth/store.go
+1
-1
1 addition, 1 deletion
storage/auth/store.go
with
34 additions
and
10 deletions
storage/auth/previousNegotiations.go
+
7
−
3
View file @
f613a8f1
...
...
@@ -22,6 +22,7 @@ import (
"gitlab.com/elixxir/crypto/e2e/auth"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/netTime"
"strings"
)
const
(
...
...
@@ -157,11 +158,14 @@ func (s *Store) savePreviousNegotiations() error {
return
s
.
kv
.
Set
(
negotiationPartnersKey
,
negotiationPartnersVersion
,
obj
)
}
//
l
oadPreviousNegotiations loads the list of previousNegotiations partners
from
// storage.
func
(
s
*
Store
)
l
oadPreviousNegotiations
()
(
map
[
id
.
ID
]
struct
{},
error
)
{
//
newOrL
oadPreviousNegotiations loads the list of previousNegotiations partners
//
from
storage.
func
(
s
*
Store
)
newOrL
oadPreviousNegotiations
()
(
map
[
id
.
ID
]
struct
{},
error
)
{
obj
,
err
:=
s
.
kv
.
Get
(
negotiationPartnersKey
,
negotiationPartnersVersion
)
if
err
!=
nil
{
if
strings
.
Contains
(
err
.
Error
(),
"object not found"
)
{
return
make
(
map
[
id
.
ID
]
struct
{}),
nil
}
return
nil
,
err
}
...
...
This diff is collapsed.
Click to expand it.
storage/auth/previousNegotiations_test.go
+
26
−
6
View file @
f613a8f1
...
...
@@ -229,9 +229,9 @@ func TestStore_deletePreviousNegotiationPartner(t *testing.T) {
}
// Check previousNegotiations in storage
previousNegotiations
,
err
:=
s
.
l
oadPreviousNegotiations
()
previousNegotiations
,
err
:=
s
.
newOrL
oadPreviousNegotiations
()
if
err
!=
nil
{
t
.
Errorf
(
"
l
oadPreviousNegotiations returned an error (%d): %+v"
,
t
.
Errorf
(
"
newOrL
oadPreviousNegotiations returned an error (%d): %+v"
,
i
,
err
)
}
_
,
exists
=
previousNegotiations
[
*
v
.
partner
]
...
...
@@ -260,8 +260,8 @@ func TestStore_deletePreviousNegotiationPartner(t *testing.T) {
}
// Tests that Store.previousNegotiations can be saved and loaded from storage
// via Store.savePreviousNegotiations andStore.
l
oadPreviousNegotiations.
func
TestStore_savePreviousNegotiations_
l
oadPreviousNegotiations
(
t
*
testing
.
T
)
{
// via Store.savePreviousNegotiations andStore.
newOrL
oadPreviousNegotiations.
func
TestStore_savePreviousNegotiations_
newOrL
oadPreviousNegotiations
(
t
*
testing
.
T
)
{
s
:=
&
Store
{
kv
:
versioned
.
NewKV
(
make
(
ekv
.
Memstore
)),
previousNegotiations
:
make
(
map
[
id
.
ID
]
struct
{}),
...
...
@@ -280,9 +280,9 @@ func TestStore_savePreviousNegotiations_loadPreviousNegotiations(t *testing.T) {
i
,
err
)
}
s
.
previousNegotiations
,
err
=
s
.
l
oadPreviousNegotiations
()
s
.
previousNegotiations
,
err
=
s
.
newOrL
oadPreviousNegotiations
()
if
err
!=
nil
{
t
.
Errorf
(
"
l
oadPreviousNegotiations returned an error (%d): %+v"
,
t
.
Errorf
(
"
newOrL
oadPreviousNegotiations returned an error (%d): %+v"
,
i
,
err
)
}
...
...
@@ -293,6 +293,26 @@ func TestStore_savePreviousNegotiations_loadPreviousNegotiations(t *testing.T) {
}
}
// Tests that Store.newOrLoadPreviousNegotiations returns blank negotiations if
// they do not exist.
func
TestStore_newOrLoadPreviousNegotiations_noNegotiations
(
t
*
testing
.
T
)
{
s
:=
&
Store
{
kv
:
versioned
.
NewKV
(
make
(
ekv
.
Memstore
)),
previousNegotiations
:
make
(
map
[
id
.
ID
]
struct
{}),
}
expected
:=
make
(
map
[
id
.
ID
]
struct
{})
blankNegotations
,
err
:=
s
.
newOrLoadPreviousNegotiations
()
if
err
!=
nil
{
t
.
Errorf
(
"newOrLoadPreviousNegotiations returned an error: %+v"
,
err
)
}
if
!
reflect
.
DeepEqual
(
expected
,
blankNegotations
)
{
t
.
Errorf
(
"Loaded previousNegotiations does not match expected."
+
"
\n
expected: %v
\n
received: %v"
,
expected
,
blankNegotations
)
}
}
// Tests that a list of partner IDs that is marshalled and unmarshalled via
// marshalPreviousNegotiations and unmarshalPreviousNegotiations matches the
// original list
...
...
This diff is collapsed.
Click to expand it.
storage/auth/store.go
+
1
−
1
View file @
f613a8f1
...
...
@@ -155,7 +155,7 @@ func LoadStore(kv *versioned.KV, grp *cyclic.Group, privKeys []*cyclic.Int) (*St
}
// Load previous negotiations from storage
s
.
previousNegotiations
,
err
=
s
.
l
oadPreviousNegotiations
()
s
.
previousNegotiations
,
err
=
s
.
newOrL
oadPreviousNegotiations
()
if
err
!=
nil
{
return
nil
,
errors
.
Errorf
(
"failed to load list of previouse "
+
"negotation partner IDs: %+v"
,
err
)
...
...
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
register
or
sign in
to comment