Skip to content
Snippets Groups Projects
Commit 6fc44b51 authored by Benjamin Wenger's avatar Benjamin Wenger
Browse files

made addFact require registration

parent 174408ce
No related branches found
No related tags found
No related merge requests found
...@@ -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 {
......
...@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment