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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
a48993c9
Commit
a48993c9
authored
Jan 28, 2022
by
Jake Taylor
Browse files
Options
Downloads
Plain Diff
Merge branch 'release' into hotfix/GetRoundResultsFix
parents
7e379978
62141ddd
No related branches found
No related tags found
2 merge requests
!170
Release
,
!144
attempt to fix GetRoundResults by making the follower only send one RoundEvent...
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
single/transmission.go
+4
-37
4 additions, 37 deletions
single/transmission.go
single/transmission_test.go
+9
-11
9 additions, 11 deletions
single/transmission_test.go
with
13 additions
and
48 deletions
single/transmission.go
+
4
−
37
View file @
a48993c9
...
@@ -13,7 +13,6 @@ import (
...
@@ -13,7 +13,6 @@ import (
jww
"github.com/spf13/jwalterweatherman"
jww
"github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/interfaces"
"gitlab.com/elixxir/client/interfaces"
"gitlab.com/elixxir/client/interfaces/params"
"gitlab.com/elixxir/client/interfaces/params"
"gitlab.com/elixxir/client/interfaces/utility"
"gitlab.com/elixxir/client/storage/reception"
"gitlab.com/elixxir/client/storage/reception"
ds
"gitlab.com/elixxir/comms/network/dataStructures"
ds
"gitlab.com/elixxir/comms/network/dataStructures"
contact2
"gitlab.com/elixxir/crypto/contact"
contact2
"gitlab.com/elixxir/crypto/contact"
...
@@ -51,8 +50,7 @@ func (m *Manager) TransmitSingleUse(partner contact2.Contact, payload []byte,
...
@@ -51,8 +50,7 @@ func (m *Manager) TransmitSingleUse(partner contact2.Contact, payload []byte,
rngReader
:=
m
.
rng
.
GetStream
()
rngReader
:=
m
.
rng
.
GetStream
()
defer
rngReader
.
Close
()
defer
rngReader
.
Close
()
return
m
.
transmitSingleUse
(
partner
,
payload
,
tag
,
maxMsgs
,
rngReader
,
return
m
.
transmitSingleUse
(
partner
,
payload
,
tag
,
maxMsgs
,
rngReader
,
callback
,
timeout
)
callback
,
timeout
,
m
.
net
.
GetInstance
()
.
GetRoundEvents
())
}
}
// roundEvents interface allows custom round events to be passed in for testing.
// roundEvents interface allows custom round events to be passed in for testing.
...
@@ -63,7 +61,7 @@ type roundEvents interface {
...
@@ -63,7 +61,7 @@ type roundEvents interface {
// transmitSingleUse has the fields passed in for easier testing.
// transmitSingleUse has the fields passed in for easier testing.
func
(
m
*
Manager
)
transmitSingleUse
(
partner
contact2
.
Contact
,
payload
[]
byte
,
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
// Get ephemeral ID address space size; this blocks until the address space
// size is set for the first time
// size is set for the first time
...
@@ -123,7 +121,7 @@ func (m *Manager) transmitSingleUse(partner contact2.Contact, payload []byte,
...
@@ -123,7 +121,7 @@ func (m *Manager) transmitSingleUse(partner contact2.Contact, payload []byte,
if
err
!=
nil
{
if
err
!=
nil
{
errorString
:=
fmt
.
Sprintf
(
"failed to send single-use transmission "
+
errorString
:=
fmt
.
Sprintf
(
"failed to send single-use transmission "
+
"CMIX message: %+v"
,
err
)
"CMIX message: %+v"
,
err
)
jww
.
ERROR
.
Print
(
errorString
)
jww
.
ERROR
.
Print
f
(
errorString
)
// Exit the state timeout handler, delete the state from map, and
// Exit the state timeout handler, delete the state from map, and
// return an error on the callback
// return an error on the callback
...
@@ -140,40 +138,9 @@ func (m *Manager) transmitSingleUse(partner contact2.Contact, payload []byte,
...
@@ -140,40 +138,9 @@ func (m *Manager) transmitSingleUse(partner contact2.Contact, payload []byte,
"message because the timeout handler quit."
)
"message because the timeout handler quit."
)
return
return
}
}
jww
.
DEBUG
.
Printf
(
"Sent single-use transmission CMIX "
+
// Update the timeout for the elapsed time
roundEventTimeout
:=
timeout
-
netTime
.
Since
(
timeStart
)
-
time
.
Millisecond
// Check message delivery
sendResults
:=
make
(
chan
ds
.
EventReturn
,
1
)
roundEvents
.
AddRoundEventChan
(
round
,
sendResults
,
roundEventTimeout
,
states
.
COMPLETED
,
states
.
FAILED
)
im
:=
fmt
.
Sprintf
(
"Sent single-use transmission CMIX "
+
"message to %s and ephemeral ID %d on round %d."
,
"message to %s and ephemeral ID %d on round %d."
,
partner
.
ID
,
ephID
.
Int64
(),
round
)
partner
.
ID
,
ephID
.
Int64
(),
round
)
jww
.
DEBUG
.
Print
(
im
)
if
m
.
client
!=
nil
{
m
.
client
.
ReportEvent
(
1
,
"SingleUse"
,
"MessageSend"
,
im
)
}
// Wait until the result tracking responds
success
,
numRoundFail
,
numTimeOut
:=
utility
.
TrackResults
(
sendResults
,
1
)
if
!
success
{
errorString
:=
fmt
.
Sprintf
(
"failed to send single-use transmission "
+
"message: %d round failures, %d round event time outs."
,
numRoundFail
,
numTimeOut
)
jww
.
ERROR
.
Print
(
errorString
)
// Exit the state timeout handler, delete the state from map, and
// return an error on the callback
quitChan
<-
struct
{}{}
m
.
p
.
Lock
()
delete
(
m
.
p
.
singleUse
,
*
rid
)
m
.
p
.
Unlock
()
go
callback
(
nil
,
errors
.
New
(
errorString
))
}
jww
.
DEBUG
.
Print
(
"Tracked single-use transmission message round."
)
}()
}()
return
nil
return
nil
...
...
This diff is collapsed.
Click to expand it.
single/transmission_test.go
+
9
−
11
View file @
a48993c9
...
@@ -50,8 +50,7 @@ func TestManager_transmitSingleUse(t *testing.T) {
...
@@ -50,8 +50,7 @@ func TestManager_transmitSingleUse(t *testing.T) {
callback
,
callbackChan
:=
createReplyComm
()
callback
,
callbackChan
:=
createReplyComm
()
timeout
:=
15
*
time
.
Millisecond
timeout
:=
15
*
time
.
Millisecond
err
:=
m
.
transmitSingleUse
(
partner
,
payload
,
tag
,
maxMsgs
,
prng
,
err
:=
m
.
transmitSingleUse
(
partner
,
payload
,
tag
,
maxMsgs
,
prng
,
callback
,
timeout
)
callback
,
timeout
,
newTestRoundEvents
(
false
))
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"transmitSingleUse() returned an error: %+v"
,
err
)
t
.
Errorf
(
"transmitSingleUse() returned an error: %+v"
,
err
)
}
}
...
@@ -93,7 +92,7 @@ func TestManager_transmitSingleUse_QuitChanError(t *testing.T) {
...
@@ -93,7 +92,7 @@ func TestManager_transmitSingleUse_QuitChanError(t *testing.T) {
timeout
:=
15
*
time
.
Millisecond
timeout
:=
15
*
time
.
Millisecond
err
:=
m
.
transmitSingleUse
(
partner
,
[]
byte
{},
"testTag"
,
9
,
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
{
if
err
!=
nil
{
t
.
Errorf
(
"transmitSingleUse() returned an error: %+v"
,
err
)
t
.
Errorf
(
"transmitSingleUse() returned an error: %+v"
,
err
)
}
}
...
@@ -125,7 +124,7 @@ func TestManager_transmitSingleUse_AddIdentityError(t *testing.T) {
...
@@ -125,7 +124,7 @@ func TestManager_transmitSingleUse_AddIdentityError(t *testing.T) {
callback
,
callbackChan
:=
createReplyComm
()
callback
,
callbackChan
:=
createReplyComm
()
err
:=
m
.
transmitSingleUse
(
partner
,
[]
byte
{},
"testTag"
,
9
,
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
{
if
err
!=
nil
{
t
.
Errorf
(
"transmitSingleUse() returned an error: %+v"
,
err
)
t
.
Errorf
(
"transmitSingleUse() returned an error: %+v"
,
err
)
}
}
...
@@ -158,7 +157,7 @@ func TestManager_transmitSingleUse_SendCMIXError(t *testing.T) {
...
@@ -158,7 +157,7 @@ func TestManager_transmitSingleUse_SendCMIXError(t *testing.T) {
timeout
:=
15
*
time
.
Millisecond
timeout
:=
15
*
time
.
Millisecond
err
:=
m
.
transmitSingleUse
(
partner
,
[]
byte
{},
"testTag"
,
9
,
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
{
if
err
!=
nil
{
t
.
Errorf
(
"transmitSingleUse() returned an error: %+v"
,
err
)
t
.
Errorf
(
"transmitSingleUse() returned an error: %+v"
,
err
)
}
}
...
@@ -182,7 +181,7 @@ func TestManager_transmitSingleUse_MakeTransmitCmixMessageError(t *testing.T) {
...
@@ -182,7 +181,7 @@ func TestManager_transmitSingleUse_MakeTransmitCmixMessageError(t *testing.T) {
prng
:=
rand
.
New
(
rand
.
NewSource
(
42
))
prng
:=
rand
.
New
(
rand
.
NewSource
(
42
))
payload
:=
make
([]
byte
,
m
.
store
.
Cmix
()
.
GetGroup
()
.
GetP
()
.
ByteLen
())
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
{
if
err
==
nil
{
t
.
Error
(
"transmitSingleUse() did not return an error when the payload "
+
t
.
Error
(
"transmitSingleUse() did not return an error when the payload "
+
"is too large."
)
"is too large."
)
...
@@ -212,7 +211,7 @@ func TestManager_transmitSingleUse_AddStateError(t *testing.T) {
...
@@ -212,7 +211,7 @@ func TestManager_transmitSingleUse_AddStateError(t *testing.T) {
m
.
p
.
singleUse
[
*
rid
]
=
newState
(
dhKey
,
maxMsgs
,
nil
)
m
.
p
.
singleUse
[
*
rid
]
=
newState
(
dhKey
,
maxMsgs
,
nil
)
err
=
m
.
transmitSingleUse
(
partner
,
payload
,
tag
,
maxMsgs
,
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"
)
{
if
!
check
(
err
,
"failed to add pending state"
)
{
t
.
Errorf
(
"transmitSingleUse() failed to error when on adding state "
+
t
.
Errorf
(
"transmitSingleUse() failed to error when on adding state "
+
"when the state already exists: %+v"
,
err
)
"when the state already exists: %+v"
,
err
)
...
@@ -232,8 +231,7 @@ func TestManager_transmitSingleUse_RoundTimeoutError(t *testing.T) {
...
@@ -232,8 +231,7 @@ func TestManager_transmitSingleUse_RoundTimeoutError(t *testing.T) {
callback
,
callbackChan
:=
createReplyComm
()
callback
,
callbackChan
:=
createReplyComm
()
timeout
:=
15
*
time
.
Millisecond
timeout
:=
15
*
time
.
Millisecond
err
:=
m
.
transmitSingleUse
(
partner
,
payload
,
"testTag"
,
8
,
prng
,
callback
,
err
:=
m
.
transmitSingleUse
(
partner
,
payload
,
"testTag"
,
8
,
prng
,
callback
,
timeout
)
timeout
,
newTestRoundEvents
(
true
))
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"transmitSingleUse() returned an error: %+v"
,
err
)
t
.
Errorf
(
"transmitSingleUse() returned an error: %+v"
,
err
)
}
}
...
@@ -242,7 +240,7 @@ func TestManager_transmitSingleUse_RoundTimeoutError(t *testing.T) {
...
@@ -242,7 +240,7 @@ func TestManager_transmitSingleUse_RoundTimeoutError(t *testing.T) {
select
{
select
{
case
results
:=
<-
callbackChan
:
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 "
+
t
.
Errorf
(
"Callback did not return the correct error when it "
+
"should have timed out.
\n
payload: %+v
\n
error: %+v"
,
"should have timed out.
\n
payload: %+v
\n
error: %+v"
,
results
.
payload
,
results
.
err
)
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