From b58c6e713708912a81a2f9905ec84ad886719942 Mon Sep 17 00:00:00 2001 From: Jono Wenger <jono@elixxir.io> Date: Tue, 30 Aug 2022 13:55:51 -0700 Subject: [PATCH] Move mockBroadcastClient and mockEventModel to joinedChannel_test.go --- channels/joinedChannel_test.go | 48 ++++++++++++++++++++++++++++++++++ channels/send_test.go | 1 - 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/channels/joinedChannel_test.go b/channels/joinedChannel_test.go index 2043ec7d6..b37147979 100644 --- a/channels/joinedChannel_test.go +++ b/channels/joinedChannel_test.go @@ -11,18 +11,24 @@ import ( "bytes" "encoding/binary" "gitlab.com/elixxir/client/broadcast" + clientCmix "gitlab.com/elixxir/client/cmix" + "gitlab.com/elixxir/client/cmix/message" + "gitlab.com/elixxir/client/cmix/rounds" "gitlab.com/elixxir/client/storage/versioned" cryptoBroadcast "gitlab.com/elixxir/crypto/broadcast" + cryptoChannel "gitlab.com/elixxir/crypto/channel" "gitlab.com/elixxir/crypto/cmix" "gitlab.com/elixxir/crypto/fastRNG" "gitlab.com/elixxir/ekv" "gitlab.com/xx_network/crypto/csprng" "gitlab.com/xx_network/crypto/signature/rsa" "gitlab.com/xx_network/primitives/id" + "gitlab.com/xx_network/primitives/id/ephemeral" "reflect" "sort" "strconv" "testing" + "time" ) // Tests that manager.store stores the channel list in the ekv. @@ -462,3 +468,45 @@ func newTestChannel(name, description string, rng csprng.Source) ( RsaPubKey: pk.GetPublic(), }, pk, nil } + +//////////////////////////////////////////////////////////////////////////////// +// Mock Broadcast Client // +//////////////////////////////////////////////////////////////////////////////// + +// mockBroadcastClient adheres to the broadcast.Client interface. +type mockBroadcastClient struct{} + +func (m *mockBroadcastClient) GetMaxMessageLength() int { return 123 } + +func (m *mockBroadcastClient) SendWithAssembler(*id.ID, + clientCmix.MessageAssembler, clientCmix.CMIXParams) ( + id.Round, ephemeral.Id, error) { + return id.Round(567), ephemeral.Id{}, nil +} + +func (m *mockBroadcastClient) IsHealthy() bool { return true } +func (m *mockBroadcastClient) AddIdentity(*id.ID, time.Time, bool) {} +func (m *mockBroadcastClient) AddService(*id.ID, message.Service, message.Processor) {} +func (m *mockBroadcastClient) DeleteClientService(*id.ID) {} +func (m *mockBroadcastClient) RemoveIdentity(*id.ID) {} + +//////////////////////////////////////////////////////////////////////////////// +// Mock EventModel // +//////////////////////////////////////////////////////////////////////////////// + +// mockEventModel adheres to the EventModel interface. +type mockEventModel struct{} + +func (m *mockEventModel) JoinChannel(*cryptoBroadcast.Channel) {} +func (m *mockEventModel) LeaveChannel(*id.ID) {} +func (m *mockEventModel) ReceiveMessage(*id.ID, cryptoChannel.MessageID, string, + string, time.Time, time.Duration, rounds.Round) { +} +func (m *mockEventModel) ReceiveReply(*id.ID, cryptoChannel.MessageID, + cryptoChannel.MessageID, string, string, time.Time, time.Duration, + rounds.Round) { +} +func (m *mockEventModel) ReceiveReaction(*id.ID, cryptoChannel.MessageID, + cryptoChannel.MessageID, string, string, time.Time, time.Duration, + rounds.Round) { +} diff --git a/channels/send_test.go b/channels/send_test.go index d6eb9df91..bce22720c 100644 --- a/channels/send_test.go +++ b/channels/send_test.go @@ -239,5 +239,4 @@ func TestAdminGeneric(t *testing.T) { t.Errorf("The payload does not match. %s vs %s ", umi.GetChannelMessage().Payload, msg) } - * / } -- GitLab