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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
9522e939
Commit
9522e939
authored
Aug 31, 2020
by
Jake Taylor
Browse files
Options
Downloads
Patches
Plain Diff
test
parent
a7718302
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
storage/cmix/store_test.go
+27
-0
27 additions, 0 deletions
storage/cmix/store_test.go
with
27 additions
and
0 deletions
storage/cmix/store_test.go
+
27
−
0
View file @
9522e939
...
@@ -81,6 +81,30 @@ func TestLoadStore(t *testing.T) {
...
@@ -81,6 +81,30 @@ func TestLoadStore(t *testing.T) {
}
}
}
}
// Happy path
func
TestStore_GetRoundKeys
(
t
*
testing
.
T
)
{
// Set up the circuit
numIds
:=
10
nodeIds
:=
make
([]
*
id
.
ID
,
numIds
)
for
i
:=
0
;
i
<
numIds
;
i
++
{
nodeIds
[
i
]
=
id
.
NewIdFromUInt
(
uint64
(
i
)
+
1
,
id
.
Node
,
t
)
key
:=
testStore
.
grp
.
NewInt
(
int64
(
i
)
+
1
)
testStore
.
Add
(
nodeIds
[
i
],
key
)
// This is wack but it cleans up after the test
defer
testStore
.
Remove
(
nodeIds
[
i
])
}
circuit
:=
connect
.
NewCircuit
(
nodeIds
)
result
,
missing
:=
testStore
.
GetRoundKeys
(
circuit
)
if
len
(
missing
)
!=
0
{
t
.
Errorf
(
"Expected to have no missing keys, got %d"
,
len
(
missing
))
}
if
result
==
nil
||
len
(
result
.
keys
)
!=
numIds
{
t
.
Errorf
(
"Expected to have %d node keys"
,
numIds
)
}
}
// Missing keys path
// Missing keys path
func
TestStore_GetRoundKeys_Missing
(
t
*
testing
.
T
)
{
func
TestStore_GetRoundKeys_Missing
(
t
*
testing
.
T
)
{
// Set up the circuit
// Set up the circuit
...
@@ -93,6 +117,9 @@ func TestStore_GetRoundKeys_Missing(t *testing.T) {
...
@@ -93,6 +117,9 @@ func TestStore_GetRoundKeys_Missing(t *testing.T) {
// Only add every other node so there are missing nodes
// Only add every other node so there are missing nodes
if
i
%
2
==
0
{
if
i
%
2
==
0
{
testStore
.
Add
(
nodeIds
[
i
],
key
)
testStore
.
Add
(
nodeIds
[
i
],
key
)
// This is wack but it cleans up after the test
defer
testStore
.
Remove
(
nodeIds
[
i
])
}
}
}
}
...
...
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