-
Notifications
You must be signed in to change notification settings - Fork 199
/
vmExecutionHandlerStub.go
50 lines (41 loc) · 1.58 KB
/
vmExecutionHandlerStub.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
package mock
import (
"math/big"
"github.com/ElrondNetwork/elrond-go/core/vmcommon"
)
// VMExecutionHandlerStub -
type VMExecutionHandlerStub struct {
RunSmartContractCreateCalled func(input *vmcommon.ContractCreateInput) (*vmcommon.VMOutput, error)
RunSmartContractCallCalled func(input *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error)
GasScheduleChangeCalled func(gasSchedule map[string]map[string]uint64)
}
// RunSmartContractCreate computes how a smart contract creation should be performed
func (vm *VMExecutionHandlerStub) RunSmartContractCreate(input *vmcommon.ContractCreateInput) (*vmcommon.VMOutput, error) {
if vm.RunSmartContractCreateCalled == nil {
return &vmcommon.VMOutput{
GasRefund: big.NewInt(0),
GasRemaining: 0,
}, nil
}
return vm.RunSmartContractCreateCalled(input)
}
// RunSmartContractCall computes the result of a smart contract call and how the system must change after the execution
func (vm *VMExecutionHandlerStub) RunSmartContractCall(input *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error) {
if vm.RunSmartContractCallCalled == nil {
return &vmcommon.VMOutput{
GasRefund: big.NewInt(0),
GasRemaining: 0,
}, nil
}
return vm.RunSmartContractCallCalled(input)
}
// GasScheduleChange -
func (vm *VMExecutionHandlerStub) GasScheduleChange(gasSchedule map[string]map[string]uint64) {
if vm.GasScheduleChangeCalled != nil {
vm.GasScheduleChangeCalled(gasSchedule)
}
}
// IsInterfaceNil returns true if there is no value under the interface
func (vm *VMExecutionHandlerStub) IsInterfaceNil() bool {
return vm == nil
}