Skip to content

Commit df9cddf

Browse files
authored
Merge pull request #8003 from onflow/bastian/clean-up-test-runtime
[FVM] Clean up test runtime
2 parents 860aaa2 + 9ae8544 commit df9cddf

File tree

3 files changed

+48
-46
lines changed

3 files changed

+48
-46
lines changed

fvm/environment/system_contracts_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func TestSystemContractsInvoke(t *testing.T) {
6161
0,
6262
runtime.Config{},
6363
func(_ runtime.Config) runtime.Runtime {
64-
return &testutil.TestInterpreterRuntime{
64+
return &testutil.TestRuntime{
6565
InvokeContractFunc: tc.contractFunction,
6666
}
6767
},

fvm/executionParameters_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestGetExecutionMemoryWeights(t *testing.T) {
3232
envMock := &fvmmock.Environment{}
3333
envMock.On("BorrowCadenceRuntime", mock.Anything).Return(
3434
reusableRuntime.NewReusableCadenceRuntime(
35-
&testutil.TestInterpreterRuntime{
35+
&testutil.TestRuntime{
3636
ReadStoredFunc: readStored,
3737
},
3838
runtime.Config{},
@@ -162,7 +162,7 @@ func TestGetExecutionEffortWeights(t *testing.T) {
162162
envMock := &fvmmock.Environment{}
163163
envMock.On("BorrowCadenceRuntime", mock.Anything).Return(
164164
reusableRuntime.NewReusableCadenceRuntime(
165-
&testutil.TestInterpreterRuntime{
165+
&testutil.TestRuntime{
166166
ReadStoredFunc: readStored,
167167
},
168168
runtime.Config{},

fvm/runtime/testutil/runtime.go

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,83 +8,85 @@ import (
88
"github.com/onflow/cadence/sema"
99
)
1010

11-
var _ runtime.Runtime = &TestInterpreterRuntime{}
12-
13-
type TestInterpreterRuntime struct {
14-
ReadStoredFunc func(address common.Address, path cadence.Path, context runtime.Context) (cadence.Value, error)
15-
InvokeContractFunc func(a common.AddressLocation, s string, values []cadence.Value, types []sema.Type, ctx runtime.Context) (cadence.Value, error)
16-
}
17-
18-
func (t *TestInterpreterRuntime) Config() runtime.Config {
11+
var _ runtime.Runtime = &TestRuntime{}
12+
13+
type TestRuntime struct {
14+
ReadStoredFunc func(
15+
address common.Address,
16+
path cadence.Path,
17+
context runtime.Context,
18+
) (cadence.Value, error)
19+
InvokeContractFunc func(
20+
a common.AddressLocation,
21+
s string,
22+
values []cadence.Value,
23+
types []sema.Type,
24+
ctx runtime.Context,
25+
) (cadence.Value, error)
26+
}
27+
28+
func (t *TestRuntime) Config() runtime.Config {
1929
panic("Config not defined")
2030
}
2131

22-
func (t *TestInterpreterRuntime) NewScriptExecutor(script runtime.Script, context runtime.Context) runtime.Executor {
32+
func (t *TestRuntime) NewScriptExecutor(_ runtime.Script, _ runtime.Context) runtime.Executor {
2333
panic("NewScriptExecutor not defined")
2434
}
2535

26-
func (t *TestInterpreterRuntime) NewTransactionExecutor(script runtime.Script, context runtime.Context) runtime.Executor {
36+
func (t *TestRuntime) NewTransactionExecutor(_ runtime.Script, _ runtime.Context) runtime.Executor {
2737
panic("NewTransactionExecutor not defined")
2838
}
2939

30-
func (t *TestInterpreterRuntime) NewContractFunctionExecutor(contractLocation common.AddressLocation, functionName string, arguments []cadence.Value, argumentTypes []sema.Type, context runtime.Context) runtime.Executor {
40+
func (t *TestRuntime) NewContractFunctionExecutor(
41+
_ common.AddressLocation,
42+
_ string,
43+
_ []cadence.Value,
44+
_ []sema.Type,
45+
_ runtime.Context,
46+
) runtime.Executor {
3147
panic("NewContractFunctionExecutor not defined")
3248
}
3349

34-
func (t *TestInterpreterRuntime) SetDebugger(debugger *interpreter.Debugger) {
50+
func (t *TestRuntime) SetDebugger(_ *interpreter.Debugger) {
3551
panic("SetDebugger not defined")
3652
}
3753

38-
func (t *TestInterpreterRuntime) ExecuteScript(runtime.Script, runtime.Context) (cadence.Value, error) {
54+
func (t *TestRuntime) ExecuteScript(_ runtime.Script, _ runtime.Context) (cadence.Value, error) {
3955
panic("ExecuteScript not defined")
4056
}
4157

42-
func (t *TestInterpreterRuntime) ExecuteTransaction(runtime.Script, runtime.Context) error {
58+
func (t *TestRuntime) ExecuteTransaction(_ runtime.Script, _ runtime.Context) error {
4359
panic("ExecuteTransaction not defined")
4460
}
4561

46-
func (t *TestInterpreterRuntime) InvokeContractFunction(a common.AddressLocation, s string, values []cadence.Value, types []sema.Type, ctx runtime.Context) (cadence.Value, error) {
62+
func (t *TestRuntime) InvokeContractFunction(
63+
a common.AddressLocation,
64+
s string,
65+
values []cadence.Value,
66+
types []sema.Type,
67+
ctx runtime.Context,
68+
) (cadence.Value, error) {
4769
if t.InvokeContractFunc == nil {
4870
panic("InvokeContractFunction not defined")
4971
}
5072
return t.InvokeContractFunc(a, s, values, types, ctx)
5173
}
5274

53-
func (t *TestInterpreterRuntime) ParseAndCheckProgram([]byte, runtime.Context) (*interpreter.Program, error) {
75+
func (t *TestRuntime) ParseAndCheckProgram(_ []byte, _ runtime.Context) (*interpreter.Program, error) {
5476
panic("ParseAndCheckProgram not defined")
5577
}
5678

57-
func (t *TestInterpreterRuntime) SetCoverageReport(*runtime.CoverageReport) {
58-
panic("SetCoverageReport not defined")
59-
}
60-
61-
func (t *TestInterpreterRuntime) SetContractUpdateValidationEnabled(bool) {
62-
panic("SetContractUpdateValidationEnabled not defined")
63-
}
64-
65-
func (t *TestInterpreterRuntime) SetAtreeValidationEnabled(bool) {
66-
panic("SetAtreeValidationEnabled not defined")
67-
}
68-
69-
func (t *TestInterpreterRuntime) SetTracingEnabled(bool) {
70-
panic("SetTracingEnabled not defined")
71-
}
72-
73-
func (t *TestInterpreterRuntime) SetInvalidatedResourceValidationEnabled(bool) {
74-
panic("SetInvalidatedResourceValidationEnabled not defined")
75-
}
76-
77-
func (t *TestInterpreterRuntime) SetResourceOwnerChangeHandlerEnabled(bool) {
78-
panic("SetResourceOwnerChangeHandlerEnabled not defined")
79-
}
80-
81-
func (t *TestInterpreterRuntime) ReadStored(address common.Address, path cadence.Path, context runtime.Context) (cadence.Value, error) {
79+
func (t *TestRuntime) ReadStored(
80+
address common.Address,
81+
path cadence.Path,
82+
context runtime.Context,
83+
) (cadence.Value, error) {
8284
if t.ReadStoredFunc == nil {
8385
panic("ReadStored not defined")
8486
}
8587
return t.ReadStoredFunc(address, path, context)
8688
}
8789

88-
func (*TestInterpreterRuntime) Storage(runtime.Context) (*runtime.Storage, *interpreter.Interpreter, error) {
89-
panic("not implemented")
90+
func (*TestRuntime) Storage(_ runtime.Context) (*runtime.Storage, *interpreter.Interpreter, error) {
91+
panic("Storage not defined")
9092
}

0 commit comments

Comments
 (0)