mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-23 03:38:35 +00:00
vm/tests: unmarshal VM state in JSON tests properly
This commit is contained in:
parent
0c7b163280
commit
e71cc04c70
1 changed files with 3 additions and 19 deletions
|
@ -44,7 +44,7 @@ type (
|
|||
}
|
||||
|
||||
vmUTExecutionEngineState struct {
|
||||
State vmUTState `json:"state"`
|
||||
State State `json:"state"`
|
||||
ResultStack []vmUTStackItem `json:"resultStack"`
|
||||
InvocationStack []vmUTExecutionContextState `json:"invocationStack"`
|
||||
}
|
||||
|
@ -61,8 +61,6 @@ type (
|
|||
Result vmUTExecutionEngineState `json:"result"`
|
||||
}
|
||||
|
||||
vmUTState State
|
||||
|
||||
vmUTStackItemType string
|
||||
)
|
||||
|
||||
|
@ -138,8 +136,8 @@ func testFile(t *testing.T, filename string) {
|
|||
for i := range test.Steps {
|
||||
execStep(t, vm, test.Steps[i])
|
||||
result := test.Steps[i].Result
|
||||
require.Equal(t, State(result.State), vm.state)
|
||||
if result.State == vmUTState(faultState) { // do not compare stacks on fault
|
||||
require.Equal(t, result.State, vm.state)
|
||||
if result.State == faultState { // do not compare stacks on fault
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -280,20 +278,6 @@ func execStep(t *testing.T, v *VM, step vmUTStep) {
|
|||
}
|
||||
}
|
||||
|
||||
func (v *vmUTState) UnmarshalJSON(data []byte) error {
|
||||
switch s := string(data); s {
|
||||
case `"Break"`:
|
||||
*v = vmUTState(breakState)
|
||||
case `"Fault"`:
|
||||
*v = vmUTState(faultState)
|
||||
case `"Halt"`:
|
||||
*v = vmUTState(haltState)
|
||||
default:
|
||||
panic(fmt.Sprintf("invalid state: %s", s))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v *vmUTScript) UnmarshalJSON(data []byte) error {
|
||||
var ops []string
|
||||
if err := json.Unmarshal(data, &ops); err != nil {
|
||||
|
|
Loading…
Reference in a new issue