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
6fc44b51
Commit
6fc44b51
authored
4 years ago
by
Benjamin Wenger
Browse files
Options
Downloads
Patches
Plain Diff
made addFact require registration
parent
174408ce
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
+6
-0
6 additions, 0 deletions
ud/addFact.go
ud/addFact_test.go
+2
-0
2 additions, 0 deletions
ud/addFact_test.go
with
8 additions
and
0 deletions
ud/addFact.go
+
6
−
0
View file @
6fc44b51
...
@@ -2,6 +2,7 @@ package ud
...
@@ -2,6 +2,7 @@ package ud
import
(
import
(
"crypto/rand"
"crypto/rand"
"github.com/pkg/errors"
pb
"gitlab.com/elixxir/comms/mixmessages"
pb
"gitlab.com/elixxir/comms/mixmessages"
"gitlab.com/elixxir/crypto/factID"
"gitlab.com/elixxir/crypto/factID"
"gitlab.com/elixxir/crypto/hash"
"gitlab.com/elixxir/crypto/hash"
...
@@ -19,6 +20,11 @@ func (m *Manager) SendRegisterFact(fact fact.Fact) (*pb.FactRegisterResponse, er
...
@@ -19,6 +20,11 @@ func (m *Manager) SendRegisterFact(fact fact.Fact) (*pb.FactRegisterResponse, er
}
}
func
(
m
*
Manager
)
addFact
(
inFact
fact
.
Fact
,
aFC
addFactComms
)
(
*
pb
.
FactRegisterResponse
,
error
)
{
func
(
m
*
Manager
)
addFact
(
inFact
fact
.
Fact
,
aFC
addFactComms
)
(
*
pb
.
FactRegisterResponse
,
error
)
{
if
!
m
.
IsRegistered
(){
return
nil
,
errors
.
New
(
"Failed to add fact: "
+
"client is not registered"
)
}
// Create a primitives Fact so we can hash it
// Create a primitives Fact so we can hash it
f
,
err
:=
fact
.
NewFact
(
inFact
.
T
,
inFact
.
Fact
)
f
,
err
:=
fact
.
NewFact
(
inFact
.
T
,
inFact
.
Fact
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
ud/addFact_test.go
+
2
−
0
View file @
6fc44b51
...
@@ -20,6 +20,7 @@ func (rFC *testAFC) SendRegisterFact(host *connect.Host, message *pb.FactRegiste
...
@@ -20,6 +20,7 @@ func (rFC *testAFC) SendRegisterFact(host *connect.Host, message *pb.FactRegiste
// Test that the addFact function completes successfully
// Test that the addFact function completes successfully
func
TestAddFact
(
t
*
testing
.
T
)
{
func
TestAddFact
(
t
*
testing
.
T
)
{
isReg
:=
uint32
(
1
)
// Add our host, addFact uses it to get the ID of the user
// Add our host, addFact uses it to get the ID of the user
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
{
...
@@ -37,6 +38,7 @@ func TestAddFact(t *testing.T) {
...
@@ -37,6 +38,7 @@ func TestAddFact(t *testing.T) {
m
:=
Manager
{
m
:=
Manager
{
host
:
h
,
host
:
h
,
privKey
:
cpk
,
privKey
:
cpk
,
registered
:&
isReg
,
}
}
// Create our test fact
// Create our test fact
...
...
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