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
872b78e8
Commit
872b78e8
authored
Mar 19, 2020
by
Aarsh Shah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better test
parent
7fa6dacb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
11 deletions
+6
-11
table_test.go
table_test.go
+6
-11
No files found.
table_test.go
View file @
872b78e8
...
...
@@ -3,7 +3,6 @@ package kbucket
import
(
"context"
"math/rand"
"sync"
"testing"
"time"
...
...
@@ -175,15 +174,11 @@ func TestHandlePeerDead(t *testing.T) {
}
}
var
lk
sync
.
Mutex
var
added
peer
.
ID
f
:=
func
(
ctx
context
.
Context
,
p
peer
.
ID
)
bool
{
if
p
==
candidate
{
lk
.
Lock
()
added
=
p
lk
.
Unlock
()
return
true
}
return
tru
e
return
fals
e
}
m
:=
pstore
.
NewMetrics
()
...
...
@@ -209,15 +204,15 @@ func TestHandlePeerDead(t *testing.T) {
// mark a peer as dead and ensure it's not in the RT & it gets replaced
require
.
NotEmpty
(
t
,
rt
.
Find
(
p1
))
require
.
Empty
(
t
,
rt
.
Find
(
candidate
))
rt
.
HandlePeerDead
(
p1
)
require
.
Empty
(
t
,
rt
.
Find
(
p1
))
time
.
Sleep
(
1
*
time
.
Second
)
time
.
Sleep
(
2
*
time
.
Second
)
require
.
NotEmpty
(
t
,
rt
.
Find
(
p2
))
rt
.
cplReplacementCache
.
Lock
()
require
.
Empty
(
t
,
rt
.
cplReplacementCache
.
candidates
)
rt
.
cplReplacementCache
.
Unlock
()
lk
.
Lock
()
require
.
Equal
(
t
,
candidate
,
added
)
lk
.
Unlock
()
require
.
NotEmpty
(
t
,
rt
.
Find
(
candidate
))
}
func
TestTableCallbacks
(
t
*
testing
.
T
)
{
...
...
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