vm: make byte representation of VMState compatible with C#
This commit is contained in:
parent
6343720adf
commit
2972569a0a
2 changed files with 11 additions and 2 deletions
|
@ -10,14 +10,14 @@ type State uint8
|
||||||
|
|
||||||
// Available States.
|
// Available States.
|
||||||
const (
|
const (
|
||||||
// NoneState represents NONE VM state.
|
|
||||||
NoneState State = 0
|
|
||||||
// HaltState represents HALT VM state.
|
// HaltState represents HALT VM state.
|
||||||
HaltState State = 1 << iota
|
HaltState State = 1 << iota
|
||||||
// FaultState represents FAULT VM state.
|
// FaultState represents FAULT VM state.
|
||||||
FaultState
|
FaultState
|
||||||
// BreakState represents BREAK VM state.
|
// BreakState represents BREAK VM state.
|
||||||
BreakState
|
BreakState
|
||||||
|
// NoneState represents NONE VM state.
|
||||||
|
NoneState State = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
// HasFlag checks for State flag presence.
|
// HasFlag checks for State flag presence.
|
||||||
|
|
|
@ -86,3 +86,12 @@ func TestState_UnmarshalJSON(t *testing.T) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, NoneState, s)
|
assert.Equal(t, NoneState, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestState_EnumCompat tests that byte value of State matches the C#'s one got from
|
||||||
|
// https://github.com/neo-project/neo-vm/blob/0028d862e253bda3c12eb8bb007a2d95822d3922/src/neo-vm/VMState.cs#L16.
|
||||||
|
func TestState_EnumCompat(t *testing.T) {
|
||||||
|
assert.Equal(t, byte(0), byte(NoneState))
|
||||||
|
assert.Equal(t, byte(1<<0), byte(HaltState))
|
||||||
|
assert.Equal(t, byte(1<<1), byte(FaultState))
|
||||||
|
assert.Equal(t, byte(1<<2), byte(BreakState))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue