Skip to content
Snippets Groups Projects
Commit 5c890337 authored by Josh Brooks's avatar Josh Brooks
Browse files

Merge branch 'xx-3003/update-id-creation' of gitlab.com:elixxir/client into...

Merge branch 'xx-3003/update-id-creation' of gitlab.com:elixxir/client into XX-3063/PersonalEphemeralTracking
parents 6ac606a5 c109c215
No related branches found
No related tags found
No related merge requests found
package reception
import (
"gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/elixxir/ekv"
"math/rand"
"strings"
"testing"
"time"
)
func TestNewRegistration_Failed(t *testing.T) {
//generate an identity for use
rng := rand.New(rand.NewSource(42))
timestamp := time.Date(2009, 11, 17, 20,
34, 58, 651387237, time.UTC)
idu, _ := generateFakeIdentity(rng, 15, timestamp)
id := idu.Identity
kv := versioned.NewKV(make(ekv.Memstore))
id.End = time.Time{}
id.ExtraChecks = 0
_, err := newRegistration(id, kv)
if err==nil || !strings.Contains(err.Error(), "Cannot create a registration for an identity which has expired"){
t.Errorf("Registeration creation succeded with expired identity")
}
}
func TestNewRegistration_Ephemeral(t *testing.T) {
//generate an identity for use
rng := rand.New(rand.NewSource(42))
timestamp := time.Date(2009, 11, 17, 20,
34, 58, 651387237, time.UTC)
idu, _ := generateFakeIdentity(rng, 15, timestamp)
id := idu.Identity
kv := versioned.NewKV(make(ekv.Memstore))
id.End = time.Now().Add(1*time.Hour)
id.ExtraChecks = 2
id.Ephemeral = true
_, err := newRegistration(id, kv)
if err!=nil || !strings.Contains(err.Error(), "Cannot create a registration for an identity which has expired"){
t.Errorf("Registeration creation failed when it should have " +
"succeded: %+v", err)
}
}
\ No newline at end of file
...@@ -154,7 +154,7 @@ func (s *Store)GetIdentity(rng io.Reader)(IdentityUse, error){ ...@@ -154,7 +154,7 @@ func (s *Store)GetIdentity(rng io.Reader)(IdentityUse, error){
// with so we can continue tracking the network and to further obfuscate // with so we can continue tracking the network and to further obfuscate
// network identities // network identities
if len(s.active)==0{ if len(s.active)==0{
identity, err = generateFakeIdentity(rng, uint(s.idSize)) identity, err = generateFakeIdentity(rng, uint(s.idSize), now)
if err!=nil{ if err!=nil{
jww.FATAL.Panicf("Failed to generate a new ID when none " + jww.FATAL.Panicf("Failed to generate a new ID when none " +
"available: %+v", err) "available: %+v", err)
...@@ -167,7 +167,7 @@ func (s *Store)GetIdentity(rng io.Reader)(IdentityUse, error){ ...@@ -167,7 +167,7 @@ func (s *Store)GetIdentity(rng io.Reader)(IdentityUse, error){
} }
//calculate the sampling period //calculate the sampling period
identity, err = identity.SetSamplingPeriod(rng) identity, err = identity.setSamplingPeriod(rng)
if err!=nil{ if err!=nil{
jww.FATAL.Panicf("Failed to caluclate the sampling period: " + jww.FATAL.Panicf("Failed to caluclate the sampling period: " +
"%+v", err) "%+v", err)
...@@ -197,7 +197,7 @@ func (s *Store)AddIdentity(identity Identity)error { ...@@ -197,7 +197,7 @@ func (s *Store)AddIdentity(identity Identity)error {
return nil return nil
} }
func (s *Store)RemoveIdentity(ephID ephemeral.Id)bool { func (s *Store)RemoveIdentity(ephID ephemeral.Id) {
s.mux.Lock() s.mux.Lock()
defer s.mux.Unlock() defer s.mux.Unlock()
...@@ -207,7 +207,7 @@ func (s *Store)RemoveIdentity(ephID ephemeral.Id)bool { ...@@ -207,7 +207,7 @@ func (s *Store)RemoveIdentity(ephID ephemeral.Id)bool {
s.active = append(s.active[:i], s.active[i+1:]...) s.active = append(s.active[:i], s.active[i+1:]...)
err := inQuestion.Delete() err := inQuestion.Delete()
if err!=nil{ if err!=nil{
jww.FATAL.Panicf("Failed to delete identity %s") jww.FATAL.Panicf("Failed to delete identity: %+v", err)
} }
if !inQuestion.Ephemeral{ if !inQuestion.Ephemeral{
if err := s.save(); err!=nil{ if err := s.save(); err!=nil{
...@@ -215,12 +215,9 @@ func (s *Store)RemoveIdentity(ephID ephemeral.Id)bool { ...@@ -215,12 +215,9 @@ func (s *Store)RemoveIdentity(ephID ephemeral.Id)bool {
"identity removal") "identity removal")
} }
} }
return
return true
} }
} }
return false
} }
func (s *Store)UpdateIDSize(idSize uint){ func (s *Store)UpdateIDSize(idSize uint){
......
...@@ -119,13 +119,6 @@ func New(baseDir, password string, u userInterface.User, cmixGrp, ...@@ -119,13 +119,6 @@ func New(baseDir, password string, u userInterface.User, cmixGrp,
return nil, errors.WithMessage(err, "Failed to create garbledMessages buffer") return nil, errors.WithMessage(err, "Failed to create garbledMessages buffer")
} }
s.checkedRounds, err = utility.NewKnownRounds(s.kv, checkedRoundsKey, CheckRoundsMaxSize)
if err != nil {
return nil, errors.WithMessage(err, "Failed to create checkedRounds")
}
// There is no round id 0
s.checkedRounds.Check(0)
s.criticalMessages, err = utility.NewE2eMessageBuffer(s.kv, criticalMessagesKey) s.criticalMessages, err = utility.NewE2eMessageBuffer(s.kv, criticalMessagesKey)
if err != nil { if err != nil {
return nil, errors.WithMessage(err, "Failed to create e2e critical message buffer") return nil, errors.WithMessage(err, "Failed to create e2e critical message buffer")
......
...@@ -18,6 +18,7 @@ import ( ...@@ -18,6 +18,7 @@ import (
"gitlab.com/xx_network/crypto/csprng" "gitlab.com/xx_network/crypto/csprng"
"gitlab.com/xx_network/crypto/large" "gitlab.com/xx_network/crypto/large"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id/ephemeral"
"gitlab.com/xx_network/primitives/ndf" "gitlab.com/xx_network/primitives/ndf"
"math/rand" "math/rand"
"reflect" "reflect"
...@@ -352,8 +353,8 @@ func (t *testNetworkManager) SendUnsafe(m message.Send, _ params.Unsafe) ([]id.R ...@@ -352,8 +353,8 @@ func (t *testNetworkManager) SendUnsafe(m message.Send, _ params.Unsafe) ([]id.R
return rounds, nil return rounds, nil
} }
func (t *testNetworkManager) SendCMIX(format.Message, params.CMIX) (id.Round, error) { func (t *testNetworkManager) SendCMIX(format.Message, *id.ID, params.CMIX) (id.Round, ephemeral.Id, error) {
return 0, nil return 0, ephemeral.Id{}, nil
} }
func (t *testNetworkManager) GetInstance() *network.Instance { func (t *testNetworkManager) GetInstance() *network.Instance {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment