-
Notifications
You must be signed in to change notification settings - Fork 199
/
gasHandlerMock.go
94 lines (80 loc) · 2.91 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
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)
GasConsumedCalled func(hash []byte) uint64
GasRefundedCalled func(hash []byte) uint64
TotalGasConsumedCalled func() uint64
TotalGasRefundedCalled func() uint64
RemoveGasConsumedCalled func(hashes [][]byte)
RemoveGasRefundedCalled 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() {
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)
}
}
// GasConsumed -
func (ghm *GasHandlerMock) GasConsumed(hash []byte) uint64 {
return ghm.GasConsumedCalled(hash)
}
// GasRefunded -
func (ghm *GasHandlerMock) GasRefunded(hash []byte) uint64 {
if ghm.GasRefundedCalled != nil {
return ghm.GasRefundedCalled(hash)
}
return 0
}
// TotalGasConsumed -
func (ghm *GasHandlerMock) TotalGasConsumed() uint64 {
if ghm.TotalGasConsumedCalled != nil {
return ghm.TotalGasConsumedCalled()
}
return 0
}
// TotalGasRefunded -
func (ghm *GasHandlerMock) TotalGasRefunded() uint64 {
return ghm.TotalGasRefundedCalled()
}
// RemoveGasConsumed -
func (ghm *GasHandlerMock) RemoveGasConsumed(hashes [][]byte) {
ghm.RemoveGasConsumedCalled(hashes)
}
// RemoveGasRefunded -
func (ghm *GasHandlerMock) RemoveGasRefunded(hashes [][]byte) {
ghm.RemoveGasRefundedCalled(hashes)
}
// ComputeGasConsumedByMiniBlock -
func (ghm *GasHandlerMock) ComputeGasConsumedByMiniBlock(miniBlock *block.MiniBlock, mapHashTx map[string]data.TransactionHandler) (uint64, uint64, error) {
return ghm.ComputeGasConsumedByMiniBlockCalled(miniBlock, mapHashTx)
}
// 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
}