-
Notifications
You must be signed in to change notification settings - Fork 199
/
InterceptorStub.go
35 lines (29 loc) · 1.01 KB
/
InterceptorStub.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
package mock
import (
"github.com/ElrondNetwork/elrond-go/core"
"github.com/ElrondNetwork/elrond-go/p2p"
"github.com/ElrondNetwork/elrond-go/process"
)
// InterceptorStub -
type InterceptorStub struct {
ProcessReceivedMessageCalled func(message p2p.MessageP2P) error
RegisterHandlerCalled func(handler func(topic string, hash []byte, data interface{}))
}
// ProcessReceivedMessage -
func (is *InterceptorStub) ProcessReceivedMessage(message p2p.MessageP2P, _ core.PeerID) error {
return is.ProcessReceivedMessageCalled(message)
}
// SetInterceptedDebugHandler -
func (is *InterceptorStub) SetInterceptedDebugHandler(_ process.InterceptedDebugger) error {
return nil
}
// RegisterHandler -
func (is *InterceptorStub) RegisterHandler(handler func(topic string, hash []byte, data interface{})) {
if is.RegisterHandlerCalled != nil {
is.RegisterHandlerCalled(handler)
}
}
// IsInterfaceNil returns true if there is no value under the interface
func (is *InterceptorStub) IsInterfaceNil() bool {
return is == nil
}