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
17aaaa9c
Commit
17aaaa9c
authored
May 17, 2016
by
Jeromy Johnson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2716 from ipfs/patch-add-link-paths
Fix #2715 and patch add-link paths
parents
786bcdee
4abba348
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
bitswap.go
bitswap.go
+3
-0
bitswap_test.go
bitswap_test.go
+13
-0
No files found.
bitswap.go
View file @
17aaaa9c
...
...
@@ -155,6 +155,9 @@ type blockRequest struct {
// GetBlock attempts to retrieve a particular block from peers within the
// deadline enforced by the context.
func
(
bs
*
Bitswap
)
GetBlock
(
parent
context
.
Context
,
k
key
.
Key
)
(
blocks
.
Block
,
error
)
{
if
k
==
""
{
return
nil
,
blockstore
.
ErrNotFound
}
// Any async work initiated by this function must end when this function
// returns. To ensure this, derive a new context. Note that it is okay to
...
...
bitswap_test.go
View file @
17aaaa9c
...
...
@@ -11,6 +11,7 @@ import (
context
"gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
blocks
"github.com/ipfs/go-ipfs/blocks"
blockstore
"github.com/ipfs/go-ipfs/blocks/blockstore"
blocksutil
"github.com/ipfs/go-ipfs/blocks/blocksutil"
key
"github.com/ipfs/go-ipfs/blocks/key"
tn
"github.com/ipfs/go-ipfs/exchange/bitswap/testnet"
...
...
@@ -278,6 +279,18 @@ func TestSendToWantingPeer(t *testing.T) {
}
func
TestEmptyKey
(
t
*
testing
.
T
)
{
net
:=
tn
.
VirtualNetwork
(
mockrouting
.
NewServer
(),
delay
.
Fixed
(
kNetworkDelay
))
sg
:=
NewTestSessionGenerator
(
net
)
defer
sg
.
Close
()
bs
:=
sg
.
Instances
(
1
)[
0
]
.
Exchange
_
,
err
:=
bs
.
GetBlock
(
context
.
Background
(),
key
.
Key
(
""
))
if
err
!=
blockstore
.
ErrNotFound
{
t
.
Error
(
"empty str key should return ErrNotFound"
)
}
}
func
TestBasicBitswap
(
t
*
testing
.
T
)
{
net
:=
tn
.
VirtualNetwork
(
mockrouting
.
NewServer
(),
delay
.
Fixed
(
kNetworkDelay
))
sg
:=
NewTestSessionGenerator
(
net
)
...
...
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