-
Notifications
You must be signed in to change notification settings - Fork 0
/
peersHolderStub.go
62 lines (51 loc) · 1.41 KB
/
peersHolderStub.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
package mock
import "github.com/kalyan3104/k-core/core"
// PeersHolderStub -
type PeersHolderStub struct {
PutConnectionAddressCalled func(peerID core.PeerID, address string)
PutShardIDCalled func(peerID core.PeerID, shardID uint32)
GetCalled func() map[uint32][]core.PeerID
ContainsCalled func(peerID core.PeerID) bool
RemoveCalled func(peerID core.PeerID)
ClearCalled func()
}
// PutConnectionAddress -
func (p *PeersHolderStub) PutConnectionAddress(peerID core.PeerID, address string) {
if p.PutConnectionAddressCalled != nil {
p.PutConnectionAddressCalled(peerID, address)
}
}
// PutShardID -
func (p *PeersHolderStub) PutShardID(peerID core.PeerID, shardID uint32) {
if p.PutShardIDCalled != nil {
p.PutShardIDCalled(peerID, shardID)
}
}
// Get -
func (p *PeersHolderStub) Get() map[uint32][]core.PeerID {
if p.GetCalled != nil {
return p.GetCalled()
}
return map[uint32][]core.PeerID{0: {"peer"}}
}
// Contains -
func (p *PeersHolderStub) Contains(peerID core.PeerID) bool {
if p.ContainsCalled != nil {
return p.ContainsCalled(peerID)
}
return false
}
// Remove -
func (p *PeersHolderStub) Remove(peerID core.PeerID) {
if p.RemoveCalled != nil {
p.RemoveCalled(peerID)
}
}
// Clear -
func (p *PeersHolderStub) Clear() {
p.ClearCalled()
}
// IsInterfaceNil -
func (p *PeersHolderStub) IsInterfaceNil() bool {
return p == nil
}