-
Notifications
You must be signed in to change notification settings - Fork 199
/
blockChainHookHandlerMock.go
84 lines (70 loc) · 2.71 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
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
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(sndAddress []byte, rcvAddress []byte) (bool, error)
DeleteCompiledCodeCalled func(codeHash []byte)
ProcessBuiltInFunctionCalled func(input *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error)
FilterCodeMetadataForUpgradeCalled func(input []byte) ([]byte, error)
ApplyFiltersOnCodeMetadataCalled func(codeMetadata vmcommon.CodeMetadata) vmcommon.CodeMetadata
}
// SaveNFTMetaDataToSystemAccount -
func (e *BlockChainHookHandlerMock) SaveNFTMetaDataToSystemAccount(_ data.TransactionHandler) error {
return nil
}
// 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(sndAddress []byte, recvAddress []byte) (bool, error) {
if e.IsPayableCalled != nil {
return e.IsPayableCalled(sndAddress, recvAddress)
}
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)
}
}
// FilterCodeMetadataForUpgrade -
func (e *BlockChainHookHandlerMock) FilterCodeMetadataForUpgrade(input []byte) ([]byte, error) {
if e.FilterCodeMetadataForUpgradeCalled != nil {
return e.FilterCodeMetadataForUpgradeCalled(input)
}
return input, nil
}
// ApplyFiltersOnCodeMetadata -
func (e *BlockChainHookHandlerMock) ApplyFiltersOnCodeMetadata(codeMetadata vmcommon.CodeMetadata) vmcommon.CodeMetadata {
if e.ApplyFiltersOnCodeMetadataCalled != nil {
return e.ApplyFiltersOnCodeMetadataCalled(codeMetadata)
}
return codeMetadata
}
// IsInterfaceNil -
func (e *BlockChainHookHandlerMock) IsInterfaceNil() bool {
return e == nil
}