Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
comms
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
comms
Commits
9b4896c8
Commit
9b4896c8
authored
Sep 3, 2020
by
Jake Taylor
Browse files
Options
Downloads
Patches
Plain Diff
add test
parent
e5876071
No related branches found
No related tags found
1 merge request
!58
Revert "Modify waiting lock"
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
network/instance.go
+1
-1
1 addition, 1 deletion
network/instance.go
network/instance_test.go
+47
-1
47 additions, 1 deletion
network/instance_test.go
with
48 additions
and
2 deletions
network/instance.go
+
1
−
1
View file @
9b4896c8
...
...
@@ -59,7 +59,7 @@ type Heartbeat struct {
isRoundComplete
bool
}
// Register
AddNode
channel with Instance
// Register
NetworkHealth
channel with Instance
func
(
i
*
Instance
)
SetNetworkHealthChan
(
c
chan
Heartbeat
)
{
i
.
networkHealth
=
c
}
...
...
This diff is collapsed.
Click to expand it.
network/instance_test.go
+
47
−
1
View file @
9b4896c8
...
...
@@ -12,6 +12,7 @@ import (
ds
"gitlab.com/elixxir/comms/network/dataStructures"
"gitlab.com/elixxir/comms/testkeys"
"gitlab.com/elixxir/comms/testutils"
"gitlab.com/elixxir/primitives/states"
"gitlab.com/xx_network/comms/connect"
"gitlab.com/xx_network/crypto/signature"
"gitlab.com/xx_network/crypto/signature/rsa"
...
...
@@ -710,6 +711,51 @@ func TestInstance_NodeEventModel(t *testing.T) {
}
}
// Happy path
func
TestInstance_RoundUpdates
(
t
*
testing
.
T
)
{
i
,
_
:=
setupComm
(
t
)
nwHealth
:=
make
(
chan
Heartbeat
,
10
)
i
.
SetNetworkHealthChan
(
nwHealth
)
// Build a basic RoundInfo object and sign it
privKey
,
err
:=
rsa
.
LoadPrivateKeyFromPem
(
testkeys
.
LoadFromPath
(
testkeys
.
GetNodeKeyPath
()))
if
err
!=
nil
{
t
.
Errorf
(
"Could not get rsa key: %s"
,
err
)
}
r
:=
&
mixmessages
.
RoundInfo
{
ID
:
2
,
UpdateID
:
4
,
State
:
uint32
(
states
.
COMPLETED
),
}
err
=
signature
.
Sign
(
r
,
privKey
)
if
err
!=
nil
{
t
.
Errorf
(
err
.
Error
())
}
// Set up a function to read channel output
isFinished
:=
false
go
func
()
{
for
heartbeat
:=
range
nwHealth
{
if
!
heartbeat
.
isRoundComplete
{
t
.
Errorf
(
"Round should have been complete"
)
}
if
heartbeat
.
hasWaitingRound
{
t
.
Errorf
(
"Should have had no waiting rounds"
)
}
isFinished
=
true
break
}
}()
// Send the round update
err
=
i
.
RoundUpdates
([]
*
mixmessages
.
RoundInfo
{
r
})
// Wait for other thread to finish
for
!
isFinished
{
time
.
Sleep
(
50
*
time
.
Millisecond
)
}
}
// Happy path
func
TestInstance_UpdateGroup
(
t
*
testing
.
T
)
{
i
,
f
:=
setupComm
(
t
)
...
...
@@ -785,7 +831,7 @@ func TestInstance_RoundUpdateAddsToERS(t *testing.T) {
privKey
,
err
:=
rsa
.
LoadPrivateKeyFromPem
(
priv
)
pub
:=
testkeys
.
LoadFromPath
(
testkeys
.
GetNodeCertPath
())
if
err
!=
nil
{
t
.
Errorf
(
"Could not ge
nerate
rsa key: %s"
,
err
)
t
.
Errorf
(
"Could not ge
t
rsa key: %s"
,
err
)
}
// Create a basic testing NDF and sign it
...
...
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