blocks/blockstore: shift insertion of TODO context to tests
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
Jakub Sztandera committed
Jul 10, 2016 at 15:16 UTC
58526b25b52275faf29fba4f035a1de6a73187dc
2 files changed
+5
-5
blocks/blockstore/bloom_cache_test.go
+5
-2
@@ -15,6 +15,9 @@ import (
15
)
16
17
func testBloomCached(bs GCBlockstore, ctx context.Context) (*bloomcache, error) {
18
+ if ctx == nil {
19
+ ctx = context.TODO()
20
+ }
21
opts := DefaultCacheOpts()
22
bbs, err := CachedBlockstore(bs, ctx, opts)
23
if err == nil {
@@ -26,11 +29,11 @@ func testBloomCached(bs GCBlockstore, ctx context.Context) (*bloomcache, error)
29
30
func TestReturnsErrorWhenSizeNegative(t *testing.T) {
31
bs := NewBlockstore(syncds.MutexWrap(ds.NewMapDatastore()))
29
- _, err := bloomCached(bs, nil, 100, 1, -1)
32
+ _, err := bloomCached(bs, context.TODO(), 100, 1, -1)
33
if err == nil {
34
t.Fail()
35
}
33
- _, err = bloomCached(bs, nil, -1, 1, 100)
36
+ _, err = bloomCached(bs, context.TODO(), -1, 1, 100)
37
if err == nil {
38
t.Fail()
39
}
blocks/blockstore/caching.go
-3
@@ -23,9 +23,6 @@ func DefaultCacheOpts() CacheOpts {
23
24
func CachedBlockstore(bs GCBlockstore,
25
ctx context.Context, opts CacheOpts) (cbs GCBlockstore, err error) {
26
- if ctx == nil {
27
- ctx = context.TODO() // For tests
28
- }
26
cbs = bs
27
28
if opts.HasBloomFilterSize < 0 || opts.HasBloomFilterHashes < 0 ||