Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
comms
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
comms
Commits
4c36bb47
Commit
4c36bb47
authored
4 years ago
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Implement and test GetOldestRoundID
parent
f8a4b975
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!58
Revert "Modify waiting lock"
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
network/dataStructures/roundData.go
+5
-0
5 additions, 0 deletions
network/dataStructures/roundData.go
network/instance.go
+5
-0
5 additions, 0 deletions
network/instance.go
network/instance_test.go
+43
-0
43 additions, 0 deletions
network/instance_test.go
with
53 additions
and
0 deletions
network/dataStructures/roundData.go
+
5
−
0
View file @
4c36bb47
...
@@ -57,3 +57,8 @@ func (d *Data) GetRound(id int) (*mixmessages.RoundInfo, error) {
...
@@ -57,3 +57,8 @@ func (d *Data) GetRound(id int) (*mixmessages.RoundInfo, error) {
func
(
d
*
Data
)
GetLastRoundID
()
id
.
Round
{
func
(
d
*
Data
)
GetLastRoundID
()
id
.
Round
{
return
id
.
Round
(
d
.
rounds
.
GetNewestId
())
return
id
.
Round
(
d
.
rounds
.
GetNewestId
())
}
}
// Gets the ID of the oldest roundd in the buffer
func
(
d
*
Data
)
GetOldestRoundID
()
id
.
Round
{
return
id
.
Round
(
d
.
rounds
.
GetOldestId
())
}
This diff is collapsed.
Click to expand it.
network/instance.go
+
5
−
0
View file @
4c36bb47
...
@@ -519,6 +519,11 @@ func (i *Instance) GetLastRoundID() id.Round {
...
@@ -519,6 +519,11 @@ func (i *Instance) GetLastRoundID() id.Round {
return
i
.
roundData
.
GetLastRoundID
()
-
1
return
i
.
roundData
.
GetLastRoundID
()
-
1
}
}
// Get the oldest round id
func
(
i
*
Instance
)
GetOldestRoundID
()
id
.
Round
{
return
i
.
roundData
.
GetOldestRoundID
()
}
// Update gateway hosts based on most complete ndf
// Update gateway hosts based on most complete ndf
func
(
i
*
Instance
)
UpdateGatewayConnections
()
error
{
func
(
i
*
Instance
)
UpdateGatewayConnections
()
error
{
if
i
.
full
!=
nil
{
if
i
.
full
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
network/instance_test.go
+
43
−
0
View file @
4c36bb47
...
@@ -316,6 +316,49 @@ func TestInstance_GetLastUpdateID(t *testing.T) {
...
@@ -316,6 +316,49 @@ func TestInstance_GetLastUpdateID(t *testing.T) {
i
.
GetLastUpdateID
()
i
.
GetLastUpdateID
()
}
}
func
TestInstance_GetOldestRoundID
(
t
*
testing
.
T
)
{
i
:=
Instance
{
roundData
:
ds
.
NewData
(),
}
expectedOldRound
:=
id
.
Round
(
0
)
_
=
i
.
roundData
.
UpsertRound
(
&
mixmessages
.
RoundInfo
{
ID
:
uint64
(
expectedOldRound
)})
_
=
i
.
roundData
.
UpsertRound
(
&
mixmessages
.
RoundInfo
{
ID
:
uint64
(
2
)})
returned
:=
i
.
GetOldestRoundID
()
if
returned
!=
expectedOldRound
{
t
.
Errorf
(
"Failed to get oldest round from buffer."
+
"
\n\t
Expected: %v"
+
"
\n\t
Received: %v"
,
expectedOldRound
,
returned
)
}
}
// Test which forces a full buffer, causing overwriting of old rounds
func
TestInstance_GetOldestRoundID_ManyRounds
(
t
*
testing
.
T
)
{
testInstance
:=
Instance
{
roundData
:
ds
.
NewData
(),
}
// Ensure a circle back in the round buffer
for
i
:=
1
;
i
<=
ds
.
RoundInfoBufLen
;
i
++
{
_
=
testInstance
.
roundData
.
UpsertRound
(
&
mixmessages
.
RoundInfo
{
ID
:
uint64
(
i
)})
}
// This will have oldest round as 0, until we reach RoundInfoBufLen, then
// round 0 will be overwritten by the newest round,
// moving the oldest round to round 1
expected
:=
id
.
Round
(
1
)
returned
:=
testInstance
.
GetOldestRoundID
()
if
returned
!=
expected
{
t
.
Errorf
(
"Failed to get oldest round from buffer."
+
"
\n\t
Expected: %v"
+
"
\n\t
Received: %v"
,
1
,
returned
)
}
}
func
TestInstance_UpdateGatewayConnections
(
t
*
testing
.
T
)
{
func
TestInstance_UpdateGatewayConnections
(
t
*
testing
.
T
)
{
secured
,
_
:=
NewSecuredNdf
(
testutils
.
NDF
)
secured
,
_
:=
NewSecuredNdf
(
testutils
.
NDF
)
testManager
:=
connect
.
NewManagerTesting
(
t
)
testManager
:=
connect
.
NewManagerTesting
(
t
)
...
...
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