go-libp2p-kad-dht/providers_test.go
Brian Tiger Chow add43e52a4 fix(dht/routing) make GetProviders respect context
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>
2014-12-05 20:56:27 -08:00

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()
}