mirror of
https://github.com/fluencelabs/go-libp2p-kad-dht
synced 2025-05-29 06:01:20 +00:00
This commit makes GetProviders (sync) respect the request context. It also amends all of GetProviders' callsites to pass a context in. This meant changing the signature of the dht's handlerfunc. I think I'll start referring to the request context as Vito Corleone. cc @whyrusleeping @jbenet License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
24 lines
519 B
Go
24 lines
519 B
Go
package dht
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/jbenet/go-ipfs/peer"
|
|
u "github.com/jbenet/go-ipfs/util"
|
|
|
|
context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
|
|
)
|
|
|
|
func TestProviderManager(t *testing.T) {
|
|
ctx := context.Background()
|
|
mid := peer.ID("testing")
|
|
p := NewProviderManager(ctx, mid)
|
|
a := u.Key("test")
|
|
p.AddProvider(a, peer.WithIDString("testingprovider"))
|
|
resp := p.GetProviders(ctx, a)
|
|
if len(resp) != 1 {
|
|
t.Fatal("Could not retrieve provider.")
|
|
}
|
|
p.Close()
|
|
}
|