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-kad-dht
Commits
4a78fc6e
Commit
4a78fc6e
authored
May 05, 2020
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: fix TestHungRequest bootstrap
Just wait for peers to fill up the routing table.
parent
fb42b20f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
ext_test.go
ext_test.go
+9
-6
No files found.
ext_test.go
View file @
4a78fc6e
...
...
@@ -20,13 +20,14 @@ import (
ggio
"github.com/gogo/protobuf/io"
u
"github.com/ipfs/go-ipfs-util"
"github.com/stretchr/testify/require"
)
// Test that one hung request to a peer doesn't prevent another request
// using that same peer from obeying its context.
func
TestHungRequest
(
t
*
testing
.
T
)
{
ctx
:=
context
.
Background
()
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel
()
mn
,
err
:=
mocknet
.
FullMeshConnected
(
ctx
,
2
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
...
...
@@ -46,8 +47,10 @@ func TestHungRequest(t *testing.T) {
})
}
require
.
NoError
(
t
,
hosts
[
0
]
.
Peerstore
()
.
AddProtocols
(
hosts
[
1
]
.
ID
(),
protocol
.
ConvertToStrings
(
d
.
serverProtocols
)
...
))
d
.
peerFound
(
ctx
,
hosts
[
1
]
.
ID
(),
true
)
// Wait at most 100ms for a peer in our routing table.
for
i
:=
0
;
i
<
100
&&
d
.
routingTable
.
Size
()
==
0
;
i
++
{
time
.
Sleep
(
10
*
time
.
Millisecond
)
}
ctx1
,
cancel1
:=
context
.
WithTimeout
(
ctx
,
1
*
time
.
Second
)
defer
cancel1
()
...
...
@@ -66,8 +69,8 @@ func TestHungRequest(t *testing.T) {
t
.
Errorf
(
"expected to fail with deadline exceeded, got: %s"
,
ctx2
.
Err
())
}
select
{
case
<-
done
:
t
.
Error
f
(
"GetClosestPeers should not have returned yet"
)
case
err
=
<-
done
:
t
.
Error
(
"GetClosestPeers should not have returned yet"
,
err
)
default
:
err
=
<-
done
if
err
!=
context
.
DeadlineExceeded
{
...
...
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