vm: add unload command

When execution fails it's the only way to change the prompt showing the
last executed instruction. Example:

```
NEO-GO-VM > loadgo examples/engine/engine.go
READY: loaded 117 instructions
NEO-GO-VM 0 > run
Error: at instruction 3 (SYSCALL): failed to invoke syscall 805851437: syscall not found
NEO-GO-VM 8 > parse
Error: missing argument
NEO-GO-VM 8 > parse 123
Integer to Hex			7b
Integer to Base64		ew==
String to Hex			313233
String to Base64		MTIz

NEO-GO-VM 8 > unload
NEO-GO-VM > exit

```
This commit is contained in:
Anna Shaleva 2022-02-16 18:43:12 +03:00 committed by AnnaShaleva
parent 563c3a4baa
commit e8ec820d2e
2 changed files with 32 additions and 0 deletions

View file

@ -641,3 +641,19 @@ func TestExit(t *testing.T) {
e.runProg(t, "exit")
require.True(t, e.exit.Load())
}
func TestReset(t *testing.T) {
script := []byte{byte(opcode.PUSH1)}
e := newTestVMCLI(t)
e.runProg(t,
"loadhex "+hex.EncodeToString(script),
"ops",
"reset",
"ops")
e.checkNextLine(t, "READY: loaded 1 instructions")
e.checkNextLine(t, "INDEX.*OPCODE.*PARAMETER")
e.checkNextLine(t, "0.*PUSH1.*")
e.checkNextLine(t, "")
e.checkError(t, fmt.Errorf("VM is not ready: no program loaded"))
}