-
Notifications
You must be signed in to change notification settings - Fork 198
/
gasHandlerMock.go
143 lines (125 loc) · 4.14 KB
/
gasHandlerMock.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
package mock
import (
"github.com/ElrondNetwork/elrond-go-core/data"
"github.com/ElrondNetwork/elrond-go-core/data/block"
)
// GasHandlerMock -
type GasHandlerMock struct {
InitCalled func()
SetGasConsumedCalled func(gasConsumed uint64, hash []byte)
SetGasRefundedCalled func(gasRefunded uint64, hash []byte)
SetGasPenalizedCalled func(gasPenalized uint64, hash []byte)
GasConsumedCalled func(hash []byte) uint64
GasRefundedCalled func(hash []byte) uint64
GasPenalizedCalled func(hash []byte) uint64
TotalGasConsumedCalled func() uint64
TotalGasRefundedCalled func() uint64
TotalGasPenalizedCalled func() uint64
RemoveGasConsumedCalled func(hashes [][]byte)
RemoveGasRefundedCalled func(hashes [][]byte)
RemoveGasPenalizedCalled func(hashes [][]byte)
ComputeGasConsumedByMiniBlockCalled func(miniBlock *block.MiniBlock, mapHashTx map[string]data.TransactionHandler) (uint64, uint64, error)
ComputeGasConsumedByTxCalled func(txSenderShardId uint32, txReceiverSharedId uint32, txHandler data.TransactionHandler) (uint64, uint64, error)
}
// Init -
func (ghm *GasHandlerMock) Init() {
if ghm.InitCalled != nil {
ghm.InitCalled()
}
}
// SetGasConsumed -
func (ghm *GasHandlerMock) SetGasConsumed(gasConsumed uint64, hash []byte) {
if ghm.SetGasConsumedCalled != nil {
ghm.SetGasConsumedCalled(gasConsumed, hash)
}
}
// SetGasRefunded -
func (ghm *GasHandlerMock) SetGasRefunded(gasRefunded uint64, hash []byte) {
if ghm.SetGasRefundedCalled != nil {
ghm.SetGasRefundedCalled(gasRefunded, hash)
}
}
// SetGasPenalized -
func (ghm *GasHandlerMock) SetGasPenalized(gasPenalized uint64, hash []byte) {
if ghm.SetGasPenalizedCalled != nil {
ghm.SetGasPenalizedCalled(gasPenalized, hash)
}
}
// GasConsumed -
func (ghm *GasHandlerMock) GasConsumed(hash []byte) uint64 {
if ghm.GasConsumedCalled != nil {
return ghm.GasConsumedCalled(hash)
}
return 0
}
// GasRefunded -
func (ghm *GasHandlerMock) GasRefunded(hash []byte) uint64 {
if ghm.GasRefundedCalled != nil {
return ghm.GasRefundedCalled(hash)
}
return 0
}
// GasPenalized -
func (ghm *GasHandlerMock) GasPenalized(hash []byte) uint64 {
if ghm.GasPenalizedCalled != nil {
return ghm.GasPenalizedCalled(hash)
}
return 0
}
// TotalGasConsumed -
func (ghm *GasHandlerMock) TotalGasConsumed() uint64 {
if ghm.TotalGasConsumedCalled != nil {
return ghm.TotalGasConsumedCalled()
}
return 0
}
// TotalGasRefunded -
func (ghm *GasHandlerMock) TotalGasRefunded() uint64 {
if ghm.TotalGasRefundedCalled != nil {
return ghm.TotalGasRefundedCalled()
}
return 0
}
// TotalGasPenalized -
func (ghm *GasHandlerMock) TotalGasPenalized() uint64 {
if ghm.TotalGasPenalizedCalled != nil {
return ghm.TotalGasPenalizedCalled()
}
return 0
}
// RemoveGasConsumed -
func (ghm *GasHandlerMock) RemoveGasConsumed(hashes [][]byte) {
if ghm.RemoveGasConsumedCalled != nil {
ghm.RemoveGasConsumedCalled(hashes)
}
}
// RemoveGasRefunded -
func (ghm *GasHandlerMock) RemoveGasRefunded(hashes [][]byte) {
if ghm.RemoveGasRefundedCalled != nil {
ghm.RemoveGasRefundedCalled(hashes)
}
}
// RemoveGasPenalized -
func (ghm *GasHandlerMock) RemoveGasPenalized(hashes [][]byte) {
if ghm.RemoveGasPenalizedCalled != nil {
ghm.RemoveGasPenalizedCalled(hashes)
}
}
// ComputeGasConsumedByMiniBlock -
func (ghm *GasHandlerMock) ComputeGasConsumedByMiniBlock(miniBlock *block.MiniBlock, mapHashTx map[string]data.TransactionHandler) (uint64, uint64, error) {
if ghm.ComputeGasConsumedByMiniBlockCalled != nil {
return ghm.ComputeGasConsumedByMiniBlockCalled(miniBlock, mapHashTx)
}
return 0, 0, nil
}
// ComputeGasConsumedByTx -
func (ghm *GasHandlerMock) ComputeGasConsumedByTx(txSenderShardId uint32, txReceiverShardId uint32, txHandler data.TransactionHandler) (uint64, uint64, error) {
if ghm.ComputeGasConsumedByTxCalled != nil {
return ghm.ComputeGasConsumedByTxCalled(txSenderShardId, txReceiverShardId, txHandler)
}
return 0, 0, nil
}
// IsInterfaceNil -
func (ghm *GasHandlerMock) IsInterfaceNil() bool {
return ghm == nil
}