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
21ccf0c7
Commit
21ccf0c7
authored
Feb 26, 2019
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test(prq): test finding providers with a pre-canceled context
parent
f6e05274
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
providerquerymanager/providerquerymanager_test.go
providerquerymanager/providerquerymanager_test.go
+25
-0
No files found.
providerquerymanager/providerquerymanager_test.go
View file @
21ccf0c7
...
...
@@ -304,3 +304,28 @@ func TestFindProviderTimeout(t *testing.T) {
t
.
Fatal
(
"Find provider request should have timed out, did not"
)
}
}
func
TestFindProviderPreCanceled
(
t
*
testing
.
T
)
{
peers
:=
testutil
.
GeneratePeers
(
10
)
fpn
:=
&
fakeProviderNetwork
{
peersFound
:
peers
,
delay
:
1
*
time
.
Millisecond
,
}
ctx
:=
context
.
Background
()
providerQueryManager
:=
New
(
ctx
,
fpn
)
providerQueryManager
.
Startup
()
providerQueryManager
.
SetFindProviderTimeout
(
100
*
time
.
Millisecond
)
keys
:=
testutil
.
GenerateCids
(
1
)
sessionCtx
,
cancel
:=
context
.
WithCancel
(
ctx
)
cancel
()
firstRequestChan
:=
providerQueryManager
.
FindProvidersAsync
(
sessionCtx
,
keys
[
0
])
if
firstRequestChan
==
nil
{
t
.
Fatal
(
"expected non-nil channel"
)
}
select
{
case
<-
firstRequestChan
:
case
<-
time
.
After
(
10
*
time
.
Millisecond
)
:
t
.
Fatal
(
"shouldn't have blocked waiting on a closed context"
)
}
}
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