-
Notifications
You must be signed in to change notification settings - Fork 0
/
gas_register.go
66 lines (57 loc) · 1.98 KB
/
gas_register.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
package wasmtesting
import (
wasmvmtypes "github.com/CosmWasm/wasmvm/types"
sdk "github.com/furyaxyz/fuxchain/libs/cosmos-sdk/types"
)
// MockGasRegister mock that implements keeper.GasRegister
type MockGasRegister struct {
CompileCostFn func(byteLength int) sdk.Gas
NewContractInstanceCostFn func(pinned bool, msgLen int) sdk.Gas
InstantiateContractCostFn func(pinned bool, msgLen int) sdk.Gas
ReplyCostFn func(pinned bool, reply wasmvmtypes.Reply) sdk.Gas
EventCostsFn func(evts []wasmvmtypes.EventAttribute) sdk.Gas
ToWasmVMGasFn func(source sdk.Gas) uint64
FromWasmVMGasFn func(source uint64) sdk.Gas
}
func (m MockGasRegister) NewContractInstanceCosts(pinned bool, msgLen int) sdk.Gas {
if m.NewContractInstanceCostFn == nil {
panic("not expected to be called")
}
return m.NewContractInstanceCostFn(pinned, msgLen)
}
func (m MockGasRegister) CompileCosts(byteLength int) sdk.Gas {
if m.CompileCostFn == nil {
panic("not expected to be called")
}
return m.CompileCostFn(byteLength)
}
func (m MockGasRegister) InstantiateContractCosts(pinned bool, msgLen int) sdk.Gas {
if m.InstantiateContractCostFn == nil {
panic("not expected to be called")
}
return m.InstantiateContractCostFn(pinned, msgLen)
}
func (m MockGasRegister) ReplyCosts(pinned bool, reply wasmvmtypes.Reply) sdk.Gas {
if m.ReplyCostFn == nil {
panic("not expected to be called")
}
return m.ReplyCostFn(pinned, reply)
}
func (m MockGasRegister) EventCosts(evts []wasmvmtypes.EventAttribute, events wasmvmtypes.Events) sdk.Gas {
if m.EventCostsFn == nil {
panic("not expected to be called")
}
return m.EventCostsFn(evts)
}
func (m MockGasRegister) ToWasmVMGas(source sdk.Gas) uint64 {
if m.ToWasmVMGasFn == nil {
panic("not expected to be called")
}
return m.ToWasmVMGasFn(source)
}
func (m MockGasRegister) FromWasmVMGas(source uint64) sdk.Gas {
if m.FromWasmVMGasFn == nil {
panic("not expected to be called")
}
return m.FromWasmVMGasFn(source)
}