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
b7de75d3
Commit
b7de75d3
authored
Aug 23, 2015
by
rht
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace context.TODO in test files with context.Background
License: MIT Signed-off-by:
rht
<
rhtbot@gmail.com
>
parent
69ff434c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
8 deletions
+9
-8
bitswap_test.go
bitswap_test.go
+7
-6
notifications/notifications_test.go
notifications/notifications_test.go
+1
-1
testutils.go
testutils.go
+1
-1
No files found.
bitswap_test.go
View file @
b7de75d3
...
...
@@ -144,6 +144,7 @@ func TestLargeFileTwoPeers(t *testing.T) {
}
func
PerformDistributionTest
(
t
*
testing
.
T
,
numInstances
,
numBlocks
int
)
{
ctx
:=
context
.
Background
()
if
testing
.
Short
()
{
t
.
SkipNow
()
}
...
...
@@ -161,7 +162,7 @@ func PerformDistributionTest(t *testing.T, numInstances, numBlocks int) {
first
:=
instances
[
0
]
for
_
,
b
:=
range
blocks
{
blkeys
=
append
(
blkeys
,
b
.
Key
())
first
.
Exchange
.
HasBlock
(
c
ontext
.
Background
()
,
b
)
first
.
Exchange
.
HasBlock
(
c
tx
,
b
)
}
t
.
Log
(
"Distribute!"
)
...
...
@@ -171,7 +172,7 @@ func PerformDistributionTest(t *testing.T, numInstances, numBlocks int) {
wg
.
Add
(
1
)
go
func
(
inst
Instance
)
{
defer
wg
.
Done
()
outch
,
err
:=
inst
.
Exchange
.
GetBlocks
(
c
ontext
.
TODO
()
,
blkeys
)
outch
,
err
:=
inst
.
Exchange
.
GetBlocks
(
c
tx
,
blkeys
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -228,7 +229,7 @@ func TestSendToWantingPeer(t *testing.T) {
alpha
:=
bg
.
Next
()
// peerA requests and waits for block alpha
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
TODO
(),
waitTime
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
waitTime
)
defer
cancel
()
alphaPromise
,
err
:=
peerA
.
Exchange
.
GetBlocks
(
ctx
,
[]
key
.
Key
{
alpha
.
Key
()})
if
err
!=
nil
{
...
...
@@ -236,7 +237,7 @@ func TestSendToWantingPeer(t *testing.T) {
}
// peerB announces to the network that he has block alpha
ctx
,
cancel
=
context
.
WithTimeout
(
context
.
TODO
(),
timeout
)
ctx
,
cancel
=
context
.
WithTimeout
(
context
.
Background
(),
timeout
)
defer
cancel
()
err
=
peerB
.
Exchange
.
HasBlock
(
ctx
,
alpha
)
if
err
!=
nil
{
...
...
@@ -265,12 +266,12 @@ func TestBasicBitswap(t *testing.T) {
instances
:=
sg
.
Instances
(
2
)
blocks
:=
bg
.
Blocks
(
1
)
err
:=
instances
[
0
]
.
Exchange
.
HasBlock
(
context
.
TODO
(),
blocks
[
0
])
err
:=
instances
[
0
]
.
Exchange
.
HasBlock
(
context
.
Background
(),
blocks
[
0
])
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
TODO
(),
time
.
Second
*
5
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
time
.
Second
*
5
)
defer
cancel
()
blk
,
err
:=
instances
[
1
]
.
Exchange
.
GetBlock
(
ctx
,
blocks
[
0
]
.
Key
())
if
err
!=
nil
{
...
...
notifications/notifications_test.go
View file @
b7de75d3
...
...
@@ -103,7 +103,7 @@ func TestDuplicateSubscribe(t *testing.T) {
func
TestSubscribeIsANoopWhenCalledWithNoKeys
(
t
*
testing
.
T
)
{
n
:=
New
()
defer
n
.
Shutdown
()
ch
:=
n
.
Subscribe
(
context
.
TODO
())
// no keys provided
ch
:=
n
.
Subscribe
(
context
.
Background
())
// no keys provided
if
_
,
ok
:=
<-
ch
;
ok
{
t
.
Fatal
(
"should be closed if no keys provided"
)
}
...
...
testutils.go
View file @
b7de75d3
...
...
@@ -18,7 +18,7 @@ import (
// WARNING: this uses RandTestBogusIdentity DO NOT USE for NON TESTS!
func
NewTestSessionGenerator
(
net
tn
.
Network
)
SessionGenerator
{
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
TODO
())
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
return
SessionGenerator
{
net
:
net
,
seq
:
0
,
...
...
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