providers_test.go 514 Bytes
Newer Older
1 2 3 4 5
package dht

import (
	"testing"

6
	peer "github.com/jbenet/go-ipfs/peer"
7
	u "github.com/jbenet/go-ipfs/util"
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
8 9

	context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
10 11 12
)

func TestProviderManager(t *testing.T) {
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
13
	ctx := context.Background()
14
	mid := peer.ID("testing")
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
15
	p := NewProviderManager(ctx, mid)
16
	a := u.Key("test")
17
	p.AddProvider(a, peer.ID("testingprovider"))
18
	resp := p.GetProviders(ctx, a)
19 20 21
	if len(resp) != 1 {
		t.Fatal("Could not retrieve provider.")
	}
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
22
	p.Close()
23
}