-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathruntimeContextMock.go
More file actions
385 lines (310 loc) · 9.56 KB
/
runtimeContextMock.go
File metadata and controls
385 lines (310 loc) · 9.56 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
package mock
import (
vmcommon "github.com/multiversx/mx-chain-vm-common-go"
"github.com/multiversx/mx-chain-vm-go/executor"
"github.com/multiversx/mx-chain-vm-go/vmhost"
)
var _ vmhost.RuntimeContext = (*RuntimeContextMock)(nil)
// RuntimeContextMock is used in tests to check the RuntimeContextMock interface method calls
type RuntimeContextMock struct {
Err error
VMInput *vmcommon.ContractCallInput
OriginalCallerAddr []byte
SCAddress []byte
SCCode []byte
SCCodeSize uint64
CallFunction string
VMType []byte
ReadOnlyFlag bool
VerifyCode bool
CurrentBreakpointValue vmhost.BreakpointValue
PointsUsed uint64
InstanceCtxID int
MemLoadResult []byte
MemLoadMultipleResult [][]byte
FailCryptoAPI bool
FailBaseOpsAPI bool
FailSyncExecAPI bool
FailBigIntAPI bool
FailBigFloatAPI bool
FailManagedBuffersAPI bool
FailManagedMapAPI bool
AsyncCallInfo *vmhost.AsyncCallInfo
InstanceStackSize uint64
CurrentTxHash []byte
OriginalTxHash []byte
TraceGasEnabled bool
GasTrace map[string]map[string][]uint64
SameContractOnStackCount uint64
HasFunctionResult bool
}
// InitState mocked method
func (r *RuntimeContextMock) InitState() {
}
// GetVMExecutor mocked method
func (r *RuntimeContextMock) GetVMExecutor() executor.Executor {
return nil
}
// ReplaceVMExecutor mocked method
func (context *RuntimeContextMock) ReplaceVMExecutor(_ executor.Executor) {
}
// GetInstanceTracker mocked method
func (context *RuntimeContextMock) GetInstanceTracker() vmhost.InstanceTracker {
return nil
}
// StartWasmerInstance mocked method
func (r *RuntimeContextMock) StartWasmerInstance(_ []byte, _ uint64, _ bool) error {
if r.Err != nil {
return r.Err
}
return nil
}
// SetCaching mocked method
func (r *RuntimeContextMock) SetCaching(_ bool) {
}
// InitStateFromContractCallInput mocked method
func (r *RuntimeContextMock) InitStateFromContractCallInput(_ *vmcommon.ContractCallInput) {
}
// PushState mocked method
func (r *RuntimeContextMock) PushState() {
}
// PopSetActiveState mocked method
func (r *RuntimeContextMock) PopSetActiveState() {
}
// PopDiscard mocked method
func (r *RuntimeContextMock) PopDiscard() {
}
// MustVerifyNextContractCode mocked method
func (r *RuntimeContextMock) MustVerifyNextContractCode() {
}
// ClearStateStack mocked method
func (r *RuntimeContextMock) ClearStateStack() {
}
// PushInstance mocked method
func (r *RuntimeContextMock) PushInstance() {
}
// PopInstance mocked method
func (r *RuntimeContextMock) PopInstance() {
}
// IsWarmInstance mocked method
func (r *RuntimeContextMock) IsWarmInstance() bool {
return false
}
// ResetWarmInstance mocked method
func (r *RuntimeContextMock) ResetWarmInstance() {
}
// GetInstanceStackSize mocked method
func (r *RuntimeContextMock) GetInstanceStackSize() uint64 {
return r.InstanceStackSize
}
// SetMaxInstanceStackSize mocked method
func (r *RuntimeContextMock) SetMaxInstanceStackSize(uint64) {
}
// ClearInstanceStack mocked method
func (r *RuntimeContextMock) ClearInstanceStack() {
}
// GetVMType mocked method
func (r *RuntimeContextMock) GetVMType() []byte {
return r.VMType
}
// GetVMInput mocked method
func (r *RuntimeContextMock) GetVMInput() *vmcommon.ContractCallInput {
return r.VMInput
}
// SetVMInput mocked method
func (r *RuntimeContextMock) SetVMInput(vmInput *vmcommon.ContractCallInput) {
r.VMInput = vmInput
}
// CountSameContractInstancesOnStack mocked method
func (r *RuntimeContextMock) CountSameContractInstancesOnStack(_ []byte) uint64 {
return r.SameContractOnStackCount
}
// GetContextAddress mocked method
func (r *RuntimeContextMock) GetContextAddress() []byte {
return r.SCAddress
}
// GetOriginalCallerAddress mocked method
func (r *RuntimeContextMock) GetOriginalCallerAddress() []byte {
return r.OriginalCallerAddr
}
// SetCodeAddress mocked method
func (r *RuntimeContextMock) SetCodeAddress(scAddress []byte) {
r.SCAddress = scAddress
}
// SetOriginalCallerAddress mocked method
func (r *RuntimeContextMock) SetOriginalCallerAddress(scAddress []byte) {
r.OriginalCallerAddr = scAddress
}
// GetSCCode mocked method
func (r *RuntimeContextMock) GetSCCode() ([]byte, error) {
return r.SCCode, r.Err
}
// GetSCCodeSize mocked method
func (r *RuntimeContextMock) GetSCCodeSize() uint64 {
return r.SCCodeSize
}
// FunctionName mocked method
func (r *RuntimeContextMock) FunctionName() string {
return r.CallFunction
}
// Arguments mocked method
func (r *RuntimeContextMock) Arguments() [][]byte {
return r.VMInput.Arguments
}
// GetCurrentTxHash mocked method
func (r *RuntimeContextMock) GetCurrentTxHash() []byte {
return r.CurrentTxHash
}
// GetOriginalTxHash mocked method
func (r *RuntimeContextMock) GetOriginalTxHash() []byte {
return r.OriginalTxHash
}
// RemoveCodeUpgradeFromArgs mocked method
func (r *RuntimeContextMock) RemoveCodeUpgradeFromArgs() {
}
// SignalExit mocked method
func (r *RuntimeContextMock) SignalExit(_ int) {
}
// SignalUserError mocked method
func (r *RuntimeContextMock) SignalUserError(_ string) {
}
// SetRuntimeBreakpointValue mocked method
func (r *RuntimeContextMock) SetRuntimeBreakpointValue(_ vmhost.BreakpointValue) {
}
// GetRuntimeBreakpointValue mocked method
func (r *RuntimeContextMock) GetRuntimeBreakpointValue() vmhost.BreakpointValue {
return r.CurrentBreakpointValue
}
// PrepareLegacyAsyncCall mocked method
func (r *RuntimeContextMock) PrepareLegacyAsyncCall(_ []byte, _ []byte, _ []byte) error {
return r.Err
}
// VerifyContractCode mocked method
func (r *RuntimeContextMock) VerifyContractCode() error {
return r.Err
}
// GetPointsUsed mocked method
func (r *RuntimeContextMock) GetPointsUsed() uint64 {
return r.PointsUsed
}
// SetPointsUsed mocked method
func (r *RuntimeContextMock) SetPointsUsed(gasPoints uint64) {
r.PointsUsed = gasPoints
}
// ReadOnly mocked method
func (r *RuntimeContextMock) ReadOnly() bool {
return r.ReadOnlyFlag
}
// SetReadOnly mocked method
func (r *RuntimeContextMock) SetReadOnly(readOnly bool) {
r.ReadOnlyFlag = readOnly
}
// GetInstance mocked method()
func (r *RuntimeContextMock) GetInstance() executor.Instance {
return nil
}
// GetWarmInstance mocked method
func (r *RuntimeContextMock) GetWarmInstance(_ []byte) (executor.Instance, bool) {
return nil, false
}
// ClearWarmInstanceCache mocked method
func (r *RuntimeContextMock) ClearWarmInstanceCache() {
}
// FunctionNameChecked mocked method
func (r *RuntimeContextMock) FunctionNameChecked() (string, error) {
if r.Err != nil {
return "", r.Err
}
return "", nil
}
// CallSCFunction mocked method
func (r *RuntimeContextMock) CallSCFunction(_ string) error {
return r.Err
}
// BaseOpsErrorShouldFailExecution mocked method
func (r *RuntimeContextMock) BaseOpsErrorShouldFailExecution() bool {
return r.FailBaseOpsAPI
}
// SyncExecAPIErrorShouldFailExecution mocked method
func (r *RuntimeContextMock) SyncExecAPIErrorShouldFailExecution() bool {
return r.FailSyncExecAPI
}
// CryptoAPIErrorShouldFailExecution mocked method
func (r *RuntimeContextMock) CryptoAPIErrorShouldFailExecution() bool {
return r.FailCryptoAPI
}
// BigIntAPIErrorShouldFailExecution mocked method
func (r *RuntimeContextMock) BigIntAPIErrorShouldFailExecution() bool {
return r.FailBigIntAPI
}
// BigFloatAPIErrorShouldFailExecution mocked method
func (r *RuntimeContextMock) BigFloatAPIErrorShouldFailExecution() bool {
return r.FailBigFloatAPI
}
// ManagedBufferAPIErrorShouldFailExecution mocked method
func (r *RuntimeContextMock) ManagedBufferAPIErrorShouldFailExecution() bool {
return r.FailManagedBuffersAPI
}
// ManagedMapAPIErrorShouldFailExecution mocked method
func (r *RuntimeContextMock) ManagedMapAPIErrorShouldFailExecution() bool {
return r.FailManagedMapAPI
}
// UseGasBoundedShouldFailExecution mocked method
func (r *RuntimeContextMock) UseGasBoundedShouldFailExecution() bool {
return true
}
// FailExecution mocked method
func (r *RuntimeContextMock) FailExecution(_ error) {
}
// AddAsyncContextCall mocked method
func (r *RuntimeContextMock) AddAsyncContextCall(_ []byte, _ *vmhost.AsyncGeneratedCall) error {
return r.Err
}
// SetCustomCallFunction mocked method
func (r *RuntimeContextMock) SetCustomCallFunction(_ string) {
}
// IsFunctionImported mocked method
func (r *RuntimeContextMock) IsFunctionImported(_ string) bool {
return true
}
// IsOpcodeUsed mocked method
func (r *RuntimeContextMock) IsOpcodeUsed(_ executor.OpcodeUsed) bool {
return false
}
// AddError mocked method
func (r *RuntimeContextMock) AddError(_ error, _ ...string) {
}
// GetAllErrors mocked method
func (r *RuntimeContextMock) GetAllErrors() error {
return nil
}
// EndExecution -
func (r *RuntimeContextMock) EndExecution() {
}
// ValidateInstances -
func (r *RuntimeContextMock) ValidateInstances() error {
return nil
}
// ValidateCallbackName mocked method
func (r *RuntimeContextMock) ValidateCallbackName(_ string) error {
return nil
}
// IsReservedFunctionName moked method
func (r *RuntimeContextMock) IsReservedFunctionName(_ string) bool {
return false
}
// HasFunction mocked method
func (r *RuntimeContextMock) HasFunction(_ string) bool {
return r.HasFunctionResult
}
// GetPrevTxHash mocked method
func (r *RuntimeContextMock) GetPrevTxHash() []byte {
return nil
}
// NumRunningInstances mocked method
func (r *RuntimeContextMock) NumRunningInstances() (int, int) {
return 0, 0
}
// CleanInstance mocked method
func (r *RuntimeContextMock) CleanInstance() {
}