-
Notifications
You must be signed in to change notification settings - Fork 199
/
consensusStateMock.go
116 lines (94 loc) · 3.88 KB
/
consensusStateMock.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package mock
import (
"github.com/ElrondNetwork/elrond-go/consensus"
"github.com/ElrondNetwork/elrond-go/sharding"
)
type ConsensusStateMock struct {
ResetConsensusStateCalled func()
IsNodeLeaderInCurrentRoundCalled func(node string) bool
IsSelfLeaderInCurrentRoundCalled func() bool
GetLeaderCalled func() (string, error)
GetNextConsensusGroupCalled func(randomSource string, vgs sharding.NodesCoordinator) ([]string, error)
IsConsensusDataSetCalled func() bool
IsConsensusDataEqualCalled func(data []byte) bool
IsJobDoneCalled func(node string, currentSubroundId int) bool
IsSelfJobDoneCalled func(currentSubroundId int) bool
IsCurrentSubroundFinishedCalled func(currentSubroundId int) bool
IsNodeSelfCalled func(node string) bool
IsBlockBodyAlreadyReceivedCalled func() bool
IsHeaderAlreadyReceivedCalled func() bool
CanDoSubroundJobCalled func(currentSubroundId int) bool
CanProcessReceivedMessageCalled func(cnsDta consensus.Message, currentRoundIndex int32, currentSubroundId int) bool
GenerateBitmapCalled func(subroundId int) []byte
ProcessingBlockCalled func() bool
SetProcessingBlockCalled func(processingBlock bool)
ConsensusGroupSizeCalled func() int
SetThresholdCalled func(subroundId int, threshold int)
}
func (cnsm *ConsensusStateMock) ResetConsensusState() {
cnsm.ResetConsensusStateCalled()
}
func (cnsm *ConsensusStateMock) IsNodeLeaderInCurrentRound(node string) bool {
return cnsm.IsNodeLeaderInCurrentRoundCalled(node)
}
func (cnsm *ConsensusStateMock) IsSelfLeaderInCurrentRound() bool {
return cnsm.IsSelfLeaderInCurrentRoundCalled()
}
func (cnsm *ConsensusStateMock) GetLeader() (string, error) {
return cnsm.GetLeaderCalled()
}
func (cnsm *ConsensusStateMock) GetNextConsensusGroup(
randomSource string,
vgs sharding.NodesCoordinator,
) ([]string, error) {
return cnsm.GetNextConsensusGroupCalled(randomSource, vgs)
}
func (cnsm *ConsensusStateMock) IsConsensusDataSet() bool {
return cnsm.IsConsensusDataSetCalled()
}
func (cnsm *ConsensusStateMock) IsConsensusDataEqual(data []byte) bool {
return cnsm.IsConsensusDataEqualCalled(data)
}
func (cnsm *ConsensusStateMock) IsJobDone(node string, currentSubroundId int) bool {
return cnsm.IsJobDoneCalled(node, currentSubroundId)
}
func (cnsm *ConsensusStateMock) IsSelfJobDone(currentSubroundId int) bool {
return cnsm.IsSelfJobDoneCalled(currentSubroundId)
}
func (cnsm *ConsensusStateMock) IsCurrentSubroundFinished(currentSubroundId int) bool {
return cnsm.IsCurrentSubroundFinishedCalled(currentSubroundId)
}
func (cnsm *ConsensusStateMock) IsNodeSelf(node string) bool {
return cnsm.IsNodeSelfCalled(node)
}
func (cnsm *ConsensusStateMock) IsBlockBodyAlreadyReceived() bool {
return cnsm.IsBlockBodyAlreadyReceivedCalled()
}
func (cnsm *ConsensusStateMock) IsHeaderAlreadyReceived() bool {
return cnsm.IsHeaderAlreadyReceivedCalled()
}
func (cnsm *ConsensusStateMock) CanDoSubroundJob(currentSubroundId int) bool {
return cnsm.CanDoSubroundJobCalled(currentSubroundId)
}
func (cnsm *ConsensusStateMock) CanProcessReceivedMessage(
cnsDta consensus.Message,
currentRoundIndex int32,
currentSubroundId int,
) bool {
return cnsm.CanProcessReceivedMessageCalled(cnsDta, currentRoundIndex, currentSubroundId)
}
func (cnsm *ConsensusStateMock) GenerateBitmap(subroundId int) []byte {
return cnsm.GenerateBitmapCalled(subroundId)
}
func (cnsm *ConsensusStateMock) ProcessingBlock() bool {
return cnsm.ProcessingBlockCalled()
}
func (cnsm *ConsensusStateMock) SetProcessingBlock(processingBlock bool) {
cnsm.SetProcessingBlockCalled(processingBlock)
}
func (cnsm *ConsensusStateMock) ConsensusGroupSize() int {
return cnsm.ConsensusGroupSizeCalled()
}
func (cnsm *ConsensusStateMock) SetThreshold(subroundId int, threshold int) {
cnsm.SetThresholdCalled(subroundId, threshold)
}