Commit 17aaaa9c authored by Jeromy Johnson's avatar Jeromy Johnson

Merge pull request #2716 from ipfs/patch-add-link-paths

Fix #2715 and patch add-link paths
parents 786bcdee 4abba348
...@@ -155,6 +155,9 @@ type blockRequest struct { ...@@ -155,6 +155,9 @@ type blockRequest struct {
// GetBlock attempts to retrieve a particular block from peers within the // GetBlock attempts to retrieve a particular block from peers within the
// deadline enforced by the context. // deadline enforced by the context.
func (bs *Bitswap) GetBlock(parent context.Context, k key.Key) (blocks.Block, error) { 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 // 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 // returns. To ensure this, derive a new context. Note that it is okay to
......
...@@ -11,6 +11,7 @@ import ( ...@@ -11,6 +11,7 @@ import (
context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
blocks "github.com/ipfs/go-ipfs/blocks" blocks "github.com/ipfs/go-ipfs/blocks"
blockstore "github.com/ipfs/go-ipfs/blocks/blockstore"
blocksutil "github.com/ipfs/go-ipfs/blocks/blocksutil" blocksutil "github.com/ipfs/go-ipfs/blocks/blocksutil"
key "github.com/ipfs/go-ipfs/blocks/key" key "github.com/ipfs/go-ipfs/blocks/key"
tn "github.com/ipfs/go-ipfs/exchange/bitswap/testnet" tn "github.com/ipfs/go-ipfs/exchange/bitswap/testnet"
...@@ -278,6 +279,18 @@ func TestSendToWantingPeer(t *testing.T) { ...@@ -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) { func TestBasicBitswap(t *testing.T) {
net := tn.VirtualNetwork(mockrouting.NewServer(), delay.Fixed(kNetworkDelay)) net := tn.VirtualNetwork(mockrouting.NewServer(), delay.Fixed(kNetworkDelay))
sg := NewTestSessionGenerator(net) sg := NewTestSessionGenerator(net)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment