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
88fb6cf0
Commit
88fb6cf0
authored
Apr 27, 2016
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test for double getting a block
License: MIT Signed-off-by:
Jeromy
<
why@ipfs.io
>
parent
b3005fb2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
0 deletions
+52
-0
bitswap_test.go
bitswap_test.go
+52
-0
No files found.
bitswap_test.go
View file @
88fb6cf0
...
...
@@ -308,3 +308,55 @@ func TestBasicBitswap(t *testing.T) {
}
}
}
func
TestDoubleGet
(
t
*
testing
.
T
)
{
net
:=
tn
.
VirtualNetwork
(
mockrouting
.
NewServer
(),
delay
.
Fixed
(
kNetworkDelay
))
sg
:=
NewTestSessionGenerator
(
net
)
defer
sg
.
Close
()
bg
:=
blocksutil
.
NewBlockGenerator
()
t
.
Log
(
"Test a one node trying to get one block from another"
)
instances
:=
sg
.
Instances
(
2
)
blocks
:=
bg
.
Blocks
(
1
)
ctx1
,
cancel1
:=
context
.
WithCancel
(
context
.
Background
())
blkch1
,
err
:=
instances
[
1
]
.
Exchange
.
GetBlocks
(
ctx1
,
[]
key
.
Key
{
blocks
[
0
]
.
Key
()})
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
ctx2
,
cancel2
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel2
()
blkch2
,
err
:=
instances
[
1
]
.
Exchange
.
GetBlocks
(
ctx2
,
[]
key
.
Key
{
blocks
[
0
]
.
Key
()})
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
cancel1
()
_
,
ok
:=
<-
blkch1
if
ok
{
t
.
Fatal
(
"expected channel to be closed"
)
}
err
=
instances
[
0
]
.
Exchange
.
HasBlock
(
blocks
[
0
])
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
blk
,
ok
:=
<-
blkch2
if
!
ok
{
t
.
Fatal
(
"expected to get the block here"
)
}
t
.
Log
(
blk
)
for
_
,
inst
:=
range
instances
{
err
:=
inst
.
Exchange
.
Close
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
}
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