-
Notifications
You must be signed in to change notification settings - Fork 199
/
argumentsParserMock.go
72 lines (62 loc) · 1.89 KB
/
argumentsParserMock.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
package mock
import (
"github.com/ElrondNetwork/elrond-vm-common"
)
type ArgumentParserMock struct {
ParseDataCalled func(data string) error
GetArgumentsCalled func() ([][]byte, error)
GetCodeCalled func() ([]byte, error)
GetFunctionCalled func() (string, error)
GetSeparatorCalled func() string
CreateDataFromStorageUpdateCalled func(storageUpdates []*vmcommon.StorageUpdate) string
GetStorageUpdatesCalled func(data string) ([]*vmcommon.StorageUpdate, error)
}
func (ap *ArgumentParserMock) ParseData(data string) error {
if ap.ParseDataCalled == nil {
return nil
}
return ap.ParseDataCalled(data)
}
func (ap *ArgumentParserMock) GetArguments() ([][]byte, error) {
if ap.GetArgumentsCalled == nil {
return make([][]byte, 0), nil
}
return ap.GetArgumentsCalled()
}
func (ap *ArgumentParserMock) GetCode() ([]byte, error) {
if ap.GetCodeCalled == nil {
return []byte(""), nil
}
return ap.GetCodeCalled()
}
func (ap *ArgumentParserMock) GetFunction() (string, error) {
if ap.GetFunctionCalled == nil {
return "", nil
}
return ap.GetFunctionCalled()
}
func (ap *ArgumentParserMock) GetSeparator() string {
if ap.GetSeparatorCalled == nil {
return "@"
}
return ap.GetSeparatorCalled()
}
func (ap *ArgumentParserMock) CreateDataFromStorageUpdate(storageUpdates []*vmcommon.StorageUpdate) string {
if ap.CreateDataFromStorageUpdateCalled == nil {
return ""
}
return ap.CreateDataFromStorageUpdateCalled(storageUpdates)
}
func (ap *ArgumentParserMock) GetStorageUpdates(data string) ([]*vmcommon.StorageUpdate, error) {
if ap.GetStorageUpdatesCalled == nil {
return nil, nil
}
return ap.GetStorageUpdatesCalled(data)
}
// IsInterfaceNil returns true if there is no value under the interface
func (ap *ArgumentParserMock) IsInterfaceNil() bool {
if ap == nil {
return true
}
return false
}