-
Notifications
You must be signed in to change notification settings - Fork 199
/
bootstrapMock.go
63 lines (51 loc) · 1.68 KB
/
bootstrapMock.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
package mock
import (
"github.com/ElrondNetwork/elrond-go/core"
"github.com/ElrondNetwork/elrond-go/data"
"github.com/ElrondNetwork/elrond-go/data/block"
)
// BootstrapperMock mocks the implementation for a Bootstrapper
type BootstrapperMock struct {
CreateAndCommitEmptyBlockCalled func(uint32) (data.BodyHandler, data.HeaderHandler, error)
AddSyncStateListenerCalled func(func(bool))
ShouldSyncCalled func() bool
StartSyncCalled func()
StopSyncCalled func()
SetStatusHandlerCalled func(handler core.AppStatusHandler) error
}
func (boot *BootstrapperMock) CreateAndCommitEmptyBlock(shardForCurrentNode uint32) (data.BodyHandler, data.HeaderHandler, error) {
if boot.CreateAndCommitEmptyBlockCalled != nil {
return boot.CreateAndCommitEmptyBlockCalled(shardForCurrentNode)
}
bb := make(block.Body, 0)
return bb, &block.Header{}, nil
}
func (boot *BootstrapperMock) AddSyncStateListener(syncStateNotifier func(isSyncing bool)) {
if boot.AddSyncStateListenerCalled != nil {
boot.AddSyncStateListenerCalled(syncStateNotifier)
return
}
return
}
func (boot *BootstrapperMock) ShouldSync() bool {
if boot.ShouldSyncCalled != nil {
return boot.ShouldSyncCalled()
}
return false
}
func (boot *BootstrapperMock) StartSync() {
boot.StartSyncCalled()
}
func (boot *BootstrapperMock) StopSync() {
boot.StopSyncCalled()
}
func (boot *BootstrapperMock) SetStatusHandler(handler core.AppStatusHandler) error {
return boot.SetStatusHandlerCalled(handler)
}
// IsInterfaceNil returns true if there is no value under the interface
func (boot *BootstrapperMock) IsInterfaceNil() bool {
if boot == nil {
return true
}
return false
}