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
701a4c44
Commit
701a4c44
authored
3 years ago
by
Jake Taylor
Browse files
Options
Downloads
Patches
Plain Diff
fix tests
parent
410a14d0
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!170
Release
,
!142
remove round events from single use messages
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
single/transmission.go
+2
-3
2 additions, 3 deletions
single/transmission.go
single/transmission_test.go
+9
-11
9 additions, 11 deletions
single/transmission_test.go
with
11 additions
and
14 deletions
single/transmission.go
+
2
−
3
View file @
701a4c44
...
...
@@ -50,8 +50,7 @@ func (m *Manager) TransmitSingleUse(partner contact2.Contact, payload []byte,
rngReader
:=
m
.
rng
.
GetStream
()
defer
rngReader
.
Close
()
return
m
.
transmitSingleUse
(
partner
,
payload
,
tag
,
maxMsgs
,
rngReader
,
callback
,
timeout
,
m
.
net
.
GetInstance
()
.
GetRoundEvents
())
return
m
.
transmitSingleUse
(
partner
,
payload
,
tag
,
maxMsgs
,
rngReader
,
callback
,
timeout
)
}
// roundEvents interface allows custom round events to be passed in for testing.
...
...
@@ -62,7 +61,7 @@ type roundEvents interface {
// transmitSingleUse has the fields passed in for easier testing.
func
(
m
*
Manager
)
transmitSingleUse
(
partner
contact2
.
Contact
,
payload
[]
byte
,
tag
string
,
MaxMsgs
uint8
,
rng
io
.
Reader
,
callback
ReplyComm
,
timeout
time
.
Duration
,
roundEvents
roundEvents
)
error
{
tag
string
,
MaxMsgs
uint8
,
rng
io
.
Reader
,
callback
ReplyComm
,
timeout
time
.
Duration
)
error
{
// Get ephemeral ID address space size; this blocks until the address space
// size is set for the first time
...
...
This diff is collapsed.
Click to expand it.
single/transmission_test.go
+
9
−
11
View file @
701a4c44
...
...
@@ -50,8 +50,7 @@ func TestManager_transmitSingleUse(t *testing.T) {
callback
,
callbackChan
:=
createReplyComm
()
timeout
:=
15
*
time
.
Millisecond
err
:=
m
.
transmitSingleUse
(
partner
,
payload
,
tag
,
maxMsgs
,
prng
,
callback
,
timeout
,
newTestRoundEvents
(
false
))
err
:=
m
.
transmitSingleUse
(
partner
,
payload
,
tag
,
maxMsgs
,
prng
,
callback
,
timeout
)
if
err
!=
nil
{
t
.
Errorf
(
"transmitSingleUse() returned an error: %+v"
,
err
)
}
...
...
@@ -93,7 +92,7 @@ func TestManager_transmitSingleUse_QuitChanError(t *testing.T) {
timeout
:=
15
*
time
.
Millisecond
err
:=
m
.
transmitSingleUse
(
partner
,
[]
byte
{},
"testTag"
,
9
,
rand
.
New
(
rand
.
NewSource
(
42
)),
callback
,
timeout
,
newTestRoundEvents
(
false
)
)
rand
.
New
(
rand
.
NewSource
(
42
)),
callback
,
timeout
)
if
err
!=
nil
{
t
.
Errorf
(
"transmitSingleUse() returned an error: %+v"
,
err
)
}
...
...
@@ -125,7 +124,7 @@ func TestManager_transmitSingleUse_AddIdentityError(t *testing.T) {
callback
,
callbackChan
:=
createReplyComm
()
err
:=
m
.
transmitSingleUse
(
partner
,
[]
byte
{},
"testTag"
,
9
,
rand
.
New
(
rand
.
NewSource
(
42
)),
callback
,
timeout
,
newTestRoundEvents
(
false
)
)
rand
.
New
(
rand
.
NewSource
(
42
)),
callback
,
timeout
)
if
err
!=
nil
{
t
.
Errorf
(
"transmitSingleUse() returned an error: %+v"
,
err
)
}
...
...
@@ -158,7 +157,7 @@ func TestManager_transmitSingleUse_SendCMIXError(t *testing.T) {
timeout
:=
15
*
time
.
Millisecond
err
:=
m
.
transmitSingleUse
(
partner
,
[]
byte
{},
"testTag"
,
9
,
rand
.
New
(
rand
.
NewSource
(
42
)),
callback
,
timeout
,
newTestRoundEvents
(
false
)
)
rand
.
New
(
rand
.
NewSource
(
42
)),
callback
,
timeout
)
if
err
!=
nil
{
t
.
Errorf
(
"transmitSingleUse() returned an error: %+v"
,
err
)
}
...
...
@@ -182,7 +181,7 @@ func TestManager_transmitSingleUse_MakeTransmitCmixMessageError(t *testing.T) {
prng
:=
rand
.
New
(
rand
.
NewSource
(
42
))
payload
:=
make
([]
byte
,
m
.
store
.
Cmix
()
.
GetGroup
()
.
GetP
()
.
ByteLen
())
err
:=
m
.
transmitSingleUse
(
contact2
.
Contact
{},
payload
,
""
,
0
,
prng
,
nil
,
0
,
nil
)
err
:=
m
.
transmitSingleUse
(
contact2
.
Contact
{},
payload
,
""
,
0
,
prng
,
nil
,
0
)
if
err
==
nil
{
t
.
Error
(
"transmitSingleUse() did not return an error when the payload "
+
"is too large."
)
...
...
@@ -212,7 +211,7 @@ func TestManager_transmitSingleUse_AddStateError(t *testing.T) {
m
.
p
.
singleUse
[
*
rid
]
=
newState
(
dhKey
,
maxMsgs
,
nil
)
err
=
m
.
transmitSingleUse
(
partner
,
payload
,
tag
,
maxMsgs
,
rand
.
New
(
rand
.
NewSource
(
42
)),
callback
,
timeout
,
nil
)
rand
.
New
(
rand
.
NewSource
(
42
)),
callback
,
timeout
)
if
!
check
(
err
,
"failed to add pending state"
)
{
t
.
Errorf
(
"transmitSingleUse() failed to error when on adding state "
+
"when the state already exists: %+v"
,
err
)
...
...
@@ -232,8 +231,7 @@ func TestManager_transmitSingleUse_RoundTimeoutError(t *testing.T) {
callback
,
callbackChan
:=
createReplyComm
()
timeout
:=
15
*
time
.
Millisecond
err
:=
m
.
transmitSingleUse
(
partner
,
payload
,
"testTag"
,
8
,
prng
,
callback
,
timeout
,
newTestRoundEvents
(
true
))
err
:=
m
.
transmitSingleUse
(
partner
,
payload
,
"testTag"
,
8
,
prng
,
callback
,
timeout
)
if
err
!=
nil
{
t
.
Errorf
(
"transmitSingleUse() returned an error: %+v"
,
err
)
}
...
...
@@ -242,7 +240,7 @@ func TestManager_transmitSingleUse_RoundTimeoutError(t *testing.T) {
select
{
case
results
:=
<-
callbackChan
:
if
results
.
payload
!=
nil
||
!
check
(
results
.
err
,
"
round failures
"
)
{
if
results
.
payload
!=
nil
||
!
check
(
results
.
err
,
"
timed out
"
)
{
t
.
Errorf
(
"Callback did not return the correct error when it "
+
"should have timed out.
\n
payload: %+v
\n
error: %+v"
,
results
.
payload
,
results
.
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