-
Notifications
You must be signed in to change notification settings - Fork 199
/
topicHandlerStub.go
43 lines (35 loc) · 1.22 KB
/
topicHandlerStub.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
package mock
import (
"github.com/ElrondNetwork/elrond-go-core/core"
"github.com/ElrondNetwork/elrond-go/p2p"
)
// TopicHandlerStub -
type TopicHandlerStub struct {
HasTopicCalled func(name string) bool
CreateTopicCalled func(name string, createChannelForTopic bool) error
RegisterMessageProcessorCalled func(topic string, identifier string, handler p2p.MessageProcessor) error
IDCalled func() core.PeerID
}
// HasTopic -
func (ths *TopicHandlerStub) HasTopic(name string) bool {
return ths.HasTopicCalled(name)
}
// CreateTopic -
func (ths *TopicHandlerStub) CreateTopic(name string, createChannelForTopic bool) error {
return ths.CreateTopicCalled(name, createChannelForTopic)
}
// RegisterMessageProcessor -
func (ths *TopicHandlerStub) RegisterMessageProcessor(topic string, identifier string, handler p2p.MessageProcessor) error {
return ths.RegisterMessageProcessorCalled(topic, identifier, handler)
}
// ID -
func (ths *TopicHandlerStub) ID() core.PeerID {
if ths.IDCalled != nil {
return ths.IDCalled()
}
return "peer ID"
}
// IsInterfaceNil returns true if there is no value under the interface
func (ths *TopicHandlerStub) IsInterfaceNil() bool {
return ths == nil
}