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
b192d685
Commit
b192d685
authored
Mar 1, 2020
by
Jonah Husson
Browse files
Options
Downloads
Patches
Plain Diff
finish tests for instance and securedndf
parent
7cac3a84
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
network/instance_test.go
+75
-2
75 additions, 2 deletions
network/instance_test.go
network/securedNdf_test.go
+122
-8
122 additions, 8 deletions
network/securedNdf_test.go
with
197 additions
and
10 deletions
network/instance_test.go
+
75
−
2
View file @
b192d685
package
network
package
network
import
(
import
(
"gitlab.com/elixxir/comms/connect"
"gitlab.com/elixxir/comms/mixmessages"
"gitlab.com/elixxir/comms/mixmessages"
ds
"gitlab.com/elixxir/comms/network/dataStructures"
ds
"gitlab.com/elixxir/comms/network/dataStructures"
"gitlab.com/elixxir/comms/testkeys"
"gitlab.com/elixxir/crypto/signature"
"gitlab.com/elixxir/crypto/signature/rsa"
"gitlab.com/elixxir/primitives/id"
"gitlab.com/elixxir/primitives/id"
"gitlab.com/elixxir/primitives/ndf"
"testing"
"testing"
)
)
...
@@ -63,14 +68,82 @@ func TestInstance_GetRoundUpdates(t *testing.T) {
...
@@ -63,14 +68,82 @@ func TestInstance_GetRoundUpdates(t *testing.T) {
}
}
}
}
func
setupComm
(
t
*
testing
.
T
)
(
*
Instance
,
*
mixmessages
.
NDF
)
{
priv
:=
testkeys
.
LoadFromPath
(
testkeys
.
GetNodeKeyPath
())
privKey
,
err
:=
rsa
.
LoadPrivateKeyFromPem
(
priv
)
pub
:=
testkeys
.
LoadFromPath
(
testkeys
.
GetNodeCertPath
())
if
err
!=
nil
{
t
.
Errorf
(
"Could not generate rsa key: %s"
,
err
)
}
f
:=
&
mixmessages
.
NDF
{}
baseNDF
:=
ndf
.
NetworkDefinition
{}
f
.
Ndf
,
err
=
baseNDF
.
Marshal
()
if
err
!=
nil
{
t
.
Errorf
(
"Could not generate serialized ndf: %s"
,
err
)
}
err
=
signature
.
Sign
(
f
,
privKey
)
pc
:=
&
connect
.
ProtoComms
{}
i
:=
NewInstance
(
pc
)
_
,
err
=
i
.
comm
.
AddHost
(
id
.
PERMISSIONING
,
"0.0.0.0:4200"
,
pub
,
false
,
true
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to add permissioning host: %+v"
,
err
)
}
return
i
,
f
}
func
TestInstance_RoundUpdate
(
t
*
testing
.
T
)
{
func
TestInstance_RoundUpdate
(
t
*
testing
.
T
)
{
msg
:=
&
mixmessages
.
RoundInfo
{
ID
:
2
,
UpdateID
:
4
,
State
:
6
,
BatchSize
:
8
,
}
priv
:=
testkeys
.
LoadFromPath
(
testkeys
.
GetNodeKeyPath
())
privKey
,
err
:=
rsa
.
LoadPrivateKeyFromPem
(
priv
)
err
=
signature
.
Sign
(
msg
,
privKey
)
i
:=
NewInstance
(
&
connect
.
ProtoComms
{})
pub
:=
testkeys
.
LoadFromPath
(
testkeys
.
GetGatewayCertPath
())
err
=
i
.
RoundUpdate
(
msg
)
if
err
==
nil
{
t
.
Error
(
"Should have failed to get perm host"
)
}
}
func
TestInstance_UpdateFullNdf
(
t
*
testing
.
T
)
{
_
,
err
=
i
.
comm
.
AddHost
(
id
.
PERMISSIONING
,
"0.0.0.0:4200"
,
pub
,
false
,
true
)
if
err
!=
nil
{
t
.
Errorf
(
"failed to add bad host: %+v"
,
err
)
}
err
=
i
.
RoundUpdate
(
msg
)
if
err
==
nil
{
t
.
Error
(
"Should have failed to verify"
)
}
i
,
_
=
setupComm
(
t
)
err
=
i
.
RoundUpdate
(
msg
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to update ndf: %+v"
,
err
)
}
}
}
func
TestInstance_UpdatePartialNdf
(
t
*
testing
.
T
)
{
func
TestInstance_UpdateFullNdf
(
t
*
testing
.
T
)
{
i
,
f
:=
setupComm
(
t
)
err
:=
i
.
UpdateFullNdf
(
f
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to update ndf: %+v"
,
err
)
}
}
func
TestInstance_UpdatePartialNdf
(
t
*
testing
.
T
)
{
i
,
f
:=
setupComm
(
t
)
err
:=
i
.
UpdatePartialNdf
(
f
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to update ndf: %+v"
,
err
)
}
}
}
This diff is collapsed.
Click to expand it.
network/securedNdf_test.go
+
122
−
8
View file @
b192d685
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