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
e28e12d6
Commit
e28e12d6
authored
2 years ago
by
David Stainton
Browse files
Options
Downloads
Plain Diff
Merge branch 'channelsImpl' of git.xx.network:elixxir/client into channelsImpl
parents
e476d19d
170d37d3
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
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
broadcast/asymmetric.go
+1
-1
1 addition, 1 deletion
broadcast/asymmetric.go
broadcast/asymmetric_test.go
+25
-25
25 additions, 25 deletions
broadcast/asymmetric_test.go
with
26 additions
and
26 deletions
broadcast/asymmetric.go
+
1
−
1
View file @
e28e12d6
...
...
@@ -31,7 +31,7 @@ func (bc *broadcastClient) BroadcastAsymmetric(pk multicastRSA.PrivateKey,
payload
[]
byte
,
cMixParams
cmix
.
CMIXParams
)
(
id
.
Round
,
ephemeral
.
Id
,
error
)
{
// Confirm network health
assemble
:=
func
(
rid
id
.
Round
)
(
payload
[]
byte
,
err
error
)
{
assemble
:=
func
(
rid
id
.
Round
)
([]
byte
,
error
)
{
return
payload
,
nil
}
return
bc
.
BroadcastAsymmetricWithAssembler
(
pk
,
assemble
,
cMixParams
)
...
...
This diff is collapsed.
Click to expand it.
broadcast/asymmetric_test.go
+
25
−
25
View file @
e28e12d6
...
...
@@ -21,31 +21,30 @@ import (
"gitlab.com/elixxir/primitives/format"
)
// Tests that
symmetric
Client adheres to the
Symmetric
interface.
// Tests that
broadcast
Client adheres to the
Channel
interface.
var
_
Channel
=
(
*
broadcastClient
)(
nil
)
// Tests that
symmetric
Client adheres to the
Symmetric
interface.
// Tests that
cmix.
Client adheres to the
Client
interface.
var
_
Client
=
(
cmix
.
Client
)(
nil
)
// Tests that mockProcessor adheres to the message.Processor interface.
var
_
message
.
Processor
=
(
*
mockProcessor
)(
nil
)
// mockProcessor adheres to the message.Processor interface.
type
mockProcessor
struct
{
messages
[]
format
.
Message
}
var
_
message
.
Processor
=
(
*
mockProcessor
)(
nil
)
func
newMockProcessor
()
*
mockProcessor
{
m
:=
new
(
mockProcessor
)
m
.
messages
=
make
([]
format
.
Message
,
0
)
return
m
}
func
(
p
*
mockProcessor
)
Process
(
message
format
.
Message
,
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
)
{
func
(
p
*
mockProcessor
)
Process
(
message
format
.
Message
,
_
receptionID
.
EphemeralIdentity
,
_
rounds
.
Round
)
{
p
.
messages
=
append
(
p
.
messages
,
message
)
}
func
(
p
mockProcessor
)
String
()
string
{
return
"hello"
}
func
(
p
*
mockProcessor
)
String
()
string
{
return
"hello"
}
func
Test_asymmetricClient_Smoke
(
t
*
testing
.
T
)
{
cMixHandler
:=
newMockCmixHandler
()
...
...
@@ -54,30 +53,30 @@ func Test_asymmetricClient_Smoke(t *testing.T) {
if
err
!=
nil
{
t
.
Fatalf
(
"Failed to generate priv key: %+v"
,
err
)
}
cname
:=
"MyChannel"
cdesc
:=
"This is my channel about stuff."
csalt
:=
cMixCrypto
.
NewSalt
(
csprng
.
NewSystemRNG
(),
32
)
cpubkey
:=
pk
.
GetPublic
()
cid
,
err
:=
crypto
.
NewChannelID
(
cname
,
cdesc
,
csalt
,
rsa
.
CreatePublicKeyPem
(
cpubkey
))
cName
:=
"MyChannel"
cDesc
:=
"This is my channel about stuff."
cSalt
:=
cMixCrypto
.
NewSalt
(
csprng
.
NewSystemRNG
(),
32
)
cPubKey
:=
pk
.
GetPublic
()
cid
,
err
:=
crypto
.
NewChannelID
(
cName
,
cDesc
,
cSalt
,
rsa
.
CreatePublicKeyPem
(
cPubKey
))
if
err
!=
nil
{
t
.
Errorf
(
"Failed to create channel ID: %+v"
,
err
)
}
channel
:=
&
crypto
.
Channel
{
ReceptionID
:
cid
,
Name
:
c
n
ame
,
Description
:
c
d
esc
,
Salt
:
c
s
alt
,
RsaPubKey
:
c
p
ub
k
ey
,
Name
:
c
N
ame
,
Description
:
c
D
esc
,
Salt
:
c
S
alt
,
RsaPubKey
:
c
P
ub
K
ey
,
}
///
// must mutate cMixHandler such that it's processorMap contains a
// message.Processor
processor
:=
newMockProcessor
()
cMixHandler
.
processorMap
[
*
cid
]
=
make
(
map
[
string
][]
message
.
Processor
)
cMixHandler
.
processorMap
[
*
cid
][
"AsymmBcast"
]
=
[]
message
.
Processor
{
processor
}
const
n
=
5
const
n
=
1
cbChans
:=
make
([]
chan
[]
byte
,
n
)
clients
:=
make
([]
Channel
,
n
)
for
i
:=
range
clients
{
...
...
@@ -122,9 +121,9 @@ func Test_asymmetricClient_Smoke(t *testing.T) {
select
{
case
r
:=
<-
cbChan
:
if
!
bytes
.
Equal
(
payload
,
r
)
{
t
.
Errorf
(
"Cmix %d failed to receive expected "
+
"
payload
from client %d.
"
+
"
\n
expected: %q
\n
received: %q"
,
j
,
i
,
payload
,
r
)
t
.
Errorf
(
"Cmix %d failed to receive expected
payload
"
+
"from client %d.
\n
expected: %q
\n
received: %q"
,
j
,
i
,
payload
,
r
)
}
case
<-
time
.
After
(
time
.
Second
)
:
t
.
Errorf
(
"Cmix %d timed out waiting for broadcast "
+
...
...
@@ -134,7 +133,8 @@ func Test_asymmetricClient_Smoke(t *testing.T) {
}
// Broadcast payload
_
,
_
,
err
:=
clients
[
i
]
.
BroadcastAsymmetric
(
pk
,
payload
,
cmix
.
GetDefaultCMIXParams
())
_
,
_
,
err
=
clients
[
i
]
.
BroadcastAsymmetric
(
pk
,
payload
,
cmix
.
GetDefaultCMIXParams
())
if
err
!=
nil
{
t
.
Errorf
(
"Cmix %d failed to send broadcast: %+v"
,
i
,
err
)
}
...
...
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