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
import (
"crypto/rand"
"github.com/pkg/errors"
pb "gitlab.com/elixxir/comms/mixmessages"
"gitlab.com/elixxir/crypto/factID"
"gitlab.com/elixxir/crypto/hash"
......@@ -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) {
if !m.IsRegistered(){
return nil, errors.New("Failed to add fact: " +
"client is not registered")
}
// Create a primitives Fact so we can hash it
f, err := fact.NewFact(inFact.T, inFact.Fact)
if err != nil {
......
......@@ -20,6 +20,7 @@ func (rFC *testAFC) SendRegisterFact(host *connect.Host, message *pb.FactRegiste
// Test that the addFact function completes successfully
func TestAddFact(t *testing.T) {
isReg := uint32(1)
// Add our host, addFact uses it to get the ID of the user
h, err := connect.NewHost(&id.DummyUser, "address", nil, connect.GetDefaultHostParams())
if err != nil {
......@@ -37,6 +38,7 @@ func TestAddFact(t *testing.T) {
m := Manager{
host: h,
privKey: cpk,
registered:&isReg,
}
// Create our test fact
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment