Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
6ccae24b
Commit
6ccae24b
authored
2 years ago
by
David Stainton
Browse files
Options
Downloads
Patches
Plain Diff
Fix test TestSendGeneric
parent
df06fbbd
No related branches found
No related tags found
5 merge requests
!510
Release
,
!419
rewrote the health tracker to both consider if there are waiting rounds and...
,
!371
[Channel RSAtoPrivate] Implement Reverse Asymmetric in Client/Broadcast
,
!354
Channels impl
,
!340
Project/channels
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
channels/send_test.go
+58
-10
58 additions, 10 deletions
channels/send_test.go
with
58 additions
and
10 deletions
channels/send_test.go
+
58
−
10
View file @
6ccae24b
...
...
@@ -2,18 +2,68 @@ package channels
import
(
"crypto/ed25519"
"testing"
"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/ephemeral"
"gitlab.com/elixxir/client/broadcast"
"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/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
{}
func
(
m
*
mockBroadcastClient
)
GetMaxMessageLength
()
int
{
...
...
@@ -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
())
client
:=
new
(
mockBroadcastClient
)
...
...
@@ -105,8 +155,8 @@ func (m *mockEventModel) ReceiveReaction(channelID *id.ID, messageID cryptoChann
nameService
.
validChMsg
=
true
model
:=
new
(
mockEventModel
)
m
anager
:= NewManager(kv, client, rngGen, nameService, model)
//
m := m
anager
.(*manager)
m
m
:=
NewManager
(
kv
,
client
,
rngGen
,
nameService
,
model
)
m
:=
m
m
.
(
*
manager
)
channelID
:=
new
(
id
.
ID
)
messageType
:=
MessageType
(
Text
)
...
...
@@ -114,13 +164,11 @@ func (m *mockEventModel) ReceiveReaction(channelID *id.ID, messageID cryptoChann
validUntil
:=
time
.
Hour
params
:=
new
(
cmix
.
CMIXParams
)
// mutate manager's channels map
// channels map[*id.ID]*joinedChannel
// add channelID and a joinedChannel
//m.channels[channelID] = new(joinedChannel)
m
.
channels
[
channelID
]
=
&
joinedChannel
{
broadcast
:
&
mockBroadcastChannel
{},
}
messageId, roundId, ephemeralId, err := m
anager
.SendGeneric(
messageId
,
roundId
,
ephemeralId
,
err
:=
m
m
.
SendGeneric
(
channelID
,
messageType
,
msg
,
...
...
@@ -132,4 +180,4 @@ func (m *mockEventModel) ReceiveReaction(channelID *id.ID, messageID cryptoChann
}
t
.
Logf
(
"messageId %v, roundId %v, ephemeralId %v"
,
messageId
,
roundId
,
ephemeralId
)
}
*/
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment