-
Notifications
You must be signed in to change notification settings - Fork 199
/
economicsHandlerMock.go
246 lines (211 loc) · 8.22 KB
/
economicsHandlerMock.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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
package economicsmocks
import (
"math/big"
"github.com/ElrondNetwork/elrond-go-core/data"
)
// EconomicsHandlerMock -
type EconomicsHandlerMock struct {
MaxInflationRateCalled func(year uint32) float64
MinInflationRateCalled func() float64
LeaderPercentageCalled func() float64
ProtocolSustainabilityPercentageCalled func() float64
ProtocolSustainabilityAddressCalled func() string
SetMaxGasLimitPerBlockCalled func(maxGasLimitPerBlock uint64)
SetMinGasPriceCalled func(minGasPrice uint64)
SetMinGasLimitCalled func(minGasLimit uint64)
MaxGasLimitPerBlockCalled func(shard uint32) uint64
ComputeGasLimitCalled func(tx data.TransactionWithFeeHandler) uint64
ComputeFeeCalled func(tx data.TransactionWithFeeHandler) *big.Int
CheckValidityTxValuesCalled func(tx data.TransactionWithFeeHandler) error
ComputeMoveBalanceFeeCalled func(tx data.TransactionWithFeeHandler) *big.Int
ComputeTxFeeCalled func(tx data.TransactionWithFeeHandler) *big.Int
DeveloperPercentageCalled func() float64
MinGasPriceCalled func() uint64
GasPerDataByteCalled func() uint64
RewardsTopUpGradientPointCalled func() *big.Int
RewardsTopUpFactorCalled func() float64
ComputeFeeForProcessingCalled func(tx data.TransactionWithFeeHandler, gasToUse uint64) *big.Int
GasPriceModifierCalled func() float64
SplitTxGasInCategoriesCalled func(tx data.TransactionWithFeeHandler) (uint64, uint64)
GasPriceForProcessingCalled func(tx data.TransactionWithFeeHandler) uint64
GasPriceForMoveCalled func(tx data.TransactionWithFeeHandler) uint64
MinGasPriceForProcessingCalled func() uint64
ComputeGasUsedAndFeeBasedOnRefundValueCalled func(tx data.TransactionWithFeeHandler, refundValue *big.Int) (uint64, *big.Int)
ComputeTxFeeBasedOnGasUsedCalled func(tx data.TransactionWithFeeHandler, gasUsed uint64) *big.Int
ComputeGasLimitBasedOnBalanceCalled func(tx data.TransactionWithFeeHandler, balance *big.Int) (uint64, error)
}
// LeaderPercentage -
func (ehm *EconomicsHandlerMock) LeaderPercentage() float64 {
return ehm.LeaderPercentageCalled()
}
// ProtocolSustainabilityPercentage will return the protocol sustainability percentage value
func (ehm *EconomicsHandlerMock) ProtocolSustainabilityPercentage() float64 {
return ehm.ProtocolSustainabilityPercentageCalled()
}
// ProtocolSustainabilityAddress will return the protocol sustainability address
func (ehm *EconomicsHandlerMock) ProtocolSustainabilityAddress() string {
return ehm.ProtocolSustainabilityAddressCalled()
}
// MinInflationRate -
func (ehm *EconomicsHandlerMock) MinInflationRate() float64 {
return ehm.MinInflationRateCalled()
}
// MaxInflationRate -
func (ehm *EconomicsHandlerMock) MaxInflationRate(year uint32) float64 {
return ehm.MaxInflationRateCalled(year)
}
// MinGasPrice -
func (ehm *EconomicsHandlerMock) MinGasPrice() uint64 {
if ehm.MinGasPriceCalled != nil {
return ehm.MinGasPriceCalled()
}
return 0
}
// MinGasLimit will return min gas limit
func (ehm *EconomicsHandlerMock) MinGasLimit() uint64 {
return 0
}
// GasPerDataByte -
func (ehm *EconomicsHandlerMock) GasPerDataByte() uint64 {
return 0
}
// DeveloperPercentage -
func (ehm *EconomicsHandlerMock) DeveloperPercentage() float64 {
return ehm.DeveloperPercentageCalled()
}
// GenesisTotalSupply -
func (ehm *EconomicsHandlerMock) GenesisTotalSupply() *big.Int {
return big.NewInt(0)
}
// SetMaxGasLimitPerBlock -
func (ehm *EconomicsHandlerMock) SetMaxGasLimitPerBlock(maxGasLimitPerBlock uint64) {
ehm.SetMaxGasLimitPerBlockCalled(maxGasLimitPerBlock)
}
// SetMinGasPrice -
func (ehm *EconomicsHandlerMock) SetMinGasPrice(minGasPrice uint64) {
ehm.SetMinGasPriceCalled(minGasPrice)
}
// SetMinGasLimit -
func (ehm *EconomicsHandlerMock) SetMinGasLimit(minGasLimit uint64) {
ehm.SetMinGasLimitCalled(minGasLimit)
}
// MaxGasLimitPerBlock -
func (ehm *EconomicsHandlerMock) MaxGasLimitPerBlock(shard uint32) uint64 {
return ehm.MaxGasLimitPerBlockCalled(shard)
}
// ComputeGasLimit -
func (ehm *EconomicsHandlerMock) ComputeGasLimit(tx data.TransactionWithFeeHandler) uint64 {
if ehm.ComputeGasLimitCalled != nil {
return ehm.ComputeGasLimitCalled(tx)
}
return 0
}
// ComputeFee -
func (ehm *EconomicsHandlerMock) ComputeFee(tx data.TransactionWithFeeHandler) *big.Int {
if ehm.ComputeFeeCalled != nil {
return ehm.ComputeFeeCalled(tx)
}
return big.NewInt(0)
}
// CheckValidityTxValues -
func (ehm *EconomicsHandlerMock) CheckValidityTxValues(tx data.TransactionWithFeeHandler) error {
if ehm.CheckValidityTxValuesCalled != nil {
return ehm.CheckValidityTxValuesCalled(tx)
}
return nil
}
// ComputeMoveBalanceFee -
func (ehm *EconomicsHandlerMock) ComputeMoveBalanceFee(tx data.TransactionWithFeeHandler) *big.Int {
if ehm.ComputeMoveBalanceFeeCalled != nil {
return ehm.ComputeMoveBalanceFeeCalled(tx)
}
return big.NewInt(0)
}
// ComputeGasLimitBasedOnBalance -
func (ehm *EconomicsHandlerMock) ComputeGasLimitBasedOnBalance(tx data.TransactionWithFeeHandler, balance *big.Int) (uint64, error) {
if ehm.ComputeGasLimitBasedOnBalanceCalled != nil {
return ehm.ComputeGasLimitBasedOnBalanceCalled(tx, balance)
}
return 0, nil
}
// ComputeTxFee -
func (ehm *EconomicsHandlerMock) ComputeTxFee(tx data.TransactionWithFeeHandler) *big.Int {
if ehm.ComputeTxFeeCalled != nil {
return ehm.ComputeTxFeeCalled(tx)
}
return big.NewInt(0)
}
// RewardsTopUpGradientPoint -
func (ehm *EconomicsHandlerMock) RewardsTopUpGradientPoint() *big.Int {
if ehm.RewardsTopUpGradientPointCalled != nil {
return ehm.RewardsTopUpGradientPointCalled()
}
return big.NewInt(0)
}
// RewardsTopUpFactor -
func (ehm *EconomicsHandlerMock) RewardsTopUpFactor() float64 {
if ehm.RewardsTopUpFactorCalled != nil {
return ehm.RewardsTopUpFactorCalled()
}
return 0
}
// ComputeFeeForProcessing -
func (ehm *EconomicsHandlerMock) ComputeFeeForProcessing(tx data.TransactionWithFeeHandler, gasToUse uint64) *big.Int {
if ehm.ComputeFeeForProcessingCalled != nil {
return ehm.ComputeFeeForProcessingCalled(tx, gasToUse)
}
return big.NewInt(0)
}
// GasPriceModifier -
func (ehm *EconomicsHandlerMock) GasPriceModifier() float64 {
if ehm.GasPriceModifierCalled != nil {
return ehm.GasPriceModifierCalled()
}
return 0
}
// SplitTxGasInCategories -
func (ehm *EconomicsHandlerMock) SplitTxGasInCategories(tx data.TransactionWithFeeHandler) (uint64, uint64) {
if ehm.SplitTxGasInCategoriesCalled != nil {
return ehm.SplitTxGasInCategoriesCalled(tx)
}
return 0, 0
}
// GasPriceForProcessing -
func (ehm *EconomicsHandlerMock) GasPriceForProcessing(tx data.TransactionWithFeeHandler) uint64 {
if ehm.GasPriceForProcessingCalled != nil {
return ehm.GasPriceForProcessingCalled(tx)
}
return 0
}
// GasPriceForMove -
func (ehm *EconomicsHandlerMock) GasPriceForMove(tx data.TransactionWithFeeHandler) uint64 {
if ehm.GasPriceForMoveCalled != nil {
return ehm.GasPriceForMoveCalled(tx)
}
return 0
}
// MinGasPriceForProcessing -
func (ehm *EconomicsHandlerMock) MinGasPriceForProcessing() uint64 {
if ehm.MinGasPriceForProcessingCalled != nil {
return ehm.MinGasPriceForProcessingCalled()
}
return 0
}
// ComputeGasUsedAndFeeBasedOnRefundValue -
func (ehm *EconomicsHandlerMock) ComputeGasUsedAndFeeBasedOnRefundValue(tx data.TransactionWithFeeHandler, refundValue *big.Int) (uint64, *big.Int) {
if ehm.ComputeGasUsedAndFeeBasedOnRefundValueCalled != nil {
return ehm.ComputeGasUsedAndFeeBasedOnRefundValueCalled(tx, refundValue)
}
return 0, big.NewInt(0)
}
// ComputeTxFeeBasedOnGasUsed -
func (ehm *EconomicsHandlerMock) ComputeTxFeeBasedOnGasUsed(tx data.TransactionWithFeeHandler, gasUsed uint64) *big.Int {
if ehm.ComputeTxFeeBasedOnGasUsedCalled != nil {
return ehm.ComputeTxFeeBasedOnGasUsedCalled(tx, gasUsed)
}
return big.NewInt(0)
}
// IsInterfaceNil returns true if there is no value under the interface
func (ehm *EconomicsHandlerMock) IsInterfaceNil() bool {
return ehm == nil
}