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
e879259c
Commit
e879259c
authored
4 years ago
by
Sydney Anne Erickson
Browse files
Options
Downloads
Plain Diff
Merge branch 'XX-2481/ERS' into 'release'
Initial draft impl of ERS in Gateway See merge request elixxir/comms!264
parents
2aca1146
7ba08b74
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!58
Revert "Modify waiting lock"
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
network/historicalRoundData_test.go
+11
-11
11 additions, 11 deletions
network/historicalRoundData_test.go
network/instance_test.go
+1
-1
1 addition, 1 deletion
network/instance_test.go
with
12 additions
and
12 deletions
network/historicalRoundData_test.go
+
11
−
11
View file @
e879259c
...
@@ -15,7 +15,7 @@ type ersMemMap struct {
...
@@ -15,7 +15,7 @@ type ersMemMap struct {
}
}
// Store a new round info object into the map
// Store a new round info object into the map
func
(
ersm
ersMemMap
)
Store
(
ri
*
pb
.
RoundInfo
)
error
{
func
(
ersm
*
ersMemMap
)
Store
(
ri
*
pb
.
RoundInfo
)
error
{
rid
:=
id
.
Round
(
ri
.
GetID
())
rid
:=
id
.
Round
(
ri
.
GetID
())
// See if the round exists, if it does we need to check that the update ID is newer than the current
// See if the round exists, if it does we need to check that the update ID is newer than the current
ori
,
err
:=
ersm
.
Retrieve
(
rid
)
ori
,
err
:=
ersm
.
Retrieve
(
rid
)
...
@@ -34,12 +34,12 @@ func (ersm ersMemMap) Store(ri *pb.RoundInfo) error {
...
@@ -34,12 +34,12 @@ func (ersm ersMemMap) Store(ri *pb.RoundInfo) error {
}
}
// Get a round info object from the memory map database
// Get a round info object from the memory map database
func
(
ersm
ersMemMap
)
Retrieve
(
id
id
.
Round
)
(
*
pb
.
RoundInfo
,
error
)
{
func
(
ersm
*
ersMemMap
)
Retrieve
(
id
id
.
Round
)
(
*
pb
.
RoundInfo
,
error
)
{
return
ersm
.
rounds
[
id
],
nil
return
ersm
.
rounds
[
id
],
nil
}
}
// Get multiple specific round info objects from the memory map database
// Get multiple specific round info objects from the memory map database
func
(
ersm
ersMemMap
)
RetrieveMany
(
rounds
[]
id
.
Round
)
([]
*
pb
.
RoundInfo
,
error
)
{
func
(
ersm
*
ersMemMap
)
RetrieveMany
(
rounds
[]
id
.
Round
)
([]
*
pb
.
RoundInfo
,
error
)
{
var
r
[]
*
pb
.
RoundInfo
var
r
[]
*
pb
.
RoundInfo
for
_
,
round
:=
range
rounds
{
for
_
,
round
:=
range
rounds
{
...
@@ -55,7 +55,7 @@ func (ersm ersMemMap) RetrieveMany(rounds []id.Round) ([]*pb.RoundInfo, error) {
...
@@ -55,7 +55,7 @@ func (ersm ersMemMap) RetrieveMany(rounds []id.Round) ([]*pb.RoundInfo, error) {
}
}
// Retrieve a concurrent range of round info objects from the memory map database
// Retrieve a concurrent range of round info objects from the memory map database
func
(
ersm
ersMemMap
)
RetrieveRange
(
first
,
last
id
.
Round
)
([]
*
pb
.
RoundInfo
,
error
)
{
func
(
ersm
*
ersMemMap
)
RetrieveRange
(
first
,
last
id
.
Round
)
([]
*
pb
.
RoundInfo
,
error
)
{
idrange
:=
uint64
(
last
-
first
)
idrange
:=
uint64
(
last
-
first
)
i
:=
uint64
(
0
)
i
:=
uint64
(
0
)
...
@@ -81,7 +81,7 @@ func (ersm ersMemMap) RetrieveRange(first, last id.Round) ([]*pb.RoundInfo, erro
...
@@ -81,7 +81,7 @@ func (ersm ersMemMap) RetrieveRange(first, last id.Round) ([]*pb.RoundInfo, erro
// a newer ID
// a newer ID
func
TestERSStore
(
t
*
testing
.
T
)
{
func
TestERSStore
(
t
*
testing
.
T
)
{
// Setup
// Setup
var
ers
ds
.
ExternalRoundStorage
=
ersMemMap
{
rounds
:
make
(
map
[
id
.
Round
]
*
pb
.
RoundInfo
)}
var
ers
ds
.
ExternalRoundStorage
=
&
ersMemMap
{
rounds
:
make
(
map
[
id
.
Round
]
*
pb
.
RoundInfo
)}
// Store a test round
// Store a test round
r
:=
pb
.
RoundInfo
{
ID
:
1
,
UpdateID
:
5
}
r
:=
pb
.
RoundInfo
{
ID
:
1
,
UpdateID
:
5
}
...
@@ -143,7 +143,7 @@ func TestERSStore(t *testing.T) {
...
@@ -143,7 +143,7 @@ func TestERSStore(t *testing.T) {
// Test that Retrieve has expected behaviour if an item doesn't exist
// Test that Retrieve has expected behaviour if an item doesn't exist
func
TestERSRetrieve
(
t
*
testing
.
T
)
{
func
TestERSRetrieve
(
t
*
testing
.
T
)
{
var
ers
ds
.
ExternalRoundStorage
=
ersMemMap
{
rounds
:
make
(
map
[
id
.
Round
]
*
pb
.
RoundInfo
)}
var
ers
ds
.
ExternalRoundStorage
=
&
ersMemMap
{
rounds
:
make
(
map
[
id
.
Round
]
*
pb
.
RoundInfo
)}
ri
,
err
:=
ers
.
Retrieve
(
id
.
Round
(
1
))
ri
,
err
:=
ers
.
Retrieve
(
id
.
Round
(
1
))
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
err
.
Error
())
t
.
Errorf
(
err
.
Error
())
...
@@ -175,7 +175,7 @@ func TestERSRetrieve(t *testing.T) {
...
@@ -175,7 +175,7 @@ func TestERSRetrieve(t *testing.T) {
// that are not
// that are not
func
TestERSRetrieveMany
(
t
*
testing
.
T
)
{
func
TestERSRetrieveMany
(
t
*
testing
.
T
)
{
// Setup
// Setup
var
ers
ds
.
ExternalRoundStorage
=
ersMemMap
{
rounds
:
make
(
map
[
id
.
Round
]
*
pb
.
RoundInfo
)}
var
ers
ds
.
ExternalRoundStorage
=
&
ersMemMap
{
rounds
:
make
(
map
[
id
.
Round
]
*
pb
.
RoundInfo
)}
// Store a test round
// Store a test round
origRound1
:=
pb
.
RoundInfo
{
ID
:
1
,
UpdateID
:
5
}
origRound1
:=
pb
.
RoundInfo
{
ID
:
1
,
UpdateID
:
5
}
...
@@ -215,7 +215,7 @@ func TestERSRetrieveMany(t *testing.T) {
...
@@ -215,7 +215,7 @@ func TestERSRetrieveMany(t *testing.T) {
// are not stored
// are not stored
func
TestERSRetrieveRange
(
t
*
testing
.
T
)
{
func
TestERSRetrieveRange
(
t
*
testing
.
T
)
{
// Setup
// Setup
var
ers
ds
.
ExternalRoundStorage
=
ersMemMap
{
rounds
:
make
(
map
[
id
.
Round
]
*
pb
.
RoundInfo
)}
var
ers
ds
.
ExternalRoundStorage
=
&
ersMemMap
{
rounds
:
make
(
map
[
id
.
Round
]
*
pb
.
RoundInfo
)}
// Store a test round
// Store a test round
origRound1
:=
pb
.
RoundInfo
{
ID
:
1
,
UpdateID
:
5
}
origRound1
:=
pb
.
RoundInfo
{
ID
:
1
,
UpdateID
:
5
}
...
@@ -259,7 +259,7 @@ func TestInstance_GetHistoricalRound(t *testing.T) {
...
@@ -259,7 +259,7 @@ func TestInstance_GetHistoricalRound(t *testing.T) {
t
.
Errorf
(
err
.
Error
())
t
.
Errorf
(
err
.
Error
())
}
}
var
ers
ds
.
ExternalRoundStorage
=
ersMemMap
{
rounds
:
make
(
map
[
id
.
Round
]
*
pb
.
RoundInfo
)}
var
ers
ds
.
ExternalRoundStorage
=
&
ersMemMap
{
rounds
:
make
(
map
[
id
.
Round
]
*
pb
.
RoundInfo
)}
i2
:=
Instance
{
ers
:
ers
}
i2
:=
Instance
{
ers
:
ers
}
ri
,
err
=
i2
.
GetHistoricalRound
(
id
.
Round
(
0
))
ri
,
err
=
i2
.
GetHistoricalRound
(
id
.
Round
(
0
))
// Should return no error and blank round
// Should return no error and blank round
...
@@ -280,7 +280,7 @@ func TestInstance_GetHistoricalRoundRange(t *testing.T) {
...
@@ -280,7 +280,7 @@ func TestInstance_GetHistoricalRoundRange(t *testing.T) {
t
.
Errorf
(
err
.
Error
())
t
.
Errorf
(
err
.
Error
())
}
}
var
ers
ds
.
ExternalRoundStorage
=
ersMemMap
{
rounds
:
make
(
map
[
id
.
Round
]
*
pb
.
RoundInfo
)}
var
ers
ds
.
ExternalRoundStorage
=
&
ersMemMap
{
rounds
:
make
(
map
[
id
.
Round
]
*
pb
.
RoundInfo
)}
i2
:=
Instance
{
ers
:
ers
}
i2
:=
Instance
{
ers
:
ers
}
ri
,
err
=
i2
.
GetHistoricalRoundRange
(
5
,
10
)
ri
,
err
=
i2
.
GetHistoricalRoundRange
(
5
,
10
)
// Should return no error and blank round
// Should return no error and blank round
...
@@ -304,7 +304,7 @@ func TestInstance_GetHistoricalRounds(t *testing.T) {
...
@@ -304,7 +304,7 @@ func TestInstance_GetHistoricalRounds(t *testing.T) {
t
.
Errorf
(
err
.
Error
())
t
.
Errorf
(
err
.
Error
())
}
}
var
ers
ds
.
ExternalRoundStorage
=
ersMemMap
{
rounds
:
make
(
map
[
id
.
Round
]
*
pb
.
RoundInfo
)}
var
ers
ds
.
ExternalRoundStorage
=
&
ersMemMap
{
rounds
:
make
(
map
[
id
.
Round
]
*
pb
.
RoundInfo
)}
i2
:=
Instance
{
ers
:
ers
}
i2
:=
Instance
{
ers
:
ers
}
ri
,
err
=
i2
.
GetHistoricalRounds
(
getRounds
)
ri
,
err
=
i2
.
GetHistoricalRounds
(
getRounds
)
// Should return no error and blank round
// Should return no error and blank round
...
...
This diff is collapsed.
Click to expand it.
network/instance_test.go
+
1
−
1
View file @
e879259c
...
@@ -691,7 +691,7 @@ func TestInstance_RoundUpdateAddsToERS(t *testing.T) {
...
@@ -691,7 +691,7 @@ func TestInstance_RoundUpdateAddsToERS(t *testing.T) {
// Build the Instance object with an ERS memory map
// Build the Instance object with an ERS memory map
pc
:=
&
connect
.
ProtoComms
{}
pc
:=
&
connect
.
ProtoComms
{}
var
ers
ds
.
ExternalRoundStorage
=
ersMemMap
{
rounds
:
make
(
map
[
id
.
Round
]
*
mixmessages
.
RoundInfo
)}
var
ers
ds
.
ExternalRoundStorage
=
&
ersMemMap
{
rounds
:
make
(
map
[
id
.
Round
]
*
mixmessages
.
RoundInfo
)}
i
,
err
:=
NewInstance
(
pc
,
baseNDF
,
baseNDF
,
ers
)
i
,
err
:=
NewInstance
(
pc
,
baseNDF
,
baseNDF
,
ers
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Error
(
nil
)
t
.
Error
(
nil
)
...
...
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