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
eb3f085a
Commit
eb3f085a
authored
4 years ago
by
Richard T. Carback III
Browse files
Options
Downloads
Plain Diff
Merge branch 'release' of gitlab.com:elixxir/client into release
parents
a62c96d8
1b032cd1
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
network/rounds/processingRounds_test.go
+30
-25
30 additions, 25 deletions
network/rounds/processingRounds_test.go
with
30 additions
and
25 deletions
network/rounds/processingRounds_test.go
+
30
−
25
View file @
eb3f085a
...
...
@@ -7,9 +7,15 @@
package
rounds
import
(
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id/ephemeral"
"reflect"
"testing"
)
// Testing functions for Processing Round structure
/*
// Tests happy path of newProcessingRounds.
func
Test_newProcessingRounds
(
t
*
testing
.
T
)
{
expectedPr
:=
&
processing
{
...
...
@@ -33,28 +39,27 @@ func TestProcessing_Process(t *testing.T) {
testData
:=
[]
struct
{
rid
id
.
Round
processing bool
change bool
status
Status
count
uint
}{
{10,
true, true
, 0},
{10,
true, false
, 0},
{10,
false, true
, 0},
{100,
true, true
, 0},
{100,
true, false
, 0},
{100,
false, true
, 0},
{
10
,
NotProcessing
,
0
},
{
10
,
NotProcessing
,
0
},
{
10
,
Processing
,
0
},
{
100
,
NotProcessing
,
0
},
{
100
,
NotProcessing
,
0
},
{
100
,
Processing
,
0
},
}
for
i
,
d
:=
range
testData
{
hid
:=
makeHashID
(
d
.
rid
,
ephID
,
source
)
if
_
,
exists
:=
pr
.
rounds
[
hid
];
exists
{
pr.rounds[hid].
processing = d.processing
pr
.
rounds
[
hid
]
.
Status
=
d
.
status
}
change, _
, count := pr.Process(d.rid, ephID, source)
if
change != d.change
{
status
,
count
:=
pr
.
Process
(
d
.
rid
,
ephID
,
source
)
if
status
!=
d
.
status
{
t
.
Errorf
(
"Process() did not return the correct boolean for round "
+
"ID %d (%d).\n
\t
expected: %
v
\n
\t
recieved: %
v
",
d.rid, i, d.
change, change
)
"ID %d (%d).
\n
expected: %
s
\n
recieved: %
s
"
,
d
.
rid
,
i
,
d
.
status
,
status
)
}
if
count
!=
d
.
count
{
t
.
Errorf
(
"Process did not return the expected count for round ID "
+
...
...
@@ -77,13 +82,13 @@ func TestProcessing_IsProcessing(t *testing.T) {
source
:=
&
id
.
ID
{}
rid
:=
id
.
Round
(
10
)
hid
:=
makeHashID
(
rid
,
ephID
,
source
)
pr.rounds[hid] = &status{0,
true, false
}
pr
.
rounds
[
hid
]
=
&
status
{
0
,
Processing
}
if
!
pr
.
IsProcessing
(
rid
,
ephID
,
source
)
{
t.Errorf("IsProcessing() should have returned
true
for round ID %d.", rid)
t
.
Errorf
(
"IsProcessing() should have returned
%s
for round ID %d."
,
Processing
,
rid
)
}
pr.rounds[hid].
p
rocessing
= false
pr
.
rounds
[
hid
]
.
Status
=
NotP
rocessing
if
pr
.
IsProcessing
(
rid
,
ephID
,
source
)
{
t.Errorf("IsProcessing() should have returned
false
for round ID %d.", rid)
t
.
Errorf
(
"IsProcessing() should have returned
%s
for round ID %d."
,
NotProcessing
,
rid
)
}
}
...
...
@@ -94,9 +99,9 @@ func TestProcessing_Fail(t *testing.T) {
ephID
:=
ephemeral
.
Id
{}
source
:=
&
id
.
ID
{}
hid
:=
makeHashID
(
rid
,
ephID
,
source
)
pr.rounds[hid] = &status{0,
true, false
}
pr
.
rounds
[
hid
]
=
&
status
{
0
,
Processing
}
pr
.
Fail
(
rid
,
ephID
,
source
)
if pr.rounds[hid].
p
rocessing {
if
pr
.
rounds
[
hid
]
.
Status
==
P
rocessing
{
t
.
Errorf
(
"Fail() did not mark processing as false for round id %d."
,
rid
)
}
if
pr
.
rounds
[
hid
]
.
failCount
!=
1
{
...
...
@@ -111,9 +116,9 @@ func TestProcessing_Done(t *testing.T) {
ephID
:=
ephemeral
.
Id
{}
source
:=
&
id
.
ID
{}
hid
:=
makeHashID
(
rid
,
ephID
,
source
)
pr.rounds[hid] = &status{0,
true, false
}
pr
.
rounds
[
hid
]
=
&
status
{
0
,
Processing
}
pr
.
Done
(
rid
,
ephID
,
source
)
if s, _ := pr.rounds[hid];
!
s.
d
one {
if
s
,
_
:=
pr
.
rounds
[
hid
];
s
.
Status
!=
D
one
{
t
.
Errorf
(
"Done() failed to flag round ID %d."
,
rid
)
}
}
*/
}
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