-
Notifications
You must be signed in to change notification settings - Fork 199
/
nodesSetupStub.go
189 lines (161 loc) · 5.31 KB
/
nodesSetupStub.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
package mock
import "github.com/multiversx/mx-chain-go/sharding/nodesCoordinator"
// NodesSetupStub -
type NodesSetupStub struct {
InitialNodesInfoForShardCalled func(shardId uint32) ([]nodesCoordinator.GenesisNodeInfoHandler, []nodesCoordinator.GenesisNodeInfoHandler, error)
InitialNodesInfoCalled func() (map[uint32][]nodesCoordinator.GenesisNodeInfoHandler, map[uint32][]nodesCoordinator.GenesisNodeInfoHandler)
GetStartTimeCalled func() int64
GetRoundDurationCalled func() uint64
GetChainIdCalled func() string
GetMinTransactionVersionCalled func() uint32
GetShardConsensusGroupSizeCalled func() uint32
GetMetaConsensusGroupSizeCalled func() uint32
NumberOfShardsCalled func() uint32
MinNumberOfNodesCalled func() uint32
MinNumberOfShardNodesCalled func() uint32
MinNumberOfMetaNodesCalled func() uint32
GetHysteresisCalled func() float32
GetAdaptivityCalled func() bool
AllInitialNodesCalled func() []nodesCoordinator.GenesisNodeInfoHandler
GetShardIDForPubKeyCalled func(pubkey []byte) (uint32, error)
InitialEligibleNodesPubKeysForShardCalled func(shardId uint32) ([]string, error)
InitialNodesPubKeysCalled func() map[uint32][]string
MinNumberOfNodesWithHysteresisCalled func() uint32
}
// MinNumberOfShardNodes -
func (n *NodesSetupStub) MinNumberOfShardNodes() uint32 {
if n.MinNumberOfShardNodesCalled != nil {
return n.MinNumberOfShardNodesCalled()
}
return 1
}
// MinNumberOfMetaNodes -
func (n *NodesSetupStub) MinNumberOfMetaNodes() uint32 {
if n.MinNumberOfMetaNodesCalled != nil {
return n.MinNumberOfMetaNodesCalled()
}
return 1
}
// GetHysteresis -
func (n *NodesSetupStub) GetHysteresis() float32 {
if n.GetHysteresisCalled != nil {
return n.GetHysteresisCalled()
}
return 0
}
// GetAdaptivity -
func (n *NodesSetupStub) GetAdaptivity() bool {
if n.GetAdaptivityCalled != nil {
return n.GetAdaptivityCalled()
}
return false
}
// MinNumberOfNodes -
func (n *NodesSetupStub) MinNumberOfNodes() uint32 {
if n.MinNumberOfNodesCalled != nil {
return n.MinNumberOfNodesCalled()
}
return 0
}
// GetStartTime -
func (n *NodesSetupStub) GetStartTime() int64 {
if n.GetStartTimeCalled != nil {
return n.GetStartTimeCalled()
}
return 0
}
// GetRoundDuration -
func (n *NodesSetupStub) GetRoundDuration() uint64 {
if n.GetRoundDurationCalled != nil {
return n.GetRoundDurationCalled()
}
return 0
}
// GetChainId -
func (n *NodesSetupStub) GetChainId() string {
if n.GetChainIdCalled != nil {
return n.GetChainIdCalled()
}
return "chainID"
}
// GetMinTransactionVersion -
func (n *NodesSetupStub) GetMinTransactionVersion() uint32 {
if n.GetMinTransactionVersionCalled != nil {
return n.GetMinTransactionVersionCalled()
}
return 1
}
// GetShardConsensusGroupSize -
func (n *NodesSetupStub) GetShardConsensusGroupSize() uint32 {
if n.GetShardConsensusGroupSizeCalled != nil {
return n.GetShardConsensusGroupSizeCalled()
}
return 0
}
// GetMetaConsensusGroupSize -
func (n *NodesSetupStub) GetMetaConsensusGroupSize() uint32 {
if n.GetMetaConsensusGroupSizeCalled != nil {
return n.GetMetaConsensusGroupSizeCalled()
}
return 0
}
// NumberOfShards -
func (n *NodesSetupStub) NumberOfShards() uint32 {
if n.NumberOfShardsCalled != nil {
return n.NumberOfShardsCalled()
}
return 0
}
// InitialNodesInfoForShard -
func (n *NodesSetupStub) InitialNodesInfoForShard(shardId uint32) ([]nodesCoordinator.GenesisNodeInfoHandler, []nodesCoordinator.GenesisNodeInfoHandler, error) {
if n.InitialNodesInfoForShardCalled != nil {
return n.InitialNodesInfoForShardCalled(shardId)
}
return nil, nil, nil
}
// InitialNodesInfo -
func (n *NodesSetupStub) InitialNodesInfo() (map[uint32][]nodesCoordinator.GenesisNodeInfoHandler, map[uint32][]nodesCoordinator.GenesisNodeInfoHandler) {
if n.InitialNodesInfoCalled != nil {
return n.InitialNodesInfoCalled()
}
return nil, nil
}
// AllInitialNodes -
func (n *NodesSetupStub) AllInitialNodes() []nodesCoordinator.GenesisNodeInfoHandler {
if n.AllInitialNodesCalled != nil {
return n.AllInitialNodesCalled()
}
return nil
}
// GetShardIDForPubKey -
func (n *NodesSetupStub) GetShardIDForPubKey(pubkey []byte) (uint32, error) {
if n.GetShardIDForPubKeyCalled != nil {
return n.GetShardIDForPubKeyCalled(pubkey)
}
return 0, nil
}
// InitialEligibleNodesPubKeysForShard -
func (n *NodesSetupStub) InitialEligibleNodesPubKeysForShard(shardId uint32) ([]string, error) {
if n.InitialEligibleNodesPubKeysForShardCalled != nil {
return n.InitialEligibleNodesPubKeysForShardCalled(shardId)
}
return []string{"val1", "val2"}, nil
}
// InitialNodesPubKeys -
func (n *NodesSetupStub) InitialNodesPubKeys() map[uint32][]string {
if n.InitialNodesPubKeysCalled != nil {
return n.InitialNodesPubKeysCalled()
}
return map[uint32][]string{0: {"val1", "val2"}}
}
// MinNumberOfNodesWithHysteresis -
func (n *NodesSetupStub) MinNumberOfNodesWithHysteresis() uint32 {
if n.MinNumberOfNodesWithHysteresisCalled != nil {
return n.MinNumberOfNodesWithHysteresisCalled()
}
return n.MinNumberOfNodes()
}
// IsInterfaceNil -
func (n *NodesSetupStub) IsInterfaceNil() bool {
return n == nil
}