Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-kbucket
Commits
8ee3433d
Commit
8ee3433d
authored
Apr 09, 2020
by
Aarsh Shah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better naming
parent
a4329c39
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
table_test.go
table_test.go
+21
-0
No files found.
table_test.go
View file @
8ee3433d
...
@@ -226,6 +226,27 @@ func TestUpdateLastSuccessfulOutboundQueryAt(t *testing.T) {
...
@@ -226,6 +226,27 @@ func TestUpdateLastSuccessfulOutboundQueryAt(t *testing.T) {
rt
.
tabLock
.
Unlock
()
rt
.
tabLock
.
Unlock
()
}
}
func
TestUpdateLastUsefulAt
(
t
*
testing
.
T
)
{
local
:=
test
.
RandPeerIDFatal
(
t
)
m
:=
pstore
.
NewMetrics
()
rt
,
err
:=
NewRoutingTable
(
10
,
ConvertPeerID
(
local
),
time
.
Hour
,
m
,
NoOpThreshold
)
require
.
NoError
(
t
,
err
)
p
:=
test
.
RandPeerIDFatal
(
t
)
b
,
err
:=
rt
.
TryAddPeer
(
p
,
true
)
require
.
True
(
t
,
b
)
require
.
NoError
(
t
,
err
)
// increment and assert
t2
:=
time
.
Now
()
.
Add
(
1
*
time
.
Hour
)
rt
.
UpdateLastUsefulAt
(
p
,
t2
)
rt
.
tabLock
.
Lock
()
pi
:=
rt
.
buckets
[
0
]
.
getPeer
(
p
)
require
.
NotNil
(
t
,
pi
)
require
.
EqualValues
(
t
,
t2
,
pi
.
LastUsefulAt
)
rt
.
tabLock
.
Unlock
()
}
func
TestTryAddPeer
(
t
*
testing
.
T
)
{
func
TestTryAddPeer
(
t
*
testing
.
T
)
{
minThreshold
:=
float64
(
24
*
1
*
time
.
Hour
)
minThreshold
:=
float64
(
24
*
1
*
time
.
Hour
)
t
.
Parallel
()
t
.
Parallel
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment