forked from libp2p/go-libp2p-routing-helpers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnull_test.go
33 lines (30 loc) · 776 Bytes
/
null_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package routinghelpers
import (
"context"
"testing"
"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/core/routing"
)
func TestNull(t *testing.T) {
var n Null
ctx := context.Background()
if err := n.PutValue(ctx, "anything", nil); err != routing.ErrNotSupported {
t.Fatal(err)
}
if _, err := n.GetValue(ctx, "anything", nil); err != routing.ErrNotFound {
t.Fatal(err)
}
if err := n.Provide(ctx, cid.Cid{}, false); err != routing.ErrNotSupported {
t.Fatal(err)
}
if _, ok := <-n.FindProvidersAsync(ctx, cid.Cid{}, 10); ok {
t.Fatal("expected no values")
}
if _, err := n.FindPeer(ctx, peer.ID("thing")); err != routing.ErrNotFound {
t.Fatal(err)
}
if err := n.Close(); err != nil {
t.Fatal(err)
}
}