-
Notifications
You must be signed in to change notification settings - Fork 199
/
feeHandlerStub.go
196 lines (168 loc) · 6.26 KB
/
feeHandlerStub.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
package mock
import (
"math/big"
"github.com/ElrondNetwork/elrond-go-core/data"
)
// FeeHandlerStub -
type FeeHandlerStub struct {
SetMaxGasLimitPerBlockCalled func(maxGasLimitPerBlock uint64)
SetMinGasPriceCalled func(minGasPrice uint64)
SetMinGasLimitCalled func(minGasLimit uint64)
MaxGasLimitPerBlockCalled func() uint64
ComputeGasLimitCalled func(tx data.TransactionWithFeeHandler) uint64
ComputeMoveBalanceFeeCalled func(tx data.TransactionWithFeeHandler) *big.Int
ComputeTxFeeCalled func(tx data.TransactionWithFeeHandler) *big.Int
CheckValidityTxValuesCalled func(tx data.TransactionWithFeeHandler) error
DeveloperPercentageCalled func() float64
MinGasPriceCalled func() uint64
GasPriceModifierCalled func() float64
ComputeFeeForProcessingCalled func(tx data.TransactionWithFeeHandler, gasToUse uint64) *big.Int
GenesisTotalSupplyCalled func() *big.Int
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)
}
// ComputeFeeForProcessing -
func (fhs *FeeHandlerStub) ComputeFeeForProcessing(tx data.TransactionWithFeeHandler, gasToUse uint64) *big.Int {
if fhs.ComputeFeeForProcessingCalled != nil {
return fhs.ComputeFeeForProcessingCalled(tx, gasToUse)
}
return big.NewInt(0)
}
// ComputeGasLimitBasedOnBalance -
func (fhs *FeeHandlerStub) ComputeGasLimitBasedOnBalance(tx data.TransactionWithFeeHandler, balance *big.Int) (uint64, error) {
if fhs.ComputeGasLimitBasedOnBalanceCalled != nil {
return fhs.ComputeGasLimitBasedOnBalanceCalled(tx, balance)
}
return 0, nil
}
// GasPriceModifier -
func (fhs *FeeHandlerStub) GasPriceModifier() float64 {
if fhs.GasPriceModifierCalled != nil {
return fhs.GasPriceModifierCalled()
}
return 1.0
}
// MinGasPrice -
func (fhs *FeeHandlerStub) MinGasPrice() uint64 {
if fhs.MinGasPriceCalled != nil {
return fhs.MinGasPriceCalled()
}
return 0
}
// MinGasLimit will return min gas limit
func (fhs *FeeHandlerStub) MinGasLimit() uint64 {
return 0
}
// DeveloperPercentage -
func (fhs *FeeHandlerStub) DeveloperPercentage() float64 {
if fhs.DeveloperPercentageCalled != nil {
return fhs.DeveloperPercentageCalled()
}
return 0.0
}
// GasPerDataByte -
func (fhs *FeeHandlerStub) GasPerDataByte() uint64 {
return 0
}
// SetMaxGasLimitPerBlock -
func (fhs *FeeHandlerStub) SetMaxGasLimitPerBlock(maxGasLimitPerBlock uint64) {
fhs.SetMaxGasLimitPerBlockCalled(maxGasLimitPerBlock)
}
// SetMinGasPrice -
func (fhs *FeeHandlerStub) SetMinGasPrice(minGasPrice uint64) {
fhs.SetMinGasPriceCalled(minGasPrice)
}
// SetMinGasLimit -
func (fhs *FeeHandlerStub) SetMinGasLimit(minGasLimit uint64) {
fhs.SetMinGasLimitCalled(minGasLimit)
}
// MaxGasLimitPerBlock -
func (fhs *FeeHandlerStub) MaxGasLimitPerBlock(uint32) uint64 {
return fhs.MaxGasLimitPerBlockCalled()
}
// ComputeGasLimit -
func (fhs *FeeHandlerStub) ComputeGasLimit(tx data.TransactionWithFeeHandler) uint64 {
if fhs.ComputeGasLimitCalled != nil {
return fhs.ComputeGasLimitCalled(tx)
}
return 0
}
// ComputeMoveBalanceFee -
func (fhs *FeeHandlerStub) ComputeMoveBalanceFee(tx data.TransactionWithFeeHandler) *big.Int {
if fhs.ComputeMoveBalanceFeeCalled != nil {
return fhs.ComputeMoveBalanceFeeCalled(tx)
}
return big.NewInt(0)
}
// ComputeTxFee -
func (fhs *FeeHandlerStub) ComputeTxFee(tx data.TransactionWithFeeHandler) *big.Int {
if fhs.ComputeTxFeeCalled != nil {
return fhs.ComputeTxFeeCalled(tx)
}
return big.NewInt(0)
}
// GenesisTotalSupply -
func (fhs *FeeHandlerStub) GenesisTotalSupply() *big.Int {
if fhs.GenesisTotalSupplyCalled != nil {
return fhs.GenesisTotalSupplyCalled()
}
return big.NewInt(0)
}
// CheckValidityTxValues -
func (fhs *FeeHandlerStub) CheckValidityTxValues(tx data.TransactionWithFeeHandler) error {
if fhs.CheckValidityTxValuesCalled != nil {
return fhs.CheckValidityTxValuesCalled(tx)
}
return nil
}
// SplitTxGasInCategories -
func (fhs *FeeHandlerStub) SplitTxGasInCategories(tx data.TransactionWithFeeHandler) (uint64, uint64) {
if fhs.SplitTxGasInCategoriesCalled != nil {
return fhs.SplitTxGasInCategoriesCalled(tx)
}
return 0, 0
}
// GasPriceForProcessing -
func (fhs *FeeHandlerStub) GasPriceForProcessing(tx data.TransactionWithFeeHandler) uint64 {
if fhs.GasPriceForProcessingCalled != nil {
return fhs.GasPriceForProcessingCalled(tx)
}
return 0
}
// GasPriceForMove -
func (fhs *FeeHandlerStub) GasPriceForMove(tx data.TransactionWithFeeHandler) uint64 {
if fhs.GasPriceForMoveCalled != nil {
return fhs.GasPriceForMoveCalled(tx)
}
return 0
}
// MinGasPriceForProcessing -
func (fhs *FeeHandlerStub) MinGasPriceForProcessing() uint64 {
if fhs.MinGasPriceForProcessingCalled != nil {
return fhs.MinGasPriceForProcessingCalled()
}
return 0
}
// ComputeGasUsedAndFeeBasedOnRefundValue -
func (fhs *FeeHandlerStub) ComputeGasUsedAndFeeBasedOnRefundValue(tx data.TransactionWithFeeHandler, refundValue *big.Int) (uint64, *big.Int) {
if fhs.ComputeGasUsedAndFeeBasedOnRefundValueCalled != nil {
return fhs.ComputeGasUsedAndFeeBasedOnRefundValueCalled(tx, refundValue)
}
return 0, big.NewInt(0)
}
// ComputeTxFeeBasedOnGasUsed -
func (fhs *FeeHandlerStub) ComputeTxFeeBasedOnGasUsed(tx data.TransactionWithFeeHandler, gasUsed uint64) *big.Int {
if fhs.ComputeTxFeeBasedOnGasUsedCalled != nil {
return fhs.ComputeTxFeeBasedOnGasUsedCalled(tx, gasUsed)
}
return big.NewInt(0)
}
// IsInterfaceNil returns true if there is no value under the interface
func (fhs *FeeHandlerStub) IsInterfaceNil() bool {
return fhs == nil
}