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
c213df42
Commit
c213df42
authored
4 years ago
by
Sydney Anne Erickson
Browse files
Options
Downloads
Patches
Plain Diff
Comments and fix TestAddFact
parent
30b1904e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ud/addFact.go
+1
-1
1 addition, 1 deletion
ud/addFact.go
ud/addFact_test.go
+19
-15
19 additions, 15 deletions
ud/addFact_test.go
with
20 additions
and
16 deletions
ud/addFact.go
+
1
−
1
View file @
c213df42
...
@@ -25,11 +25,11 @@ func (m *Manager) addFact(fact fact.Fact, aFC addFactComms) (*pb.FactRegisterRes
...
@@ -25,11 +25,11 @@ func (m *Manager) addFact(fact fact.Fact, aFC addFactComms) (*pb.FactRegisterRes
FactType
:
uint32
(
fact
.
T
),
FactType
:
uint32
(
fact
.
T
),
}
}
// Sign our fact for putting into the request
fsig
,
err
:=
rsa
.
Sign
(
rand
.
Reader
,
m
.
privKey
,
hash
.
CMixHash
,
mmFact
.
Digest
(),
nil
)
fsig
,
err
:=
rsa
.
Sign
(
rand
.
Reader
,
m
.
privKey
,
hash
.
CMixHash
,
mmFact
.
Digest
(),
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
return
&
pb
.
FactRegisterResponse
{},
err
return
&
pb
.
FactRegisterResponse
{},
err
}
}
//signature.Sign(mmFact, m.privKey)
// Create our Fact Removal Request message data
// Create our Fact Removal Request message data
remFactMsg
:=
pb
.
FactRegisterRequest
{
remFactMsg
:=
pb
.
FactRegisterRequest
{
...
...
This diff is collapsed.
Click to expand it.
ud/addFact_test.go
+
19
−
15
View file @
c213df42
package
ud
package
ud
import
(
import
(
"gitlab.com/elixxir/client/interfaces/contact"
"gitlab.com/elixxir/comms/client"
pb
"gitlab.com/elixxir/comms/mixmessages"
pb
"gitlab.com/elixxir/comms/mixmessages"
"gitlab.com/xx_network/comms/connect"
"gitlab.com/elixxir/primitives/fact"
"gitlab.com/xx_network/crypto/csprng"
"gitlab.com/xx_network/comms/connect"
"gitlab.com/xx_network/crypto/signature/rsa"
"gitlab.com/xx_network/crypto/csprng"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/crypto/signature/rsa"
"testing"
"gitlab.com/xx_network/primitives/id"
"testing"
)
)
type
testAFC
struct
{}
type
testAFC
struct
{}
// Dummy implementation of SendRegisterFact so we don't need
// to run our own UDB server
func
(
rFC
*
testAFC
)
SendRegisterFact
(
host
*
connect
.
Host
,
message
*
pb
.
FactRegisterRequest
)
(
*
pb
.
FactRegisterResponse
,
error
)
{
func
(
rFC
*
testAFC
)
SendRegisterFact
(
host
*
connect
.
Host
,
message
*
pb
.
FactRegisterRequest
)
(
*
pb
.
FactRegisterResponse
,
error
)
{
return
&
pb
.
FactRegisterResponse
{},
nil
return
&
pb
.
FactRegisterResponse
{},
nil
}
}
// Test that the addFact function completes successfully
func
TestAddFact
(
t
*
testing
.
T
)
{
func
TestAddFact
(
t
*
testing
.
T
)
{
c
,
err
:=
client
.
NewClientComms
(
&
id
.
DummyUser
,
nil
,
nil
,
nil
)
// Add our host, addFact uses it to get the ID of the user
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
h
,
err
:=
connect
.
NewHost
(
&
id
.
DummyUser
,
"address"
,
nil
,
connect
.
GetDefaultHostParams
())
h
,
err
:=
connect
.
NewHost
(
&
id
.
DummyUser
,
"address"
,
nil
,
connect
.
GetDefaultHostParams
())
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
// Create a new Private Key to use for signing the Fact
rng
:=
csprng
.
NewSystemRNG
()
rng
:=
csprng
.
NewSystemRNG
()
cpk
,
err
:=
rsa
.
GenerateKey
(
rng
,
2048
)
cpk
,
err
:=
rsa
.
GenerateKey
(
rng
,
2048
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
// Create our Manager object
m
:=
Manager
{
m
:=
Manager
{
comms
:
c
,
comms
:
nil
,
host
:
h
,
host
:
h
,
privKey
:
cpk
,
privKey
:
cpk
,
}
}
f
:=
contact
.
Fact
{
// Create our test fact
f
:=
fact
.
Fact
{
Fact
:
"testing"
,
Fact
:
"testing"
,
T
:
2
,
T
:
2
,
}
}
// Setup a dummy comms that implements SendRegisterFact
// This way we don't need to run UDB just to check that this
// function works.
tafc
:=
testAFC
{}
tafc
:=
testAFC
{}
// Run addFact and see if it returns without an error!
_
,
err
=
m
.
addFact
(
f
,
&
tafc
)
_
,
err
=
m
.
addFact
(
f
,
&
tafc
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
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