Skip to content

Commit

Permalink
fix staticcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed May 19, 2021
1 parent 68136fb commit 5ac879d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
10 changes: 5 additions & 5 deletions dummy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/routing"

cid "github.com/ipfs/go-cid"
"github.com/ipfs/go-cid"
)

type testCloser struct {
Expand All @@ -23,17 +23,17 @@ func (closer *testCloser) Close() error {

type failValueStore struct{}

var failValueErr = errors.New("fail valuestore error")
var errFailValue = errors.New("fail valuestore error")

func (f failValueStore) PutValue(ctx context.Context, key string, value []byte, opts ...routing.Option) error {
return failValueErr
return errFailValue
}
func (f failValueStore) GetValue(ctx context.Context, key string, opts ...routing.Option) ([]byte, error) {
return nil, failValueErr
return nil, errFailValue
}

func (f failValueStore) SearchValue(ctx context.Context, key string, opts ...routing.Option) (<-chan []byte, error) {
return nil, failValueErr
return nil, errFailValue
}

type dummyValueStore sync.Map
Expand Down
4 changes: 2 additions & 2 deletions parallel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ func TestParallelPutFailure(t *testing.T) {
},
}
err := router.PutValue(ctx, "/some/thing", []byte("thing"))
if err != failValueErr {
t.Fatalf("exected put to fail with %q, got %q", failValueErr, err)
if err != errFailValue {
t.Fatalf("exected put to fail with %q, got %q", errFailValue, err)
}
}

Expand Down
6 changes: 3 additions & 3 deletions tiered.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/routing"

multierror "github.com/hashicorp/go-multierror"
cid "github.com/ipfs/go-cid"
"github.com/hashicorp/go-multierror"
"github.com/ipfs/go-cid"
record "github.com/libp2p/go-libp2p-record"
)

Expand Down Expand Up @@ -66,7 +66,7 @@ func (r Tiered) GetValue(ctx context.Context, key string, opts ...routing.Option
// returning results in monotonically increasing "freshness" from all
// sub-routers.
func (r Tiered) SearchValue(ctx context.Context, key string, opts ...routing.Option) (<-chan []byte, error) {
return Parallel{Routers: r.Routers, Validator: r.Validator}.SearchValue(ctx, key, opts...)
return Parallel(r).SearchValue(ctx, key, opts...)
}

// GetPublicKey sequentially searches each sub-router for the the public key,
Expand Down
7 changes: 3 additions & 4 deletions tiered_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

record "github.com/libp2p/go-libp2p-record"

errwrap "github.com/hashicorp/errwrap"
cid "github.com/ipfs/go-cid"
"github.com/hashicorp/errwrap"
"github.com/ipfs/go-cid"
)

type testValidator struct{}
Expand Down Expand Up @@ -100,8 +100,7 @@ func TestTieredSearch(t *testing.T) {
t.Fatal(err)
}

v, ok = <-valch
if !ok {
if _, ok := <-valch; !ok {
t.Fatal("expected to get a value")
}

Expand Down

0 comments on commit 5ac879d

Please sign in to comment.