/
scenarioRunner.go
32 lines (27 loc) · 1.06 KB
/
scenarioRunner.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
package mandoscontroller
import (
fr "github.com/ElrondNetwork/arwen-wasm-vm/mandos-go/fileresolver"
mj "github.com/ElrondNetwork/arwen-wasm-vm/mandos-go/json/model"
mjparse "github.com/ElrondNetwork/arwen-wasm-vm/mandos-go/json/parse"
)
// ScenarioExecutor describes a component that can run a VM scenario.
type ScenarioExecutor interface {
// Reset clears state/world.
Reset()
// ExecuteScenario executes the scenario and checks if it passed. Failure is signaled by returning an error.
// The FileResolver helps with resolving external steps.
// TODO: group into a "execution context" param.
ExecuteScenario(*mj.Scenario, fr.FileResolver) error
}
// ScenarioRunner is a component that can run json scenarios, using a provided executor.
type ScenarioRunner struct {
Executor ScenarioExecutor
Parser mjparse.Parser
}
// NewScenarioRunner creates new ScenarioRunner instance.
func NewScenarioRunner(executor ScenarioExecutor, fileResolver fr.FileResolver) *ScenarioRunner {
return &ScenarioRunner{
Executor: executor,
Parser: mjparse.NewParser(fileResolver),
}
}