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
Merge requests
!430
XX-4277 / Fix file transfer crashes
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
XX-4277 / Fix file transfer crashes
XX-4277/fileTransferCrashDebug
into
release
Overview
0
Commits
22
Pipelines
0
Changes
11
Merged
Jono Wenger
requested to merge
XX-4277/fileTransferCrashDebug
into
release
2 years ago
Overview
0
Commits
22
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Compare
version 8
version 15
4f465dd6
2 years ago
version 14
f19bd05b
2 years ago
version 13
8a3833c3
2 years ago
version 12
b912519f
2 years ago
version 11
f5d87011
2 years ago
version 10
310fb7ff
2 years ago
version 9
223718df
2 years ago
version 8
41a135fc
2 years ago
version 7
0bcf1292
2 years ago
version 6
3f5802fd
2 years ago
version 5
0667ec02
2 years ago
version 4
d2420664
2 years ago
version 3
9f18c2f5
2 years ago
version 2
371b6433
2 years ago
version 1
4c8901c5
2 years ago
release (base)
and
version 9
latest version
7bca379e
22 commits,
2 years ago
version 15
4f465dd6
21 commits,
2 years ago
version 14
f19bd05b
20 commits,
2 years ago
version 13
8a3833c3
19 commits,
2 years ago
version 12
b912519f
18 commits,
2 years ago
version 11
f5d87011
16 commits,
2 years ago
version 10
310fb7ff
14 commits,
2 years ago
version 9
223718df
13 commits,
2 years ago
version 8
41a135fc
12 commits,
2 years ago
version 7
0bcf1292
11 commits,
2 years ago
version 6
3f5802fd
10 commits,
2 years ago
version 5
0667ec02
6 commits,
2 years ago
version 4
d2420664
5 commits,
2 years ago
version 3
9f18c2f5
4 commits,
2 years ago
version 2
371b6433
2 commits,
2 years ago
version 1
4c8901c5
1 commit,
2 years ago
Show latest version
1 file
+
107
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
cmix/identity/receptionID/identity_test.go
+
107
−
0
Options
@@ -14,6 +14,7 @@ import (
"gitlab.com/xx_network/primitives/id/ephemeral"
"gitlab.com/xx_network/primitives/netTime"
"math/rand"
"reflect"
"testing"
"time"
)
@@ -109,3 +110,109 @@ func TestIdentity_Equal(t *testing.T) {
"
\n
a: %s
\n
c: %s"
,
a
,
c
)
}
}
// TestIdentity_store_loadProcessNext tests that when an Identity is stored,
// Identity.ProcessNext is loaded. This test is exhaustive by making a reasonably
// long Identity.ProcessNext linked list, and checking if all Identity's are loaded.
func
TestIdentity_store_loadProcessNext
(
t
*
testing
.
T
)
{
kv
:=
versioned
.
NewKV
(
ekv
.
MakeMemstore
())
const
numTests
=
10
// Construct the first identity, which will be stored
ephId
:=
ephemeral
.
Id
{}
copy
(
ephId
[
:
],
[]
byte
{
0
})
first
:=
&
Identity
{
EphemeralIdentity
:
EphemeralIdentity
{
EphId
:
ephId
,
Source
:
&
id
.
Permissioning
,
},
AddressSize
:
0
,
End
:
netTime
.
Now
()
.
Round
(
0
),
ExtraChecks
:
0
,
StartValid
:
netTime
.
Now
()
.
Round
(
0
),
EndValid
:
netTime
.
Now
()
.
Round
(
0
),
Ephemeral
:
false
,
}
// Build the linked list with unique identities. Use temp as a temporary
// head, such that the previous node in the linked list can have its next
// set with the next identity, and then set temp to the next identity for
// the next iteration
temp
:=
first
for
i
:=
1
;
i
<
numTests
;
i
++
{
// Ensure uniqueness of every identity by having the ephemeral ID
// contain the number of the iteration (ie the value of i)
ephId
=
ephemeral
.
Id
{}
copy
(
ephId
[
:
],
[]
byte
{
byte
(
i
)})
next
:=
&
Identity
{
EphemeralIdentity
:
EphemeralIdentity
{
EphId
:
ephId
,
Source
:
&
id
.
Permissioning
,
},
AddressSize
:
25
,
End
:
netTime
.
Now
()
.
Round
(
0
),
ExtraChecks
:
16
,
StartValid
:
netTime
.
Now
()
.
Round
(
0
),
EndValid
:
netTime
.
Now
()
.
Round
(
0
),
Ephemeral
:
false
,
}
temp
.
ProcessNext
=
next
temp
=
next
}
// Save the first identity. This should be the head of
// the created linked list, and thus all nodes (Identity's) should be saved.
err
:=
first
.
store
(
kv
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to store: %s"
,
err
)
}
// Load the identity
loadedIdentity
,
err
:=
loadIdentity
(
kv
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to load: %+v"
,
err
)
}
// Smoke test: Check that there is a next element in the linked list
if
loadedIdentity
.
ProcessNext
==
nil
{
t
.
Fatalf
(
"Failed to load processNext for identity!"
)
}
// Serialize the linked list, such that we can iterate over
// it to check for expected values later
temp
=
&
loadedIdentity
serializedList
:=
make
([]
*
Identity
,
0
)
for
temp
!=
nil
{
serializedList
=
append
(
serializedList
,
temp
)
temp
=
temp
.
ProcessNext
}
// Smoke test: Check that the number of loaded identities is of the
// expected quantity
if
len
(
serializedList
)
!=
numTests
{
t
.
Fatalf
(
"Bad number of identities from Identity.ProcessNext."
+
"
\n
Expected: %d"
+
"
\n
Received: %d"
,
numTests
,
len
(
serializedList
))
}
// Go through every identity to make sure it has the expected value
for
i
:=
0
;
i
<
len
(
serializedList
);
i
++
{
// The loaded identity should have an ephemeral ID
// contain the number of the iteration (ie the value of i)
ephId
=
ephemeral
.
Id
{}
copy
(
ephId
[
:
],
[]
byte
{
byte
(
i
)})
received
:=
serializedList
[
i
]
if
!
reflect
.
DeepEqual
(
ephId
,
received
.
EphId
)
{
t
.
Errorf
(
"Identity #%d loaded is not expected."
+
"
\n
Expected: %+v"
+
"
\n
Received: %+v"
,
i
,
ephId
,
received
.
EphId
)
}
}
}
Loading