Skip to content
Snippets Groups Projects
Commit b58c6e71 authored by Jono Wenger's avatar Jono Wenger
Browse files

Move mockBroadcastClient and mockEventModel to joinedChannel_test.go

parent 6ffe5f27
Branches
Tags
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
......@@ -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) {
}
......@@ -239,5 +239,4 @@ func TestAdminGeneric(t *testing.T) {
t.Errorf("The payload does not match. %s vs %s ",
umi.GetChannelMessage().Payload, msg)
}
* /
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment