-
Notifications
You must be signed in to change notification settings - Fork 3
/
host.go
77 lines (60 loc) · 1.81 KB
/
host.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
package mocks
import (
"context"
"github.com/libp2p/go-libp2p/core/connmgr"
"github.com/libp2p/go-libp2p/core/event"
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/core/peerstore"
"github.com/libp2p/go-libp2p/core/protocol"
multiaddr "github.com/multiformats/go-multiaddr"
)
// MockHost provides a mock implementation of host.Host for unit testing.
type MockHost struct {
PeerStore peerstore.Peerstore
}
var _ host.Host = &MockHost{}
func (*MockHost) Addrs() []multiaddr.Multiaddr {
panic("unimplemented")
}
func (*MockHost) Close() error {
panic("unimplemented")
}
func (*MockHost) ConnManager() connmgr.ConnManager {
panic("unimplemented")
}
func (*MockHost) Connect(ctx context.Context, pi peer.AddrInfo) error {
panic("unimplemented")
}
func (*MockHost) EventBus() event.Bus {
panic("unimplemented")
}
// ID returns the peer ID of this host.
func (*MockHost) ID() peer.ID {
return "localhost-peer-for-unit-testing"
}
func (*MockHost) Mux() protocol.Switch {
panic("unimplemented")
}
func (*MockHost) Network() network.Network {
panic("unimplemented")
}
func (*MockHost) NewStream(ctx context.Context, p peer.ID, pids ...protocol.ID) (network.Stream, error) {
panic("unimplemented")
}
// Peerstore returns the mocked peerstore of this host.
func (m *MockHost) Peerstore() peerstore.Peerstore {
return m.PeerStore
}
func (*MockHost) RemoveStreamHandler(pid protocol.ID) {
panic("unimplemented")
}
func (*MockHost) SetStreamHandler(pid protocol.ID, handler network.StreamHandler) {
panic("unimplemented")
}
func (*MockHost) SetStreamHandlerMatch(protocol.ID, func(protocol.ID) bool, network.StreamHandler) {
panic("unimplemented")
}