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
2e912b88
Commit
2e912b88
authored
Feb 18, 2021
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Fixed tests for changes in RoundEventCallback
parent
cf5e47e3
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/messages_test.go
+37
-12
37 additions, 12 deletions
api/messages_test.go
api/utilsInterfaces_test.go
+0
-21
0 additions, 21 deletions
api/utilsInterfaces_test.go
with
37 additions
and
33 deletions
api/messages_test.go
+
37
−
12
View file @
2e912b88
...
...
@@ -43,8 +43,14 @@ func TestClient_GetRoundResults(t *testing.T) {
t
.
Errorf
(
"Failed in setup: %v"
,
err
)
}
// Construct the round call back function signature
var
successfulRounds
,
timeout
bool
receivedRCB
:=
func
(
allRoundsSucceeded
,
timedOut
bool
,
rounds
map
[
id
.
Round
]
RoundResult
)
{
successfulRounds
=
allRoundsSucceeded
timeout
=
timedOut
}
// Call the round results
receivedRCB
:=
NewMockRoundCB
()
err
=
client
.
getRoundResults
(
roundList
,
time
.
Duration
(
10
)
*
time
.
Millisecond
,
receivedRCB
,
sendResults
,
NewNoHistoricalRoundsComm
())
if
err
!=
nil
{
...
...
@@ -55,11 +61,11 @@ func TestClient_GetRoundResults(t *testing.T) {
time
.
Sleep
(
1
*
time
.
Second
)
// If any rounds timed out or any round failed, the happy path has failed
if
receivedRCB
.
time
dO
ut
||
!
receivedRCB
.
allRoundsSucceeded
{
if
time
o
ut
||
!
successfulRounds
{
t
.
Errorf
(
"Unexpected round failures in happy path. "
+
"Expected all rounds to succeed with no timeouts."
+
"
\n\t
TimedOut: %v"
+
"
\n\t
allRoundsSucceeded: %v"
,
receivedRCB
.
time
dO
ut
,
receivedRCB
.
allRoundsSucceeded
)
"
\n\t
allRoundsSucceeded: %v"
,
time
o
ut
,
successfulRounds
)
}
}
...
...
@@ -100,8 +106,14 @@ func TestClient_GetRoundResults_FailedRounds(t *testing.T) {
t
.
Errorf
(
"Failed in setup: %v"
,
err
)
}
// Construct the round call back function signature
var
successfulRounds
,
timeout
bool
receivedRCB
:=
func
(
allRoundsSucceeded
,
timedOut
bool
,
rounds
map
[
id
.
Round
]
RoundResult
)
{
successfulRounds
=
allRoundsSucceeded
timeout
=
timedOut
}
// Call the round results
receivedRCB
:=
NewMockRoundCB
()
err
=
client
.
getRoundResults
(
roundList
,
time
.
Duration
(
10
)
*
time
.
Millisecond
,
receivedRCB
,
sendResults
,
NewNoHistoricalRoundsComm
())
if
err
!=
nil
{
...
...
@@ -112,10 +124,10 @@ func TestClient_GetRoundResults_FailedRounds(t *testing.T) {
time
.
Sleep
(
2
*
time
.
Second
)
// If no rounds have failed, this test has failed
if
receivedRCB
.
allRoundsSucceeded
{
if
successfulRounds
{
t
.
Errorf
(
"Expected some rounds to fail. "
+
"
\n\t
TimedOut: %v"
+
"
\n\t
allRoundsSucceeded: %v"
,
receivedRCB
.
time
dO
ut
,
receivedRCB
.
allRoundsSucceeded
)
"
\n\t
allRoundsSucceeded: %v"
,
time
o
ut
,
successfulRounds
)
}
}
...
...
@@ -166,8 +178,14 @@ func TestClient_GetRoundResults_HistoricalRounds(t *testing.T) {
}
// Construct the round call back function signature
var
successfulRounds
,
timeout
bool
receivedRCB
:=
func
(
allRoundsSucceeded
,
timedOut
bool
,
rounds
map
[
id
.
Round
]
RoundResult
)
{
successfulRounds
=
allRoundsSucceeded
timeout
=
timedOut
}
// Call the round results
receivedRCB
:=
NewMockRoundCB
()
err
=
client
.
getRoundResults
(
roundList
,
time
.
Duration
(
10
)
*
time
.
Millisecond
,
receivedRCB
,
sendResults
,
NewHistoricalRoundsComm
())
if
err
!=
nil
{
...
...
@@ -178,10 +196,10 @@ func TestClient_GetRoundResults_HistoricalRounds(t *testing.T) {
time
.
Sleep
(
2
*
time
.
Second
)
// If no round failed, this test has failed
if
receivedRCB
.
allRoundsSucceeded
{
if
successfulRounds
{
t
.
Errorf
(
"Expected historical rounds to have round failures"
+
"
\n\t
TimedOut: %v"
+
"
\n\t
allRoundsSucceeded: %v"
,
receivedRCB
.
time
dO
ut
,
receivedRCB
.
allRoundsSucceeded
)
"
\n\t
allRoundsSucceeded: %v"
,
time
o
ut
,
successfulRounds
)
}
}
...
...
@@ -204,8 +222,14 @@ func TestClient_GetRoundResults_Timeout(t *testing.T) {
t
.
Errorf
(
"Failed in setup: %v"
,
err
)
}
// Construct the round call back function signature
var
successfulRounds
,
timeout
bool
receivedRCB
:=
func
(
allRoundsSucceeded
,
timedOut
bool
,
rounds
map
[
id
.
Round
]
RoundResult
)
{
successfulRounds
=
allRoundsSucceeded
timeout
=
timedOut
}
// Call the round results
receivedRCB
:=
NewMockRoundCB
()
err
=
client
.
getRoundResults
(
roundList
,
time
.
Duration
(
10
)
*
time
.
Millisecond
,
receivedRCB
,
sendResults
,
NewNoHistoricalRoundsComm
())
if
err
!=
nil
{
...
...
@@ -216,9 +240,10 @@ func TestClient_GetRoundResults_Timeout(t *testing.T) {
time
.
Sleep
(
2
*
time
.
Second
)
// If no rounds have timed out , this test has failed
if
!
receivedRCB
.
time
dO
ut
{
if
!
time
o
ut
{
t
.
Errorf
(
"Expected all rounds to timeout with no valid round reporter."
+
"
\n\t
TimedOut: %v"
,
receivedRCB
.
timedOut
)
"
\n\t
TimedOut: %v"
+
"
\n\t
allRoundsSucceeded: %v"
,
timeout
,
successfulRounds
)
}
}
This diff is collapsed.
Click to expand it.
api/utilsInterfaces_test.go
+
0
−
21
View file @
2e912b88
...
...
@@ -21,27 +21,6 @@ import (
"gitlab.com/xx_network/primitives/id/ephemeral"
)
// A mock structure which should conform to the callback for getRoundResults
type
mockRoundCallback
struct
{
allRoundsSucceeded
bool
timedOut
bool
rounds
map
[
id
.
Round
]
RoundResult
}
// Construction for mockRoundCallback
func
NewMockRoundCB
()
*
mockRoundCallback
{
return
&
mockRoundCallback
{}
}
// Report simply stores the passed in values in the structure
func
(
mrc
*
mockRoundCallback
)
Report
(
allRoundsSucceeded
,
timedOut
bool
,
rounds
map
[
id
.
Round
]
RoundResult
)
{
mrc
.
allRoundsSucceeded
=
allRoundsSucceeded
mrc
.
timedOut
=
timedOut
mrc
.
rounds
=
rounds
}
// Mock comm struct which returns no historical round data
type
noHistoricalRounds
struct
{}
...
...
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