-
Notifications
You must be signed in to change notification settings - Fork 199
/
blockChainHookHandlerMock.go
59 lines (50 loc) · 1.77 KB
/
blockChainHookHandlerMock.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
package mock
import (
"github.com/ElrondNetwork/elrond-go-core/data"
vmcommon "github.com/ElrondNetwork/elrond-vm-common"
)
// BlockChainHookHandlerMock -
type BlockChainHookHandlerMock struct {
SetCurrentHeaderCalled func(hdr data.HeaderHandler)
NewAddressCalled func(creatorAddress []byte, creatorNonce uint64, vmType []byte) ([]byte, error)
IsPayableCalled func(address []byte) (bool, error)
DeleteCompiledCodeCalled func(codeHash []byte)
ProcessBuiltInFunctionCalled func(input *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error)
}
// ProcessBuiltInFunction -
func (e *BlockChainHookHandlerMock) ProcessBuiltInFunction(input *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error) {
if e.ProcessBuiltInFunctionCalled != nil {
return e.ProcessBuiltInFunctionCalled(input)
}
return &vmcommon.VMOutput{ReturnCode: vmcommon.Ok}, nil
}
// IsPayable -
func (e *BlockChainHookHandlerMock) IsPayable(address []byte) (bool, error) {
if e.IsPayableCalled != nil {
return e.IsPayableCalled(address)
}
return true, nil
}
// SetCurrentHeader -
func (e *BlockChainHookHandlerMock) SetCurrentHeader(hdr data.HeaderHandler) {
if e.SetCurrentHeaderCalled != nil {
e.SetCurrentHeaderCalled(hdr)
}
}
// NewAddress -
func (e *BlockChainHookHandlerMock) NewAddress(creatorAddress []byte, creatorNonce uint64, vmType []byte) ([]byte, error) {
if e.NewAddressCalled != nil {
return e.NewAddressCalled(creatorAddress, creatorNonce, vmType)
}
return make([]byte, 0), nil
}
// DeleteCompiledCode -
func (e *BlockChainHookHandlerMock) DeleteCompiledCode(codeHash []byte) {
if e.DeleteCompiledCodeCalled != nil {
e.DeleteCompiledCodeCalled(codeHash)
}
}
// IsInterfaceNil -
func (e *BlockChainHookHandlerMock) IsInterfaceNil() bool {
return e == nil
}