Skip to content
Snippets Groups Projects
Commit 2b243d52 authored by benjamin's avatar benjamin
Browse files

fixed tests

parent ff40d501
No related branches found
No related tags found
4 merge requests!510Release,!419rewrote the health tracker to both consider if there are waiting rounds and...,!402modified sent code to hand random instead of nil ids to the layer below,!340Project/channels
...@@ -143,7 +143,7 @@ func setupManager(identity cryptoChannel.PrivateIdentity, kv *versioned.KV, ...@@ -143,7 +143,7 @@ func setupManager(identity cryptoChannel.PrivateIdentity, kv *versioned.KV,
m.events = initEvents(model) m.events = initEvents(model)
m.st = loadSendTracker(net, kv, m.events.triggerEvent, m.st = loadSendTracker(net, kv, m.events.triggerEvent,
m.events.triggerAdminEvent, model.UpdateSentStatus) m.events.triggerAdminEvent, model.UpdateSentStatus, rng)
m.loadChannels() m.loadChannels()
......
...@@ -7,8 +7,10 @@ import ( ...@@ -7,8 +7,10 @@ import (
"gitlab.com/elixxir/client/cmix/rounds" "gitlab.com/elixxir/client/cmix/rounds"
"gitlab.com/elixxir/client/storage/versioned" "gitlab.com/elixxir/client/storage/versioned"
cryptoChannel "gitlab.com/elixxir/crypto/channel" cryptoChannel "gitlab.com/elixxir/crypto/channel"
"gitlab.com/elixxir/crypto/fastRNG"
"gitlab.com/elixxir/ekv" "gitlab.com/elixxir/ekv"
"gitlab.com/elixxir/primitives/states" "gitlab.com/elixxir/primitives/states"
"gitlab.com/xx_network/crypto/csprng"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id/ephemeral" "gitlab.com/xx_network/primitives/id/ephemeral"
"gitlab.com/xx_network/primitives/netTime" "gitlab.com/xx_network/primitives/netTime"
...@@ -67,7 +69,9 @@ func TestSendTracker_MessageReceive(t *testing.T) { ...@@ -67,7 +69,9 @@ func TestSendTracker_MessageReceive(t *testing.T) {
cid := id.NewIdFromString("channel", id.User, t) cid := id.NewIdFromString("channel", id.User, t)
st := loadSendTracker(&mockClient{}, kv, trigger, nil, updateStatus) crng := fastRNG.NewStreamGenerator(100, 5, csprng.NewSystemRNG)
st := loadSendTracker(&mockClient{}, kv, trigger, nil, updateStatus, crng)
mid := cryptoChannel.MakeMessageID([]byte("hello"), cid) mid := cryptoChannel.MakeMessageID([]byte("hello"), cid)
process := st.MessageReceive(mid, r) process := st.MessageReceive(mid, r)
...@@ -140,7 +144,9 @@ func TestSendTracker_failedSend(t *testing.T) { ...@@ -140,7 +144,9 @@ func TestSendTracker_failedSend(t *testing.T) {
triggerCh <- status triggerCh <- status
} }
st := loadSendTracker(&mockClient{}, kv, nil, adminTrigger, updateStatus) crng := fastRNG.NewStreamGenerator(100, 5, csprng.NewSystemRNG)
st := loadSendTracker(&mockClient{}, kv, nil, adminTrigger, updateStatus, crng)
cid := id.NewIdFromString("channel", id.User, t) cid := id.NewIdFromString("channel", id.User, t)
mid := cryptoChannel.MakeMessageID([]byte("hello"), cid) mid := cryptoChannel.MakeMessageID([]byte("hello"), cid)
...@@ -206,7 +212,9 @@ func TestSendTracker_send(t *testing.T) { ...@@ -206,7 +212,9 @@ func TestSendTracker_send(t *testing.T) {
triggerCh <- true triggerCh <- true
} }
st := loadSendTracker(&mockClient{}, kv, trigger, nil, updateStatus) crng := fastRNG.NewStreamGenerator(100, 5, csprng.NewSystemRNG)
st := loadSendTracker(&mockClient{}, kv, trigger, nil, updateStatus, crng)
cid := id.NewIdFromString("channel", id.User, t) cid := id.NewIdFromString("channel", id.User, t)
mid := cryptoChannel.MakeMessageID([]byte("hello"), cid) mid := cryptoChannel.MakeMessageID([]byte("hello"), cid)
...@@ -265,7 +273,9 @@ func TestSendTracker_send(t *testing.T) { ...@@ -265,7 +273,9 @@ func TestSendTracker_send(t *testing.T) {
func TestSendTracker_load_store(t *testing.T) { func TestSendTracker_load_store(t *testing.T) {
kv := versioned.NewKV(ekv.MakeMemstore()) kv := versioned.NewKV(ekv.MakeMemstore())
st := loadSendTracker(&mockClient{}, kv, nil, nil, nil) crng := fastRNG.NewStreamGenerator(100, 5, csprng.NewSystemRNG)
st := loadSendTracker(&mockClient{}, kv, nil, nil, nil, crng)
cid := id.NewIdFromString("channel", id.User, t) cid := id.NewIdFromString("channel", id.User, t)
mid := cryptoChannel.MakeMessageID([]byte("hello"), cid) mid := cryptoChannel.MakeMessageID([]byte("hello"), cid)
rid := id.Round(2) rid := id.Round(2)
...@@ -275,7 +285,7 @@ func TestSendTracker_load_store(t *testing.T) { ...@@ -275,7 +285,7 @@ func TestSendTracker_load_store(t *testing.T) {
t.Fatalf("Failed to store byRound: %+v", err) t.Fatalf("Failed to store byRound: %+v", err)
} }
st2 := loadSendTracker(&mockClient{}, kv, nil, nil, nil) st2 := loadSendTracker(&mockClient{}, kv, nil, nil, nil, crng)
if len(st2.byRound) != len(st.byRound) { if len(st2.byRound) != len(st.byRound) {
t.Fatalf("byRound was not properly loaded") t.Fatalf("byRound was not properly loaded")
} }
...@@ -294,7 +304,9 @@ func TestRoundResult_callback(t *testing.T) { ...@@ -294,7 +304,9 @@ func TestRoundResult_callback(t *testing.T) {
return 0, nil return 0, nil
} }
st := loadSendTracker(&mockClient{}, kv, trigger, nil, update) crng := fastRNG.NewStreamGenerator(100, 5, csprng.NewSystemRNG)
st := loadSendTracker(&mockClient{}, kv, trigger, nil, update, crng)
cid := id.NewIdFromString("channel", id.User, t) cid := id.NewIdFromString("channel", id.User, t)
mid := cryptoChannel.MakeMessageID([]byte("hello"), cid) mid := cryptoChannel.MakeMessageID([]byte("hello"), cid)
......
...@@ -152,6 +152,8 @@ func TestSendGeneric(t *testing.T) { ...@@ -152,6 +152,8 @@ func TestSendGeneric(t *testing.T) {
t.Fatalf(err.Error()) t.Fatalf(err.Error())
} }
crng := fastRNG.NewStreamGenerator(100, 5, csprng.NewSystemRNG)
m := &manager{ m := &manager{
me: pi, me: pi,
channels: make(map[id.ID]*joinedChannel), channels: make(map[id.ID]*joinedChannel),
...@@ -173,7 +175,7 @@ func TestSendGeneric(t *testing.T) { ...@@ -173,7 +175,7 @@ func TestSendGeneric(t *testing.T) {
return 0, nil return 0, nil
}, func(uuid uint64, messageID cryptoChannel.MessageID, }, func(uuid uint64, messageID cryptoChannel.MessageID,
timestamp time.Time, round rounds.Round, status SentStatus) { timestamp time.Time, round rounds.Round, status SentStatus) {
}), }, crng),
} }
channelID := new(id.ID) channelID := new(id.ID)
...@@ -240,6 +242,8 @@ func TestAdminGeneric(t *testing.T) { ...@@ -240,6 +242,8 @@ func TestAdminGeneric(t *testing.T) {
t.Fatalf(err.Error()) t.Fatalf(err.Error())
} }
crng := fastRNG.NewStreamGenerator(100, 5, csprng.NewSystemRNG)
m := &manager{ m := &manager{
channels: make(map[id.ID]*joinedChannel), channels: make(map[id.ID]*joinedChannel),
nicknameManager: &nicknameManager{ nicknameManager: &nicknameManager{
...@@ -260,7 +264,7 @@ func TestAdminGeneric(t *testing.T) { ...@@ -260,7 +264,7 @@ func TestAdminGeneric(t *testing.T) {
return 0, nil return 0, nil
}, func(uuid uint64, messageID cryptoChannel.MessageID, }, func(uuid uint64, messageID cryptoChannel.MessageID,
timestamp time.Time, round rounds.Round, status SentStatus) { timestamp time.Time, round rounds.Round, status SentStatus) {
}), }, crng),
} }
messageType := Text messageType := Text
...@@ -330,6 +334,8 @@ func TestSendMessage(t *testing.T) { ...@@ -330,6 +334,8 @@ func TestSendMessage(t *testing.T) {
t.Fatalf(err.Error()) t.Fatalf(err.Error())
} }
crng := fastRNG.NewStreamGenerator(100, 5, csprng.NewSystemRNG)
m := &manager{ m := &manager{
me: pi, me: pi,
channels: make(map[id.ID]*joinedChannel), channels: make(map[id.ID]*joinedChannel),
...@@ -350,7 +356,7 @@ func TestSendMessage(t *testing.T) { ...@@ -350,7 +356,7 @@ func TestSendMessage(t *testing.T) {
return 0, nil return 0, nil
}, func(uuid uint64, messageID cryptoChannel.MessageID, }, func(uuid uint64, messageID cryptoChannel.MessageID,
timestamp time.Time, round rounds.Round, status SentStatus) { timestamp time.Time, round rounds.Round, status SentStatus) {
}), }, crng),
} }
channelID := new(id.ID) channelID := new(id.ID)
...@@ -425,6 +431,8 @@ func TestSendReply(t *testing.T) { ...@@ -425,6 +431,8 @@ func TestSendReply(t *testing.T) {
t.Fatalf(err.Error()) t.Fatalf(err.Error())
} }
crng := fastRNG.NewStreamGenerator(100, 5, csprng.NewSystemRNG)
m := &manager{ m := &manager{
me: pi, me: pi,
channels: make(map[id.ID]*joinedChannel), channels: make(map[id.ID]*joinedChannel),
...@@ -445,7 +453,7 @@ func TestSendReply(t *testing.T) { ...@@ -445,7 +453,7 @@ func TestSendReply(t *testing.T) {
return 0, nil return 0, nil
}, func(uuid uint64, messageID cryptoChannel.MessageID, }, func(uuid uint64, messageID cryptoChannel.MessageID,
timestamp time.Time, round rounds.Round, status SentStatus) { timestamp time.Time, round rounds.Round, status SentStatus) {
}), }, crng),
} }
channelID := new(id.ID) channelID := new(id.ID)
...@@ -520,6 +528,8 @@ func TestSendReaction(t *testing.T) { ...@@ -520,6 +528,8 @@ func TestSendReaction(t *testing.T) {
t.Fatalf(err.Error()) t.Fatalf(err.Error())
} }
crng := fastRNG.NewStreamGenerator(100, 5, csprng.NewSystemRNG)
m := &manager{ m := &manager{
me: pi, me: pi,
nicknameManager: &nicknameManager{ nicknameManager: &nicknameManager{
...@@ -540,7 +550,7 @@ func TestSendReaction(t *testing.T) { ...@@ -540,7 +550,7 @@ func TestSendReaction(t *testing.T) {
return 0, nil return 0, nil
}, func(uuid uint64, messageID cryptoChannel.MessageID, }, func(uuid uint64, messageID cryptoChannel.MessageID,
timestamp time.Time, round rounds.Round, status SentStatus) { timestamp time.Time, round rounds.Round, status SentStatus) {
}), }, crng),
} }
channelID := new(id.ID) channelID := new(id.ID)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment