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
dms3
go-bitswap
Commits
da7f7eac
Commit
da7f7eac
authored
Aug 20, 2019
by
Dirk McCormick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: fix flakey session peer manager tests
parent
c980d7ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
sessionpeermanager/sessionpeermanager_test.go
sessionpeermanager/sessionpeermanager_test.go
+8
-6
No files found.
sessionpeermanager/sessionpeermanager_test.go
View file @
da7f7eac
...
...
@@ -150,7 +150,8 @@ func TestOrderingPeers(t *testing.T) {
ctx
:=
context
.
Background
()
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
30
*
time
.
Millisecond
)
defer
cancel
()
peers
:=
testutil
.
GeneratePeers
(
100
)
peerCount
:=
100
peers
:=
testutil
.
GeneratePeers
(
peerCount
)
completed
:=
make
(
chan
struct
{})
fpt
:=
&
fakePeerTagger
{}
fppf
:=
&
fakePeerProviderFinder
{
peers
,
completed
}
...
...
@@ -171,9 +172,10 @@ func TestOrderingPeers(t *testing.T) {
sessionPeerManager
.
RecordPeerRequests
(
nil
,
c
)
// record receives
peer1
:=
peers
[
rand
.
Intn
(
100
)]
peer2
:=
peers
[
rand
.
Intn
(
100
)]
peer3
:=
peers
[
rand
.
Intn
(
100
)]
randi
:=
rand
.
Perm
(
peerCount
)
peer1
:=
peers
[
randi
[
0
]]
peer2
:=
peers
[
randi
[
1
]]
peer3
:=
peers
[
randi
[
2
]]
time
.
Sleep
(
1
*
time
.
Millisecond
)
sessionPeerManager
.
RecordPeerResponse
(
peer1
,
[]
cid
.
Cid
{
c
[
0
]})
time
.
Sleep
(
5
*
time
.
Millisecond
)
...
...
@@ -358,7 +360,7 @@ func TestTimeoutsAndCancels(t *testing.T) {
func
TestUntaggingPeers
(
t
*
testing
.
T
)
{
ctx
:=
context
.
Background
()
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
1
0
*
time
.
Millisecond
)
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
3
0
*
time
.
Millisecond
)
defer
cancel
()
peers
:=
testutil
.
GeneratePeers
(
5
)
completed
:=
make
(
chan
struct
{})
...
...
@@ -375,7 +377,7 @@ func TestUntaggingPeers(t *testing.T) {
case
<-
ctx
.
Done
()
:
t
.
Fatal
(
"Did not finish finding providers"
)
}
time
.
Sleep
(
2
*
time
.
Millisecond
)
time
.
Sleep
(
15
*
time
.
Millisecond
)
if
fpt
.
count
()
!=
len
(
peers
)
{
t
.
Fatal
(
"Peers were not tagged!"
)
...
...
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