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
e63d5c66
Commit
e63d5c66
authored
2 years ago
by
Jono Wenger
Browse files
Options
Downloads
Patches
Plain Diff
Fix Test_asymmetricClient_Smoke
parent
b2ae067f
No related branches found
No related tags found
4 merge requests
!510
Release
,
!419
rewrote the health tracker to both consider if there are waiting rounds and...
,
!386
Channels restructure
,
!340
Project/channels
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
broadcast/rsaToPublic_test.go
+11
-10
11 additions, 10 deletions
broadcast/rsaToPublic_test.go
broadcast/utils_test.go
+6
-19
6 additions, 19 deletions
broadcast/utils_test.go
with
17 additions
and
29 deletions
broadcast/rsaToPublic_test.go
+
11
−
10
View file @
e63d5c66
...
...
@@ -7,7 +7,6 @@
package
broadcast
/*
import
(
"bytes"
"fmt"
...
...
@@ -57,23 +56,25 @@ func Test_asymmetricClient_Smoke(t *testing.T) {
rngGen
:=
fastRNG
.
NewStreamGenerator
(
1000
,
10
,
csprng
.
NewSystemRNG
)
cName
:=
"MyChannel"
cDesc
:=
"This is my channel about stuff."
packetPayloadLength
:=
newMockCmix
(
cMixHandler
)
.
GetMaxMessageLength
()
channel, pk, _ := crypto.NewChannel(
cName, cDesc,
newMockCmix(cMixHandler).GetMaxMessage
Length
()
, rngGen.GetStream())
channel
,
pk
,
_
:=
crypto
.
NewChannel
(
cName
,
cDesc
,
packetPayload
Length
,
rngGen
.
GetStream
())
cid
:=
channel
.
ReceptionID
// must mutate cMixHandler such that it's processorMap contains a
// Must mutate cMixHandler such that it's processorMap contains a
// message.Processor
processor
:= newMockProcessor()
mockProc
:=
newMockProcessor
()
cMixHandler
.
processorMap
[
*
cid
]
=
make
(
map
[
string
][]
message
.
Processor
)
cMixHandler.processorMap[*cid]["AsymmBcast"] = []message.Processor{
processor
}
cMixHandler
.
processorMap
[
*
cid
][
"AsymmBcast"
]
=
[]
message
.
Processor
{
mockProc
}
const
n
=
1
cbChans
:=
make
([]
chan
[]
byte
,
n
)
clients
:=
make
([]
Channel
,
n
)
for
i
:=
range
clients
{
cbChan
:=
make
(
chan
[]
byte
,
10
)
cb := func(
payload []byte, _ receptionID.EphemeralIdentity,
_ rounds.Round) {
cb
:=
func
(
payload
[]
byte
,
_
receptionID
.
EphemeralIdentity
,
_
rounds
.
Round
)
{
cbChan
<-
payload
}
...
...
@@ -90,7 +91,7 @@ func Test_asymmetricClient_Smoke(t *testing.T) {
cbChans
[
i
]
=
cbChan
clients
[
i
]
=
s
// Test that Get returns the expected channel
// Test that
Channel.
Get returns the expected channel
if
!
reflect
.
DeepEqual
(
s
.
Get
(),
channel
)
{
t
.
Errorf
(
"Cmix %d returned wrong channel."
+
"
\n
expected: %+v
\n
received: %+v"
,
i
,
channel
,
s
.
Get
())
...
...
@@ -163,4 +164,4 @@ func Test_asymmetricClient_Smoke(t *testing.T) {
}
wg
.
Wait
()
}
*/
}
This diff is collapsed.
Click to expand it.
broadcast/utils_test.go
+
6
−
19
View file @
e63d5c66
...
...
@@ -8,12 +8,9 @@
package
broadcast
import
(
"math/rand"
"sync"
"testing"
"time"
"gitlab.com/xx_network/crypto/signature/rsa"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id/ephemeral"
...
...
@@ -24,19 +21,8 @@ import (
"gitlab.com/elixxir/primitives/format"
)
// newRsaPubKey generates a new random RSA public key for testing.
func
newRsaPubKey
(
seed
int64
,
t
*
testing
.
T
)
*
rsa
.
PublicKey
{
prng
:=
rand
.
New
(
rand
.
NewSource
(
seed
))
privKey
,
err
:=
rsa
.
GenerateKey
(
prng
,
64
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to generate new RSA key: %+v"
,
err
)
}
return
privKey
.
GetPublic
()
}
////////////////////////////////////////////////////////////////////////////////
// Mock cMix //
// Mock cMix
//
////////////////////////////////////////////////////////////////////////////////
type
mockCmixHandler
struct
{
...
...
@@ -58,18 +44,19 @@ type mockCmix struct {
func
newMockCmix
(
handler
*
mockCmixHandler
)
*
mockCmix
{
return
&
mockCmix
{
numPrimeBytes
:
4096
,
numPrimeBytes
:
4096
/
8
,
health
:
true
,
handler
:
handler
,
}
}
func
(
m
*
mockCmix
)
GetMaxMessageLength
()
int
{
return
format
.
NewMessage
(
m
.
numPrimeBytes
*
2
)
.
ContentsSize
()
return
format
.
NewMessage
(
m
.
numPrimeBytes
)
.
ContentsSize
()
}
func
(
m
*
mockCmix
)
SendWithAssembler
(
recipient
*
id
.
ID
,
assembler
cmix
.
MessageAssembler
,
cmixParams
cmix
.
CMIXParams
)
(
rounds
.
Round
,
ephemeral
.
Id
,
error
)
{
func
(
m
*
mockCmix
)
SendWithAssembler
(
recipient
*
id
.
ID
,
assembler
cmix
.
MessageAssembler
,
_
cmix
.
CMIXParams
)
(
rounds
.
Round
,
ephemeral
.
Id
,
error
)
{
fingerprint
,
service
,
payload
,
mac
,
err
:=
assembler
(
42
)
if
err
!=
nil
{
...
...
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