-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
fx_options_test.go
60 lines (49 loc) · 1.04 KB
/
fx_options_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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package libp2p
import (
"testing"
"github.com/libp2p/go-libp2p/core/event"
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/p2p/protocol/identify"
"github.com/stretchr/testify/require"
"go.uber.org/fx"
)
func TestGetPeerID(t *testing.T) {
var id peer.ID
host, err := New(
WithFxOption(fx.Populate(&id)),
)
require.NoError(t, err)
defer host.Close()
require.Equal(t, host.ID(), id)
}
func TestGetEventBus(t *testing.T) {
var eb event.Bus
host, err := New(
NoTransports,
WithFxOption(fx.Populate(&eb)),
)
require.NoError(t, err)
defer host.Close()
require.NotNil(t, eb)
}
func TestGetHost(t *testing.T) {
var h host.Host
host, err := New(
NoTransports,
WithFxOption(fx.Populate(&h)),
)
require.NoError(t, err)
defer host.Close()
require.NotNil(t, h)
}
func TestGetIDService(t *testing.T) {
var id identify.IDService
host, err := New(
NoTransports,
WithFxOption(fx.Populate(&id)),
)
require.NoError(t, err)
defer host.Close()
require.NotNil(t, id)
}