Skip to content
Snippets Groups Projects
Commit 6ccae24b authored by David Stainton's avatar David Stainton
Browse files

Fix test TestSendGeneric

parent df06fbbd
No related branches found
No related tags found
5 merge requests!510Release,!419rewrote the health tracker to both consider if there are waiting rounds and...,!371[Channel RSAtoPrivate] Implement Reverse Asymmetric in Client/Broadcast,!354Channels impl,!340Project/channels
...@@ -2,18 +2,68 @@ package channels ...@@ -2,18 +2,68 @@ package channels
import ( import (
"crypto/ed25519" "crypto/ed25519"
"testing"
"time" "time"
"gitlab.com/xx_network/crypto/csprng"
"gitlab.com/xx_network/crypto/multicastRSA"
"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/elixxir/client/broadcast"
"gitlab.com/elixxir/client/cmix" "gitlab.com/elixxir/client/cmix"
"gitlab.com/elixxir/client/cmix/message" "gitlab.com/elixxir/client/cmix/message"
"gitlab.com/elixxir/client/cmix/rounds" "gitlab.com/elixxir/client/cmix/rounds"
"gitlab.com/elixxir/client/storage/versioned"
cryptoBroadcast "gitlab.com/elixxir/crypto/broadcast" cryptoBroadcast "gitlab.com/elixxir/crypto/broadcast"
cryptoChannel "gitlab.com/elixxir/crypto/channel" cryptoChannel "gitlab.com/elixxir/crypto/channel"
"gitlab.com/elixxir/crypto/fastRNG"
"gitlab.com/elixxir/ekv"
) )
type mockBroadcastChannel struct{}
func (m *mockBroadcastChannel) MaxPayloadSize() int {
return 12345
}
func (m *mockBroadcastChannel) MaxAsymmetricPayloadSize() int {
return 123
}
func (m *mockBroadcastChannel) Get() cryptoBroadcast.Channel {
return cryptoBroadcast.Channel{}
}
func (m *mockBroadcastChannel) Broadcast(payload []byte, cMixParams cmix.CMIXParams) (
id.Round, ephemeral.Id, error) {
return id.Round(123), ephemeral.Id{}, nil
}
func (m *mockBroadcastChannel) BroadcastWithAssembler(assembler broadcast.Assembler, cMixParams cmix.CMIXParams) (
id.Round, ephemeral.Id, error) {
return id.Round(123), ephemeral.Id{}, nil
}
func (m *mockBroadcastChannel) BroadcastAsymmetric(pk multicastRSA.PrivateKey, payload []byte,
cMixParams cmix.CMIXParams) (id.Round, ephemeral.Id, error) {
return id.Round(123), ephemeral.Id{}, nil
}
func (m *mockBroadcastChannel) BroadcastAsymmetricWithAssembler(
pk multicastRSA.PrivateKey, assembler broadcast.Assembler,
cMixParams cmix.CMIXParams) (id.Round, ephemeral.Id, error) {
return id.Round(123), ephemeral.Id{}, nil
}
func (m *mockBroadcastChannel) RegisterListener(listenerCb broadcast.ListenerFunc, method broadcast.Method) error {
return nil
}
func (m *mockBroadcastChannel) Stop() {
}
type mockBroadcastClient struct{} type mockBroadcastClient struct{}
func (m *mockBroadcastClient) GetMaxMessageLength() int { func (m *mockBroadcastClient) GetMaxMessageLength() int {
...@@ -96,7 +146,7 @@ func (m *mockEventModel) ReceiveReaction(channelID *id.ID, messageID cryptoChann ...@@ -96,7 +146,7 @@ func (m *mockEventModel) ReceiveReaction(channelID *id.ID, messageID cryptoChann
} }
/*func TestSendGeneric(t *testing.T) { func TestSendGeneric(t *testing.T) {
kv := versioned.NewKV(ekv.MakeMemstore()) kv := versioned.NewKV(ekv.MakeMemstore())
client := new(mockBroadcastClient) client := new(mockBroadcastClient)
...@@ -105,8 +155,8 @@ func (m *mockEventModel) ReceiveReaction(channelID *id.ID, messageID cryptoChann ...@@ -105,8 +155,8 @@ func (m *mockEventModel) ReceiveReaction(channelID *id.ID, messageID cryptoChann
nameService.validChMsg = true nameService.validChMsg = true
model := new(mockEventModel) model := new(mockEventModel)
manager := NewManager(kv, client, rngGen, nameService, model) mm := NewManager(kv, client, rngGen, nameService, model)
//m := manager.(*manager) m := mm.(*manager)
channelID := new(id.ID) channelID := new(id.ID)
messageType := MessageType(Text) messageType := MessageType(Text)
...@@ -114,13 +164,11 @@ func (m *mockEventModel) ReceiveReaction(channelID *id.ID, messageID cryptoChann ...@@ -114,13 +164,11 @@ func (m *mockEventModel) ReceiveReaction(channelID *id.ID, messageID cryptoChann
validUntil := time.Hour validUntil := time.Hour
params := new(cmix.CMIXParams) params := new(cmix.CMIXParams)
// mutate manager's channels map m.channels[channelID] = &joinedChannel{
// channels map[*id.ID]*joinedChannel broadcast: &mockBroadcastChannel{},
// add channelID and a joinedChannel }
//m.channels[channelID] = new(joinedChannel)
messageId, roundId, ephemeralId, err := manager.SendGeneric( messageId, roundId, ephemeralId, err := mm.SendGeneric(
channelID, channelID,
messageType, messageType,
msg, msg,
...@@ -132,4 +180,4 @@ func (m *mockEventModel) ReceiveReaction(channelID *id.ID, messageID cryptoChann ...@@ -132,4 +180,4 @@ func (m *mockEventModel) ReceiveReaction(channelID *id.ID, messageID cryptoChann
} }
t.Logf("messageId %v, roundId %v, ephemeralId %v", messageId, roundId, ephemeralId) t.Logf("messageId %v, roundId %v, ephemeralId %v", messageId, roundId, ephemeralId)
}*/ }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment