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

import (
	"testing"

6
	key "github.com/ipfs/go-ipfs/blocks/key"
7
	peer "gx/ipfs/QmccGfZs3rzku8Bv6sTPH3bMUKD1EVod8srgRjt5csdmva/go-libp2p/p2p/peer"
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
8

9
	context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/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 := key.Key("test")
17
	p.AddProvider(ctx, a, peer.ID("testingprovider"))
18
	resp := p.GetProviders(ctx, a)
19 20 21
	if len(resp) != 1 {
		t.Fatal("Could not retrieve provider.")
	}
22
	p.proc.Close()
23
}