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
ce273f56
Commit
ce273f56
authored
Feb 1, 2021
by
Jono Wenger
Browse files
Options
Downloads
Patches
Plain Diff
Fix tests
parent
8b4c4243
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
storage/reception/fake_test.go
+18
-15
18 additions, 15 deletions
storage/reception/fake_test.go
storage/reception/identity.go
+22
-12
22 additions, 12 deletions
storage/reception/identity.go
storage/reception/identity_test.go
+15
-17
15 additions, 17 deletions
storage/reception/identity_test.go
with
55 additions
and
44 deletions
storage/reception/fake_test.go
+
18
−
15
View file @
ce273f56
...
...
@@ -11,17 +11,20 @@ import (
func
TestGenerateFakeIdentity
(
t
*
testing
.
T
)
{
rng
:=
rand
.
New
(
rand
.
NewSource
(
42
))
end
,
_
:=
json
.
Marshal
(
time
.
Unix
(
0
,
1258494203759765625
))
startValid
,
_
:=
json
.
Marshal
(
time
.
Unix
(
0
,
1258407803759765625
))
endValid
,
_
:=
json
.
Marshal
(
time
.
Unix
(
0
,
1258494203759765625
))
expected
:=
"{
\"
EphId
\"
:[0,0,0,0,0,0,46,197],"
+
"
\"
Source
\"
:[83,140,127,150,177,100,191,27,151,187,159,75,180,114,"
+
"232,159,91,20,132,242,82,9,201,217,52,62,146,186,9,221,157,82,3],"
+
"
\"
End
\"
:
\"
2009-11-17T13:43:23.759765625-08:00
\
"
,
\"
ExtraChecks
\"
:0,"
+
"
\"
StartValid
\"
:
\"
2009-11-16T13:43:23.759765625-08:00
\
"
,"
+
"
\"
EndValid
\"
:
\"
2009-11-17T13:43:23.759765625-08:00
\
"
,"
+
"
\"
End
\"
:
"
+
string
(
end
)
+
",
\"
ExtraChecks
\"
:0,"
+
"
\"
StartValid
\"
:
"
+
string
(
startValid
)
+
","
+
"
\"
EndValid
\"
:
"
+
string
(
endValid
)
+
","
+
"
\"
RequestMask
\"
:86400000000000,
\"
Ephemeral
\"
:true,"
+
"
\"
StartRequest
\"
:
\"
0001-01-01T00:00:00Z
\"
,"
+
"
\"
EndRequest
\"
:
\"
0001-01-01T00:00:00Z
\"
,
\"
Fake
\"
:true,
\"
KR
\"
:null}"
timestamp
:=
time
.
Date
(
2009
,
11
,
17
,
20
,
34
,
58
,
651387237
,
time
.
UTC
)
...
...
This diff is collapsed.
Click to expand it.
storage/reception/identity.go
+
22
−
12
View file @
ce273f56
...
...
@@ -48,7 +48,6 @@ func loadIdentity(kv *versioned.KV)(Identity, error){
return
r
,
nil
}
func
(
i
Identity
)
store
(
kv
*
versioned
.
KV
)
error
{
//marshal the registration
regStr
,
err
:=
json
.
Marshal
(
&
i
)
...
...
@@ -84,3 +83,14 @@ func (i *Identity)String()string{
return
strconv
.
FormatInt
(
i
.
EphId
.
Int64
(),
16
)
+
" "
+
i
.
Source
.
String
()
}
func
(
i
Identity
)
Equal
(
b
Identity
)
bool
{
return
i
.
EphId
==
b
.
EphId
&&
i
.
Source
.
Cmp
(
b
.
Source
)
&&
i
.
End
.
Equal
(
b
.
End
)
&&
i
.
ExtraChecks
==
b
.
ExtraChecks
&&
i
.
StartValid
.
Equal
(
b
.
StartValid
)
&&
i
.
EndValid
.
Equal
(
b
.
EndValid
)
&&
i
.
RequestMask
==
b
.
RequestMask
&&
i
.
Ephemeral
==
b
.
Ephemeral
}
This diff is collapsed.
Click to expand it.
storage/reception/identity_test.go
+
15
−
17
View file @
ce273f56
...
...
@@ -6,7 +6,6 @@ import (
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id/ephemeral"
"math/rand"
"reflect"
"testing"
"time"
)
...
...
@@ -34,7 +33,7 @@ func TestIdentity_EncodeDecode(t *testing.T) {
t
.
Errorf
(
"Failed to load: %s"
,
err
)
}
if
!
r
eflect
.
Deep
Equal
(
r
,
rLoad
){
if
!
r
.
Equal
(
rLoad
)
{
t
.
Errorf
(
"The two registrations are not the same
\n
saved: %+v
\n
loaded: %+v"
,
r
,
rLoad
)
}
}
...
...
@@ -68,7 +67,6 @@ func TestIdentity_Delete(t *testing.T) {
}
}
func
TestIdentity_String
(
t
*
testing
.
T
)
{
rng
:=
rand
.
New
(
rand
.
NewSource
(
42
))
...
...
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