Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

context.TODO() a few places that now require a context #78

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions impl/graphsync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ func TestUnixFSFetch(t *testing.T) {
return nil, errors.New("Incorrect Link Type")
}
// read block from one store
block, err := bs.Get(c.Cid)
block, err := bs.Get(context.TODO(), c.Cid)
if err != nil {
return nil, err
}
Expand All @@ -867,7 +867,7 @@ func TestUnixFSFetch(t *testing.T) {
if err != nil {
return err
}
return bs.Put(block)
return bs.Put(context.TODO(), block)
}
return &buf, committer, nil
}
Expand Down
5 changes: 3 additions & 2 deletions storeutil/storeutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package storeutil

import (
"bytes"
"context"
"fmt"
"io"

Expand All @@ -19,7 +20,7 @@ func LoaderForBlockstore(bs bstore.Blockstore) ipld.Loader {
if !ok {
return nil, fmt.Errorf("Unsupported Link Type")
}
block, err := bs.Get(asCidLink.Cid)
block, err := bs.Get(context.TODO(), asCidLink.Cid)
if err != nil {
return nil, err
}
Expand All @@ -41,7 +42,7 @@ func StorerForBlockstore(bs bstore.Blockstore) ipld.Storer {
if err != nil {
return err
}
return bs.Put(block)
return bs.Put(context.TODO(), block)
}
return &buffer, committer, nil
}
Expand Down
7 changes: 5 additions & 2 deletions storeutil/storeutil_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package storeutil

import (
"context"
"io/ioutil"
"testing"

Expand All @@ -16,9 +17,10 @@ import (
)

func TestLoader(t *testing.T) {
ctx := context.Background()
store := bstore.NewBlockstore(dss.MutexWrap(datastore.NewMapDatastore()))
blk := testutil.GenerateBlocksOfSize(1, 1000)[0]
err := store.Put(blk)
err := store.Put(ctx, blk)
require.NoError(t, err, "Unable to put block to store")
loader := LoaderForBlockstore(store)
data, err := loader(cidlink.Link{Cid: blk.Cid()}, ipld.LinkContext{})
Expand All @@ -30,6 +32,7 @@ func TestLoader(t *testing.T) {
}

func TestStorer(t *testing.T) {
ctx := context.Background()
store := bstore.NewBlockstore(dss.MutexWrap(datastore.NewMapDatastore()))
blk := testutil.GenerateBlocksOfSize(1, 1000)[0]
storer := StorerForBlockstore(store)
Expand All @@ -39,6 +42,6 @@ func TestStorer(t *testing.T) {
require.NoError(t, err, "Unable to write data to buffer")
err = commit(cidlink.Link{Cid: blk.Cid()})
require.NoError(t, err, "Unable to commit with storer function")
_, err = store.Get(blk.Cid())
_, err = store.Get(ctx, blk.Cid())
require.NoError(t, err, "Block not written to store")
}