-
Notifications
You must be signed in to change notification settings - Fork 0
/
hostinfo_test.go
34 lines (27 loc) · 675 Bytes
/
hostinfo_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
34
package hostinfo_test
import (
"context"
"testing"
"github.com/libp2p/go-libp2p"
"github.com/libp2p/go-libp2p/core/host"
"github.com/multiformats/go-multiaddr"
"github.com/stretchr/testify/assert"
hostinfo "github.com/drgomesp/go-libp2p-hostinfo"
)
func newHost(t *testing.T, listen multiaddr.Multiaddr) host.Host {
h, err := libp2p.New(
libp2p.ListenAddrs(listen),
)
if err != nil {
t.Fatal(err)
}
return h
}
func TestNewService(t *testing.T) {
ma, _ := multiaddr.NewMultiaddr("/ip4/127.0.0.1/tcp/10000")
h := newHost(t, ma)
defer h.Close()
svc, err := hostinfo.NewService(context.Background(), h)
assert.NoError(t, err)
assert.NotNil(t, svc)
}