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
7117e876
Commit
7117e876
authored
3 years ago
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Fix getRoundResults tests
parent
c0c0333b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!510
Release
,
!207
WIP: Client Restructure
,
!203
Symmetric broadcast
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
network/results_test.go
+50
-45
50 additions, 45 deletions
network/results_test.go
network/utils_test.go
+113
-0
113 additions, 0 deletions
network/utils_test.go
with
163 additions
and
45 deletions
network/results_test.go
+
50
−
45
View file @
7117e876
...
@@ -7,7 +7,6 @@
...
@@ -7,7 +7,6 @@
package
network
package
network
import
(
import
(
"gitlab.com/elixxir/client/api"
pb
"gitlab.com/elixxir/comms/mixmessages"
pb
"gitlab.com/elixxir/comms/mixmessages"
ds
"gitlab.com/elixxir/comms/network/dataStructures"
ds
"gitlab.com/elixxir/comms/network/dataStructures"
"gitlab.com/elixxir/primitives/states"
"gitlab.com/elixxir/primitives/states"
...
@@ -26,34 +25,40 @@ func TestClient_GetRoundResults(t *testing.T) {
...
@@ -26,34 +25,40 @@ func TestClient_GetRoundResults(t *testing.T) {
roundList
=
append
(
roundList
,
id
.
Round
(
i
))
roundList
=
append
(
roundList
,
id
.
Round
(
i
))
}
}
// Pre-populate the results channel with successful rounds
testTopology
:=
[][]
byte
{
id
.
NewIdFromUInt
(
1
,
id
.
Node
,
t
)
.
Bytes
(),
id
.
NewIdFromUInt
(
2
,
id
.
Node
,
t
)
.
Bytes
(),
id
.
NewIdFromUInt
(
3
,
id
.
Node
,
t
)
.
Bytes
(),
id
.
NewIdFromUInt
(
4
,
id
.
Node
,
t
)
.
Bytes
(),
}
// Pre-populate the results channel with successful round
sendResults
:=
make
(
chan
ds
.
EventReturn
,
len
(
roundList
))
sendResults
:=
make
(
chan
ds
.
EventReturn
,
len
(
roundList
))
for
i
:=
0
;
i
<
numRounds
;
i
++
{
for
i
:=
0
;
i
<
numRounds
;
i
++
{
sendResults
<-
ds
.
EventReturn
{
sendResults
<-
ds
.
EventReturn
{
RoundInfo
:
&
pb
.
RoundInfo
{
RoundInfo
:
&
pb
.
RoundInfo
{
ID
:
uint64
(
i
),
ID
:
uint64
(
i
),
State
:
uint32
(
states
.
COMPLETED
),
State
:
uint32
(
states
.
COMPLETED
),
Topology
:
testTopology
,
},
},
TimedOut
:
false
,
TimedOut
:
false
,
}
}
}
}
// Create a new copy of the test client for this test
m
,
err
:=
newTestManager
(
t
)
client
,
err
:=
api
.
newTestingClient
(
t
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Failed in setup: %
+
v"
,
err
)
t
.
Fatalf
(
"Failed in setup: %v"
,
err
)
}
}
// Construct the round call back function signature
// Construct the round call back function signature
var
successfulRounds
,
timeout
bool
var
successfulRounds
,
timeout
bool
receivedRCB
:=
func
(
allRoundsSucceeded
,
timedOut
bool
,
rounds
map
[
id
.
Round
]
Round
LookupStatus
)
{
receivedRCB
:=
func
(
allRoundsSucceeded
,
timedOut
bool
,
rounds
map
[
id
.
Round
]
Round
Result
)
{
successfulRounds
=
allRoundsSucceeded
successfulRounds
=
allRoundsSucceeded
timeout
=
timedOut
timeout
=
timedOut
}
}
// Call the round results
// Call the round results
err
=
client
.
getRoundResults
(
roundList
,
time
.
Duration
(
10
)
*
time
.
Millisecond
,
err
=
m
.
getRoundResults
(
roundList
,
time
.
Duration
(
10
)
*
time
.
Millisecond
,
receivedRCB
,
sendResults
,
api
.
NewNoHistoricalRoundsComm
()
)
receivedRCB
,
sendResults
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Error in happy path: %v"
,
err
)
t
.
Errorf
(
"Error in happy path: %v"
,
err
)
}
}
...
@@ -82,14 +87,21 @@ func TestClient_GetRoundResults_FailedRounds(t *testing.T) {
...
@@ -82,14 +87,21 @@ func TestClient_GetRoundResults_FailedRounds(t *testing.T) {
roundList
=
append
(
roundList
,
id
.
Round
(
i
))
roundList
=
append
(
roundList
,
id
.
Round
(
i
))
}
}
testTopology
:=
[][]
byte
{
id
.
NewIdFromUInt
(
1
,
id
.
Node
,
t
)
.
Bytes
(),
id
.
NewIdFromUInt
(
2
,
id
.
Node
,
t
)
.
Bytes
(),
id
.
NewIdFromUInt
(
3
,
id
.
Node
,
t
)
.
Bytes
(),
id
.
NewIdFromUInt
(
4
,
id
.
Node
,
t
)
.
Bytes
(),
}
// Pre-populate the results channel with mostly successful rounds
// Pre-populate the results channel with mostly successful rounds
sendResults
:=
make
(
chan
ds
.
EventReturn
,
len
(
roundList
))
sendResults
:=
make
(
chan
ds
.
EventReturn
,
len
(
roundList
))
for
i
:=
0
;
i
<
numRounds
;
i
++
{
for
i
:=
0
;
i
<
numRounds
;
i
++
{
// Last two rounds will have a failure and a timeout respectively
// Last two rounds will have a failure and a timeout respectively
result
:=
ds
.
EventReturn
{
result
:=
ds
.
EventReturn
{
RoundInfo
:
&
pb
.
RoundInfo
{
RoundInfo
:
&
pb
.
RoundInfo
{
ID
:
uint64
(
i
),
ID
:
uint64
(
i
),
State
:
uint32
(
states
.
COMPLETED
),
State
:
uint32
(
states
.
COMPLETED
),
Topology
:
testTopology
,
},
},
TimedOut
:
false
,
TimedOut
:
false
,
}
}
...
@@ -101,22 +113,22 @@ func TestClient_GetRoundResults_FailedRounds(t *testing.T) {
...
@@ -101,22 +113,22 @@ func TestClient_GetRoundResults_FailedRounds(t *testing.T) {
}
}
// Create a new copy of the test
client
for this test
// Create a new copy of the test
manager
for this test
client
,
err
:=
api
.
newTest
ingClient
(
t
)
m
,
err
:=
newTest
Manager
(
t
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Failed in setup: %v"
,
err
)
t
.
Fatalf
(
"Failed in setup: %v"
,
err
)
}
}
// Construct the round call back function signature
// Construct the round call back function signature
var
successfulRounds
,
timeout
bool
var
successfulRounds
,
timeout
bool
receivedRCB
:=
func
(
allRoundsSucceeded
,
timedOut
bool
,
rounds
map
[
id
.
Round
]
Round
LookupStatus
)
{
receivedRCB
:=
func
(
allRoundsSucceeded
,
timedOut
bool
,
rounds
map
[
id
.
Round
]
Round
Result
)
{
successfulRounds
=
allRoundsSucceeded
successfulRounds
=
allRoundsSucceeded
timeout
=
timedOut
timeout
=
timedOut
}
}
// Call the round results
// Call the round results
err
=
client
.
getRoundResults
(
roundList
,
time
.
Duration
(
10
)
*
time
.
Millisecond
,
err
=
m
.
getRoundResults
(
roundList
,
time
.
Duration
(
10
)
*
time
.
Millisecond
,
receivedRCB
,
sendResults
,
api
.
NewNoHistoricalRoundsComm
()
)
receivedRCB
,
sendResults
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Error in happy path: %v"
,
err
)
t
.
Errorf
(
"Error in happy path: %v"
,
err
)
}
}
...
@@ -141,54 +153,47 @@ func TestClient_GetRoundResults_HistoricalRounds(t *testing.T) {
...
@@ -141,54 +153,47 @@ func TestClient_GetRoundResults_HistoricalRounds(t *testing.T) {
roundList
=
append
(
roundList
,
id
.
Round
(
i
))
roundList
=
append
(
roundList
,
id
.
Round
(
i
))
}
}
testTopology
:=
[][]
byte
{
id
.
NewIdFromUInt
(
1
,
id
.
Node
,
t
)
.
Bytes
(),
id
.
NewIdFromUInt
(
2
,
id
.
Node
,
t
)
.
Bytes
(),
id
.
NewIdFromUInt
(
3
,
id
.
Node
,
t
)
.
Bytes
(),
id
.
NewIdFromUInt
(
4
,
id
.
Node
,
t
)
.
Bytes
(),
}
// Pre-populate the results channel with successful rounds
// Pre-populate the results channel with successful rounds
sendResults
:=
make
(
chan
ds
.
EventReturn
,
len
(
roundList
)
-
2
)
sendResults
:=
make
(
chan
ds
.
EventReturn
,
len
(
roundList
)
-
2
)
for
i
:=
0
;
i
<
numRounds
;
i
++
{
for
i
:=
0
;
i
<
numRounds
;
i
++
{
// Skip sending rounds intended for historical rounds comm
// Skip sending rounds intended for historical rounds comm
if
i
==
api
.
failedHistoricalRoundID
||
if
i
==
failedHistoricalRoundID
||
i
==
api
.
completedHistoricalRoundID
{
i
==
completedHistoricalRoundID
{
continue
continue
}
}
sendResults
<-
ds
.
EventReturn
{
sendResults
<-
ds
.
EventReturn
{
RoundInfo
:
&
pb
.
RoundInfo
{
RoundInfo
:
&
pb
.
RoundInfo
{
ID
:
uint64
(
i
),
ID
:
uint64
(
i
),
State
:
uint32
(
states
.
COMPLETED
),
State
:
uint32
(
states
.
COMPLETED
),
Topology
:
testTopology
,
},
},
TimedOut
:
false
,
TimedOut
:
false
,
}
}
}
}
// Create a new copy of the test
client
for this test
// Create a new copy of the test
manager
for this test
client
,
err
:=
api
.
newTest
ingClient
(
t
)
m
,
err
:=
newTest
Manager
(
t
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Failed in setup: %v"
,
err
)
t
.
Fatalf
(
"Failed in setup: %v"
,
err
)
}
}
// Overpopulate the round buffer, ensuring a circle back of the ring buffer
for
i
:=
1
;
i
<=
ds
.
RoundInfoBufLen
+
api
.
completedHistoricalRoundID
+
1
;
i
++
{
ri
:=
&
pb
.
RoundInfo
{
ID
:
uint64
(
i
)}
if
err
=
api
.
signRoundInfo
(
ri
);
err
!=
nil
{
t
.
Errorf
(
"Failed to sign round in set up: %v"
,
err
)
}
_
,
err
=
client
.
network
.
GetInstance
()
.
RoundUpdate
(
ri
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to upsert round in set up: %v"
,
err
)
}
}
// Construct the round call back function signature
// Construct the round call back function signature
var
successfulRounds
,
timeout
bool
var
successfulRounds
,
timeout
bool
receivedRCB
:=
func
(
allRoundsSucceeded
,
timedOut
bool
,
rounds
map
[
id
.
Round
]
Round
LookupStatus
)
{
receivedRCB
:=
func
(
allRoundsSucceeded
,
timedOut
bool
,
rounds
map
[
id
.
Round
]
Round
Result
)
{
successfulRounds
=
allRoundsSucceeded
successfulRounds
=
allRoundsSucceeded
timeout
=
timedOut
timeout
=
timedOut
}
}
// Call the round results
// Call the round results
err
=
client
.
getRoundResults
(
roundList
,
time
.
Duration
(
10
)
*
time
.
Millisecond
,
err
=
m
.
getRoundResults
(
roundList
,
time
.
Duration
(
10
)
*
time
.
Millisecond
,
receivedRCB
,
sendResults
,
api
.
NewHistoricalRoundsComm
()
)
receivedRCB
,
sendResults
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Error in happy path: %v"
,
err
)
t
.
Errorf
(
"Error in happy path: %v"
,
err
)
}
}
...
@@ -217,22 +222,22 @@ func TestClient_GetRoundResults_Timeout(t *testing.T) {
...
@@ -217,22 +222,22 @@ func TestClient_GetRoundResults_Timeout(t *testing.T) {
var
sendResults
chan
ds
.
EventReturn
var
sendResults
chan
ds
.
EventReturn
sendResults
=
nil
sendResults
=
nil
// Create a new copy of the test
client
for this test
// Create a new copy of the test
manager
for this test
client
,
err
:=
api
.
newTest
ingClient
(
t
)
m
,
err
:=
newTest
Manager
(
t
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Failed in setup: %v"
,
err
)
t
.
Fatalf
(
"Failed in setup: %v"
,
err
)
}
}
// Construct the round call back function signature
// Construct the round call back function signature
var
successfulRounds
,
timeout
bool
var
successfulRounds
,
timeout
bool
receivedRCB
:=
func
(
allRoundsSucceeded
,
timedOut
bool
,
rounds
map
[
id
.
Round
]
Round
LookupStatus
)
{
receivedRCB
:=
func
(
allRoundsSucceeded
,
timedOut
bool
,
rounds
map
[
id
.
Round
]
Round
Result
)
{
successfulRounds
=
allRoundsSucceeded
successfulRounds
=
allRoundsSucceeded
timeout
=
timedOut
timeout
=
timedOut
}
}
// Call the round results
// Call the round results
err
=
client
.
getRoundResults
(
roundList
,
time
.
Duration
(
10
)
*
time
.
Millisecond
,
err
=
m
.
getRoundResults
(
roundList
,
time
.
Duration
(
10
)
*
time
.
Millisecond
,
receivedRCB
,
sendResults
,
api
.
NewNoHistoricalRoundsComm
()
)
receivedRCB
,
sendResults
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Error in happy path: %v"
,
err
)
t
.
Errorf
(
"Error in happy path: %v"
,
err
)
}
}
...
...
This diff is collapsed.
Click to expand it.
network/utils_test.go
0 → 100644
+
113
−
0
View file @
7117e876
///////////////////////////////////////////////////////////////////////////////
// Copyright © 2020 xx network SEZC //
// //
// Use of this source code is governed by a license that can be found in the //
// LICENSE file //
///////////////////////////////////////////////////////////////////////////////
package
network
import
(
"gitlab.com/elixxir/client/storage"
"gitlab.com/elixxir/comms/client"
commsNetwork
"gitlab.com/elixxir/comms/network"
"gitlab.com/elixxir/crypto/fastRNG"
"gitlab.com/xx_network/comms/connect"
"gitlab.com/xx_network/crypto/csprng"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/ndf"
"testing"
)
func
newTestManager
(
t
*
testing
.
T
)
(
*
manager
,
error
)
{
commsManager
:=
connect
.
NewManagerTesting
(
t
)
instanceComms
:=
&
connect
.
ProtoComms
{
Manager
:
commsManager
,
}
thisInstance
,
err
:=
commsNetwork
.
NewInstanceTesting
(
instanceComms
,
getNDF
(),
getNDF
(),
nil
,
nil
,
t
)
if
err
!=
nil
{
return
nil
,
err
}
comms
,
err
:=
client
.
NewClientComms
(
id
.
NewIdFromUInt
(
100
,
id
.
User
,
t
),
nil
,
nil
,
nil
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
m
:=
&
manager
{
session
:
storage
.
InitTestingSession
(
t
),
rng
:
fastRNG
.
NewStreamGenerator
(
1000
,
10
,
csprng
.
NewSystemRNG
),
comms
:
comms
,
instance
:
thisInstance
,
param
:
GetDefaultParams
(),
// todo: for other tests, these may need to be initialized with test values.
// That explodes this setup function massively, may need a different setup
// function for each embedded interface?
Sender
:
nil
,
Handler
:
nil
,
Registrar
:
nil
,
Retriever
:
nil
,
Pickup
:
nil
,
Space
:
nil
,
Tracker
:
nil
,
Monitor
:
nil
,
crit
:
nil
,
earliestRound
:
nil
,
tracker
:
nil
,
latencySum
:
0
,
numLatencies
:
0
,
verboseRounds
:
nil
,
events
:
nil
,
maxMsgLen
:
0
,
}
return
m
,
nil
}
// Constructs a mock ndf
func
getNDF
()
*
ndf
.
NetworkDefinition
{
return
&
ndf
.
NetworkDefinition
{
E2E
:
ndf
.
Group
{
Prime
:
"E2EE983D031DC1DB6F1A7A67DF0E9A8E5561DB8E8D49413394C049B"
+
"7A8ACCEDC298708F121951D9CF920EC5D146727AA4AE535B0922C688B55B3DD2AE"
+
"DF6C01C94764DAB937935AA83BE36E67760713AB44A6337C20E7861575E745D31F"
+
"8B9E9AD8412118C62A3E2E29DF46B0864D0C951C394A5CBBDC6ADC718DD2A3E041"
+
"023DBB5AB23EBB4742DE9C1687B5B34FA48C3521632C4A530E8FFB1BC51DADDF45"
+
"3B0B2717C2BC6669ED76B4BDD5C9FF558E88F26E5785302BEDBCA23EAC5ACE9209"
+
"6EE8A60642FB61E8F3D24990B8CB12EE448EEF78E184C7242DD161C7738F32BF29"
+
"A841698978825B4111B4BC3E1E198455095958333D776D8B2BEEED3A1A1A221A6E"
+
"37E664A64B83981C46FFDDC1A45E3D5211AAF8BFBC072768C4F50D7D7803D2D4F2"
+
"78DE8014A47323631D7E064DE81C0C6BFA43EF0E6998860F1390B5D3FEACAF1696"
+
"015CB79C3F9C2D93D961120CD0E5F12CBB687EAB045241F96789C38E89D796138E"
+
"6319BE62E35D87B1048CA28BE389B575E994DCA755471584A09EC723742DC35873"
+
"847AEF49F66E43873"
,
Generator
:
"2"
,
},
CMIX
:
ndf
.
Group
{
Prime
:
"9DB6FB5951B66BB6FE1E140F1D2CE5502374161FD6538DF1648218642F0B5C48"
+
"C8F7A41AADFA187324B87674FA1822B00F1ECF8136943D7C55757264E5A1A44F"
+
"FE012E9936E00C1D3E9310B01C7D179805D3058B2A9F4BB6F9716BFE6117C6B5"
+
"B3CC4D9BE341104AD4A80AD6C94E005F4B993E14F091EB51743BF33050C38DE2"
+
"35567E1B34C3D6A5C0CEAA1A0F368213C3D19843D0B4B09DCB9FC72D39C8DE41"
+
"F1BF14D4BB4563CA28371621CAD3324B6A2D392145BEBFAC748805236F5CA2FE"
+
"92B871CD8F9C36D3292B5509CA8CAA77A2ADFC7BFD77DDA6F71125A7456FEA15"
+
"3E433256A2261C6A06ED3693797E7995FAD5AABBCFBE3EDA2741E375404AE25B"
,
Generator
:
"5C7FF6B06F8F143FE8288433493E4769C4D988ACE5BE25A0E24809670716C613"
+
"D7B0CEE6932F8FAA7C44D2CB24523DA53FBE4F6EC3595892D1AA58C4328A06C4"
+
"6A15662E7EAA703A1DECF8BBB2D05DBE2EB956C142A338661D10461C0D135472"
+
"085057F3494309FFA73C611F78B32ADBB5740C361C9F35BE90997DB2014E2EF5"
+
"AA61782F52ABEB8BD6432C4DD097BC5423B285DAFB60DC364E8161F4A2A35ACA"
+
"3A10B1C4D203CC76A470A33AFDCBDD92959859ABD8B56E1725252D78EAC66E71"
+
"BA9AE3F1DD2487199874393CD4D832186800654760E1E34C09E4D155179F9EC0"
+
"DC4473F996BDCE6EED1CABED8B6F116F7AD9CF505DF0F998E34AB27514B0FFE7"
,
},
Registration
:
ndf
.
Registration
{
EllipticPubKey
:
"/WRtT+mDZGC3FXQbvuQgfqOonAjJ47IKE0zhaGTQQ70="
,
},
}
}
// Round IDs to return on mock historicalRounds comm
const
failedHistoricalRoundID
=
7
const
completedHistoricalRoundID
=
8
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