diff --git a/dht_test.go b/dht_test.go index 2e5196120..0c23d0398 100644 --- a/dht_test.go +++ b/dht_test.go @@ -5,8 +5,6 @@ import ( "context" "errors" "fmt" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "math/rand" "sort" "strings" @@ -14,6 +12,9 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + opts "github.com/libp2p/go-libp2p-kad-dht/opts" pb "github.com/libp2p/go-libp2p-kad-dht/pb" diff --git a/query.go b/query.go index 9f2e44233..d43549955 100644 --- a/query.go +++ b/query.go @@ -57,15 +57,9 @@ type queryFunc func(context.Context, peer.ID) (*dhtQueryResult, error) // Run runs the query at hand. pass in a list of peers to use first. func (q *dhtQuery) Run(ctx context.Context, peers []peer.ID) (*dhtQueryResult, error) { - select { - case <-ctx.Done(): + if ctx.Err() != nil { return nil, ctx.Err() - default: } - - ctx, cancel := context.WithCancel(ctx) - defer cancel() - runner := newQueryRunner(q) return runner.Run(ctx, peers) }