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
0e5663a2
Commit
0e5663a2
authored
Sep 1, 2021
by
Jonah Husson
Browse files
Options
Downloads
Patches
Plain Diff
Fix grace period use
parent
48e1227b
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!23
Release
,
!17
Fix grace period use
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
network/ephemeral/tracker.go
+6
-5
6 additions, 5 deletions
network/ephemeral/tracker.go
network/ephemeral/tracker_test.go
+16
-0
16 additions, 0 deletions
network/ephemeral/tracker_test.go
with
22 additions
and
5 deletions
network/ephemeral/tracker.go
+
6
−
5
View file @
0e5663a2
...
@@ -141,15 +141,16 @@ func generateIdentities(protoIds []ephemeral.ProtoIdentity, ourId *id.ID,
...
@@ -141,15 +141,16 @@ func generateIdentities(protoIds []ephemeral.ProtoIdentity, ourId *id.ID,
// Add identities for every ephemeral ID
// Add identities for every ephemeral ID
for
i
,
eid
:=
range
protoIds
{
for
i
,
eid
:=
range
protoIds
{
// Expand the grace period for both start and end
// Expand the grace period for both start and end
eid
.
End
.
Add
(
validityGracePeriod
)
// This does not actually modify anything.... time is not a pointer and even if it were this returns the new value???
eid
.
Start
.
Add
(
-
validityGracePeriod
)
// eid.End.Add(validityGracePeriod)
// eid.Start.Add(-validityGracePeriod)
identities
[
i
]
=
reception
.
Identity
{
identities
[
i
]
=
reception
.
Identity
{
EphId
:
eid
.
Id
,
EphId
:
eid
.
Id
,
Source
:
ourId
,
Source
:
ourId
,
AddressSize
:
addressSize
,
AddressSize
:
addressSize
,
End
:
eid
.
End
,
End
:
eid
.
End
,
StartValid
:
eid
.
Start
,
StartValid
:
eid
.
Start
.
Add
(
-
validityGracePeriod
)
,
EndValid
:
eid
.
End
,
EndValid
:
eid
.
End
.
Add
(
validityGracePeriod
),
// What is this vs end? should it be modified??
Ephemeral
:
false
,
Ephemeral
:
false
,
}
}
...
@@ -211,6 +212,6 @@ func calculateTickerTime(baseIDs []ephemeral.ProtoIdentity, now time.Time) time.
...
@@ -211,6 +212,6 @@ func calculateTickerTime(baseIDs []ephemeral.ProtoIdentity, now time.Time) time.
// Factor out the grace period previously expanded upon
// Factor out the grace period previously expanded upon
// Calculate and return that duration
// Calculate and return that duration
gracePeriod
:=
lastIdentity
.
End
.
Add
(
-
2
*
validityGracePeriod
)
gracePeriod
:=
lastIdentity
.
End
.
Add
(
-
1
*
validityGracePeriod
)
return
gracePeriod
.
Sub
(
now
)
return
gracePeriod
.
Sub
(
now
)
}
}
This diff is collapsed.
Click to expand it.
network/ephemeral/tracker_test.go
+
16
−
0
View file @
0e5663a2
...
@@ -17,6 +17,7 @@ import (
...
@@ -17,6 +17,7 @@ import (
"gitlab.com/xx_network/comms/signature"
"gitlab.com/xx_network/comms/signature"
"gitlab.com/xx_network/crypto/signature/rsa"
"gitlab.com/xx_network/crypto/signature/rsa"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id/ephemeral"
"gitlab.com/xx_network/primitives/netTime"
"gitlab.com/xx_network/primitives/netTime"
"gitlab.com/xx_network/primitives/utils"
"gitlab.com/xx_network/primitives/utils"
"testing"
"testing"
...
@@ -122,3 +123,18 @@ func setupInstance(instance interfaces.NetworkManager) error {
...
@@ -122,3 +123,18 @@ func setupInstance(instance interfaces.NetworkManager) error {
return
nil
return
nil
}
}
func
TestGenerateIdentities
(
t
*
testing
.
T
)
{
eid
,
s
,
e
,
err
:=
ephemeral
.
GetId
(
id
.
NewIdFromString
(
"zezima"
,
id
.
Node
,
t
),
16
,
time
.
Now
()
.
UnixNano
())
if
err
!=
nil
{
t
.
Errorf
(
"Failed to get eid: %+v"
,
err
)
}
protoIds
:=
[]
ephemeral
.
ProtoIdentity
{{
eid
,
s
,
e
}}
generated
:=
generateIdentities
(
protoIds
,
id
.
NewIdFromString
(
"escaline"
,
id
.
Node
,
t
),
16
)
if
generated
[
0
]
.
End
!=
protoIds
[
0
]
.
End
.
Add
(
5
*
time
.
Minute
)
{
t
.
Errorf
(
"End was not modified. Orig %+v, Generated %+v"
,
protoIds
[
0
]
.
End
,
generated
[
0
]
.
End
)
}
if
generated
[
0
]
.
StartValid
!=
protoIds
[
0
]
.
Start
.
Add
(
-
5
*
time
.
Minute
)
{
t
.
Errorf
(
"End was not modified. Orig %+v, Generated %+v"
,
protoIds
[
0
]
.
End
,
generated
[
0
]
.
End
)
}
}
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