From 1adff449e1e618c5f9e857da5104e03ad8dee693 Mon Sep 17 00:00:00 2001 From: Shargon Date: Mon, 22 Apr 2019 16:10:58 +0200 Subject: [PATCH] More Opcode unit tests (#135) * DEPTH, NIP and XDROP unit tests * XSWAP * SWAP * ROT * OVER --- .../Tests/OpCodes/Stack/DEPTH.json | 257 ++++++++++ .../neo-vm.Tests/Tests/OpCodes/Stack/NIP.json | 169 ++++++ .../Tests/OpCodes/Stack/OVER.json | 292 +++++++++++ .../neo-vm.Tests/Tests/OpCodes/Stack/ROT.json | 255 +++++++++ .../Tests/OpCodes/Stack/SWAP.json | 255 +++++++++ .../Tests/OpCodes/Stack/XDROP.json | 292 +++++++++++ .../Tests/OpCodes/Stack/XSWAP.json | 485 ++++++++++++++++++ 7 files changed, 2005 insertions(+) create mode 100644 tests/neo-vm.Tests/Tests/OpCodes/Stack/DEPTH.json create mode 100644 tests/neo-vm.Tests/Tests/OpCodes/Stack/NIP.json create mode 100644 tests/neo-vm.Tests/Tests/OpCodes/Stack/OVER.json create mode 100644 tests/neo-vm.Tests/Tests/OpCodes/Stack/ROT.json create mode 100644 tests/neo-vm.Tests/Tests/OpCodes/Stack/SWAP.json create mode 100644 tests/neo-vm.Tests/Tests/OpCodes/Stack/XDROP.json create mode 100644 tests/neo-vm.Tests/Tests/OpCodes/Stack/XSWAP.json diff --git a/tests/neo-vm.Tests/Tests/OpCodes/Stack/DEPTH.json b/tests/neo-vm.Tests/Tests/OpCodes/Stack/DEPTH.json new file mode 100644 index 00000000..aa3e43d2 --- /dev/null +++ b/tests/neo-vm.Tests/Tests/OpCodes/Stack/DEPTH.json @@ -0,0 +1,257 @@ +{ + "category": "Stack", + "name": "DEPTH", + "tests": + [ + { + "name": "Without push", + "script": "0x74", + "steps": + [ + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0xB1DF1979BA1AA2A8A114B641D764F26CF1D5D844", + "instructionPointer": 1, + "nextInstruction": "RET", + "evaluationStack": + [ + { + "type": "Integer", + "value": 0 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Halt", + "resultStack": + [ + { + "type": "Integer", + "value": 0 + } + ] + } + } + ] + }, + { + "name": "With push", + "script": "0x5274", + "steps": + [ + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0x624FD1BC5EB834B8D0E3A0EDD8B3C9B6FFE07F1F", + "instructionPointer": 1, + "nextInstruction": "DEPTH", + "evaluationStack": + [ + { + "type": "Integer", + "value": 2 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0x624FD1BC5EB834B8D0E3A0EDD8B3C9B6FFE07F1F", + "instructionPointer": 2, + "nextInstruction": "RET", + "evaluationStack": + [ + { + "type": "Integer", + "value": 1 + }, + { + "type": "Integer", + "value": 2 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Halt", + "resultStack": + [ + { + "type": "Integer", + "value": 1 + }, + { + "type": "Integer", + "value": 2 + } + ] + } + } + ] + }, + { + "name": "3xDEPTH", + "script": "0x747474", + "steps": + [ + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0xC53606A179DF21289AF657F6F8E0D4890A7C3238", + "instructionPointer": 1, + "nextInstruction": "DEPTH", + "evaluationStack": + [ + { + "type": "Integer", + "value": 0 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0xC53606A179DF21289AF657F6F8E0D4890A7C3238", + "instructionPointer": 2, + "nextInstruction": "DEPTH", + "evaluationStack": + [ + { + "type": "Integer", + "value": 1 + }, + { + "type": "Integer", + "value": 0 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0xC53606A179DF21289AF657F6F8E0D4890A7C3238", + "instructionPointer": 3, + "nextInstruction": "RET", + "evaluationStack": + [ + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 1 + }, + { + "type": "Integer", + "value": 0 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Halt", + "resultStack": + [ + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 1 + }, + { + "type": "Integer", + "value": 0 + } + ] + } + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/neo-vm.Tests/Tests/OpCodes/Stack/NIP.json b/tests/neo-vm.Tests/Tests/OpCodes/Stack/NIP.json new file mode 100644 index 00000000..75330efb --- /dev/null +++ b/tests/neo-vm.Tests/Tests/OpCodes/Stack/NIP.json @@ -0,0 +1,169 @@ +{ + "category": "Stack", + "name": "NIP", + "tests": + [ + { + "name": "Without push", + "script": "0x77", + "steps": + [ + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Fault", + "invocationStack": + [ + { + "scriptHash": "0xAE552BE33415B13B347B4DA9AF4A8DF13003886C", + "instructionPointer": 0, + "nextInstruction": "NIP" + } + ] + } + } + ] + }, + { + "name": "Without two stack items", + "script": "0x5577", + "steps": + [ + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0xD6AE3179EFA9E2386523418B3BD006CB1FFCCC54", + "instructionPointer": 1, + "nextInstruction": "NIP", + "evaluationStack": + [ + { + "type": "Integer", + "value": 5 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Fault", + "invocationStack": + [ + { + "scriptHash": "0xD6AE3179EFA9E2386523418B3BD006CB1FFCCC54", + "instructionPointer": 1, + "nextInstruction": "NIP", + "evaluationStack": + [ + { + "type": "Integer", + "value": 5 + } + ] + } + ] + } + } + ] + }, + { + "name": "Real test", + "script": "0x00009177", + "steps": + [ + { + "actions": + [ + "StepInto", + "StepInto", + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0x977A561814D8A884C9890522AFAE17532D6F70B7", + "instructionPointer": 3, + "nextInstruction": "NIP", + "evaluationStack": + [ + { + "type": "Boolean", + "value": true + }, + { + "type": "ByteArray", + "value": "" + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0x977A561814D8A884C9890522AFAE17532D6F70B7", + "instructionPointer": 4, + "nextInstruction": "RET", + "evaluationStack": + [ + { + "type": "Boolean", + "value": true + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Halt", + "resultStack": + [ + { + "type": "Boolean", + "value": true + } + ] + } + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/neo-vm.Tests/Tests/OpCodes/Stack/OVER.json b/tests/neo-vm.Tests/Tests/OpCodes/Stack/OVER.json new file mode 100644 index 00000000..a7ed58bb --- /dev/null +++ b/tests/neo-vm.Tests/Tests/OpCodes/Stack/OVER.json @@ -0,0 +1,292 @@ +{ + "category": "Stack", + "name": "OVER", + "tests": + [ + { + "name": "Without push", + "script": "0x78", + "steps": + [ + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Fault", + "invocationStack": + [ + { + "scriptHash": "0x4E944B03E84FDC97F2FB68CB62B73D000EF5BE71", + "instructionPointer": 0, + "nextInstruction": "OVER" + } + ] + } + } + ] + }, + { + "name": "With one push", + "script": "0x0078", + "steps": + [ + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0xCC7A0EED4DA27DF89934B4EECA682218408A8429", + "instructionPointer": 1, + "nextInstruction": "OVER", + "evaluationStack": + [ + { + "type": "ByteArray", + "value": "" + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Fault", + "invocationStack": + [ + { + "scriptHash": "0xCC7A0EED4DA27DF89934B4EECA682218408A8429", + "instructionPointer": 1, + "nextInstruction": "OVER", + "evaluationStack": + [ + { + "type": "ByteArray", + "value": "" + } + ] + } + ] + } + } + ] + }, + { + "name": "Real test with 2 items", + "script": "0x515278", + "steps": + [ + { + "actions": + [ + "StepInto", + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0x46504C72FD722450625CDC35C11BC227DD766C1C", + "instructionPointer": 2, + "nextInstruction": "OVER", + "evaluationStack": + [ + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 1 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0x46504C72FD722450625CDC35C11BC227DD766C1C", + "instructionPointer": 3, + "nextInstruction": "RET", + "evaluationStack": + [ + { + "type": "Integer", + "value": 1 + }, + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 1 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Halt", + "resultStack": + [ + { + "type": "Integer", + "value": 1 + }, + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 1 + } + ] + } + } + ] + }, + { + "name": "Real test with 3 items", + "script": "0x51525378", + "steps": + [ + { + "actions": + [ + "StepInto", + "StepInto", + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0xF14DD06CFEDEF7B5FC631BA25B71D8EA15BE5606", + "instructionPointer": 3, + "nextInstruction": "OVER", + "evaluationStack": + [ + { + "type": "Integer", + "value": 3 + }, + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 1 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0xF14DD06CFEDEF7B5FC631BA25B71D8EA15BE5606", + "instructionPointer": 4, + "nextInstruction": "RET", + "evaluationStack": + [ + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 3 + }, + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 1 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Halt", + "resultStack": + [ + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 3 + }, + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 1 + } + ] + } + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/neo-vm.Tests/Tests/OpCodes/Stack/ROT.json b/tests/neo-vm.Tests/Tests/OpCodes/Stack/ROT.json new file mode 100644 index 00000000..c248355d --- /dev/null +++ b/tests/neo-vm.Tests/Tests/OpCodes/Stack/ROT.json @@ -0,0 +1,255 @@ +{ + "category": "Stack", + "name": "ROT", + "tests": + [ + { + "name": "Without push", + "script": "0x7B", + "steps": + [ + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Fault", + "invocationStack": + [ + { + "scriptHash": "0x24A8837CC0C388783111CB3C70A908110A3DB01F", + "instructionPointer": 0, + "nextInstruction": "ROT" + } + ] + } + } + ] + }, + { + "name": "With one push", + "script": "0x007B", + "steps": + [ + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0xEBE1C98CCDF09D6889493CAF9511F33F28AC31BD", + "instructionPointer": 1, + "nextInstruction": "ROT", + "evaluationStack": + [ + { + "type": "ByteArray", + "value": "" + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Fault", + "invocationStack": + [ + { + "scriptHash": "0xEBE1C98CCDF09D6889493CAF9511F33F28AC31BD", + "instructionPointer": 1, + "nextInstruction": "ROT", + "evaluationStack": + [ + { + "type": "ByteArray", + "value": "" + } + ] + } + ] + } + } + ] + }, + { + "name": "With 2 items", + "script": "0x51527B", + "steps": + [ + { + "actions": + [ + "StepInto", + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0xE8429F59B9BB57BBBA5FB97A2A846DF53D56C6A8", + "instructionPointer": 2, + "nextInstruction": "ROT", + "evaluationStack": + [ + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 1 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Fault", + "invocationStack": + [ + { + "scriptHash": "0xE8429F59B9BB57BBBA5FB97A2A846DF53D56C6A8", + "instructionPointer": 2, + "nextInstruction": "ROT", + "evaluationStack": + [ + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 1 + } + ] + } + ] + } + } + ] + }, + { + "name": "Real test with 3 items", + "script": "0x5152537B", + "steps": + [ + { + "actions": + [ + "StepInto", + "StepInto", + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0x14A1B62A56570F7C2B02D8B009994D7012532A1A", + "instructionPointer": 3, + "nextInstruction": "ROT", + "evaluationStack": + [ + { + "type": "Integer", + "value": 3 + }, + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 1 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0x14A1B62A56570F7C2B02D8B009994D7012532A1A", + "instructionPointer": 4, + "nextInstruction": "RET", + "evaluationStack": + [ + { + "type": "Integer", + "value": 1 + }, + { + "type": "Integer", + "value": 3 + }, + { + "type": "Integer", + "value": 2 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Halt", + "resultStack": + [ + { + "type": "Integer", + "value": 1 + }, + { + "type": "Integer", + "value": 3 + }, + { + "type": "Integer", + "value": 2 + } + ] + } + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/neo-vm.Tests/Tests/OpCodes/Stack/SWAP.json b/tests/neo-vm.Tests/Tests/OpCodes/Stack/SWAP.json new file mode 100644 index 00000000..238287de --- /dev/null +++ b/tests/neo-vm.Tests/Tests/OpCodes/Stack/SWAP.json @@ -0,0 +1,255 @@ +{ + "category": "Stack", + "name": "SWAP", + "tests": + [ + { + "name": "Without push", + "script": "0x7C", + "steps": + [ + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Fault", + "invocationStack": + [ + { + "scriptHash": "0x9EE8159814B4207AF1287D798A6E18D5924F6B50", + "instructionPointer": 0, + "nextInstruction": "SWAP" + } + ] + } + } + ] + }, + { + "name": "With one push", + "script": "0x007C", + "steps": + [ + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0x87E8259103A041DBF0212617DECCED255E7B529F", + "instructionPointer": 1, + "nextInstruction": "SWAP", + "evaluationStack": + [ + { + "type": "ByteArray", + "value": "" + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Fault", + "invocationStack": + [ + { + "scriptHash": "0x87E8259103A041DBF0212617DECCED255E7B529F", + "instructionPointer": 1, + "nextInstruction": "SWAP", + "evaluationStack": + [ + { + "type": "ByteArray", + "value": "" + } + ] + } + ] + } + } + ] + }, + { + "name": "Real test with 2 items", + "script": "0x51527C", + "steps": + [ + { + "actions": + [ + "StepInto", + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0x5384F8B71D40DE6F002C5ED90D8C20B05CAF6819", + "instructionPointer": 2, + "nextInstruction": "SWAP", + "evaluationStack": + [ + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 1 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0x5384F8B71D40DE6F002C5ED90D8C20B05CAF6819", + "instructionPointer": 3, + "nextInstruction": "RET", + "evaluationStack": + [ + { + "type": "Integer", + "value": 1 + }, + { + "type": "Integer", + "value": 2 + } + ] + } + ] + } + } + ] + }, + { + "name": "Real test with 3 items", + "script": "0x5152537C", + "steps": + [ + { + "actions": + [ + "StepInto", + "StepInto", + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0x7348461A172D40C7BBC53EB1C5D51898F47E5EE4", + "instructionPointer": 3, + "nextInstruction": "SWAP", + "evaluationStack": + [ + { + "type": "Integer", + "value": 3 + }, + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 1 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0x7348461A172D40C7BBC53EB1C5D51898F47E5EE4", + "instructionPointer": 4, + "nextInstruction": "RET", + "evaluationStack": + [ + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 3 + }, + { + "type": "Integer", + "value": 1 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Halt", + "resultStack": + [ + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 3 + }, + { + "type": "Integer", + "value": 1 + } + ] + } + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/neo-vm.Tests/Tests/OpCodes/Stack/XDROP.json b/tests/neo-vm.Tests/Tests/OpCodes/Stack/XDROP.json new file mode 100644 index 00000000..9be66a99 --- /dev/null +++ b/tests/neo-vm.Tests/Tests/OpCodes/Stack/XDROP.json @@ -0,0 +1,292 @@ +{ + "category": "Stack", + "name": "XDROP", + "tests": + [ + { + "name": "Without push", + "script": "0x6D", + "steps": + [ + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Fault", + "invocationStack": + [ + { + "scriptHash": "0xECD8BB6107B098FC608B2C0AD3B8147549EAC11C", + "instructionPointer": 0, + "nextInstruction": "XDROP" + } + ] + } + } + ] + }, + { + "name": "Overflow drop", + "script": "0x535251536D", + "steps": + [ + { + "actions": + [ + "StepInto", + "StepInto", + "StepInto", + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0xC4B0ED142B6643896418FEB354A3E3FC957A13E9", + "instructionPointer": 4, + "nextInstruction": "XDROP", + "evaluationStack": + [ + { + "type": "Integer", + "value": 3 + }, + { + "type": "Integer", + "value": 1 + }, + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 3 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Fault", + "invocationStack": + [ + { + "scriptHash": "0xC4B0ED142B6643896418FEB354A3E3FC957A13E9", + "instructionPointer": 4, + "nextInstruction": "XDROP", + "evaluationStack": + [ + { + "type": "Integer", + "value": 1 + }, + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 3 + } + ] + } + ] + } + } + ] + }, + { + "name": "Wrong index type [Map]", + "script": "0x535251C76D", + "steps": + [ + { + "actions": + [ + "StepInto", + "StepInto", + "StepInto", + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0x6A717D954C9DF69D29E533F441960F2440454C7E", + "instructionPointer": 4, + "nextInstruction": "XDROP", + "evaluationStack": + [ + { + "type": "Map", + "value": + { + + } + }, + { + "type": "Integer", + "value": 1 + }, + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 3 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Fault", + "invocationStack": + [ + { + "scriptHash": "0x6A717D954C9DF69D29E533F441960F2440454C7E", + "instructionPointer": 4, + "nextInstruction": "XDROP", + "evaluationStack": + [ + { + "type": "Integer", + "value": 1 + }, + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 3 + } + ] + } + ] + } + } + ] + }, + { + "name": "Real test", + "script": "0x535251516D", + "steps": + [ + { + "actions": + [ + "StepInto", + "StepInto", + "StepInto", + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0xBCA3D105E94C00868726B846EFFD7E6575D9C281", + "instructionPointer": 4, + "nextInstruction": "XDROP", + "evaluationStack": + [ + { + "type": "Integer", + "value": 1 + }, + { + "type": "Integer", + "value": 1 + }, + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 3 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0xBCA3D105E94C00868726B846EFFD7E6575D9C281", + "instructionPointer": 5, + "nextInstruction": "RET", + "evaluationStack": + [ + { + "type": "Integer", + "value": 1 + }, + { + "type": "Integer", + "value": 3 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Halt", + "resultStack": + [ + { + "type": "Integer", + "value": 1 + }, + { + "type": "Integer", + "value": 3 + } + ] + } + } + ] + } + ] +} \ No newline at end of file diff --git a/tests/neo-vm.Tests/Tests/OpCodes/Stack/XSWAP.json b/tests/neo-vm.Tests/Tests/OpCodes/Stack/XSWAP.json new file mode 100644 index 00000000..526ce4bf --- /dev/null +++ b/tests/neo-vm.Tests/Tests/OpCodes/Stack/XSWAP.json @@ -0,0 +1,485 @@ +{ + "category": "Stack", + "name": "XSWAP", + "tests": + [ + { + "name": "Without push", + "script": "0x72", + "steps": + [ + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Fault", + "invocationStack": + [ + { + "scriptHash": "0x7C6A6BCF5FAA451AB936551201D4332CF31A741E", + "instructionPointer": 0, + "nextInstruction": "XSWAP" + } + ] + } + } + ] + }, + { + "name": "Pick outside", + "script": "0x5152535472", + "steps": + [ + { + "actions": + [ + "StepInto", + "StepInto", + "StepInto", + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0x6AE7AB4D735D3A154E7B52752FB0297B56730622", + "instructionPointer": 4, + "nextInstruction": "XSWAP", + "evaluationStack": + [ + { + "type": "Integer", + "value": 4 + }, + { + "type": "Integer", + "value": 3 + }, + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 1 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Fault", + "invocationStack": + [ + { + "scriptHash": "0x6AE7AB4D735D3A154E7B52752FB0297B56730622", + "instructionPointer": 4, + "nextInstruction": "XSWAP", + "evaluationStack": + [ + { + "type": "Integer", + "value": 3 + }, + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 1 + } + ] + } + ] + } + } + ] + }, + { + "name": "Less than 0", + "script": "0x5152534F72", + "steps": + [ + { + "actions": + [ + "StepInto", + "StepInto", + "StepInto", + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0x8A37769DE09C2E21AD6CC63D1D0A2B292886EBFD", + "instructionPointer": 4, + "nextInstruction": "XSWAP", + "evaluationStack": + [ + { + "type": "Integer", + "value": -1 + }, + { + "type": "Integer", + "value": 3 + }, + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 1 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Fault", + "invocationStack": + [ + { + "scriptHash": "0x8A37769DE09C2E21AD6CC63D1D0A2B292886EBFD", + "instructionPointer": 4, + "nextInstruction": "XSWAP", + "evaluationStack": + [ + { + "type": "Integer", + "value": 3 + }, + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 1 + } + ] + } + ] + } + } + ] + }, + { + "name": "Wrong type", + "script": "0x515253C772", + "steps": + [ + { + "actions": + [ + "StepInto", + "StepInto", + "StepInto", + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0x9C2F31D43F444A2E65BDD847C8FF91AF8342F8D1", + "instructionPointer": 4, + "nextInstruction": "XSWAP", + "evaluationStack": + [ + { + "type": "Map", + "value": + { + + } + }, + { + "type": "Integer", + "value": 3 + }, + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 1 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Fault", + "invocationStack": + [ + { + "scriptHash": "0x9C2F31D43F444A2E65BDD847C8FF91AF8342F8D1", + "instructionPointer": 4, + "nextInstruction": "XSWAP", + "evaluationStack": + [ + { + "type": "Integer", + "value": 3 + }, + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 1 + } + ] + } + ] + } + } + ] + }, + { + "name": "Real test", + "script": "0x5352515272", + "steps": + [ + { + "actions": + [ + "StepInto", + "StepInto", + "StepInto", + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0xF9418895125F90B3E8E57A67F6EA531DD67CDD6B", + "instructionPointer": 4, + "nextInstruction": "XSWAP", + "evaluationStack": + [ + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 1 + }, + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 3 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0xF9418895125F90B3E8E57A67F6EA531DD67CDD6B", + "instructionPointer": 5, + "nextInstruction": "RET", + "evaluationStack": + [ + { + "type": "Integer", + "value": 3 + }, + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 1 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Halt", + "resultStack": + [ + { + "type": "Integer", + "value": 3 + }, + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 1 + } + ] + } + } + ] + }, + { + "name": "Real test with 0", + "script": "0x5352510072", + "steps": + [ + { + "actions": + [ + "StepInto", + "StepInto", + "StepInto", + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0xDFFD478674E822A66351C3BBFEF09F15481DBA96", + "instructionPointer": 4, + "nextInstruction": "XSWAP", + "evaluationStack": + [ + { + "type": "ByteArray", + "value": "" + }, + { + "type": "Integer", + "value": 1 + }, + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 3 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Break", + "invocationStack": + [ + { + "scriptHash": "0xDFFD478674E822A66351C3BBFEF09F15481DBA96", + "instructionPointer": 5, + "nextInstruction": "RET", + "evaluationStack": + [ + { + "type": "Integer", + "value": 1 + }, + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 3 + } + ] + } + ] + } + }, + { + "actions": + [ + "StepInto" + ], + "result": + { + "state": "Halt", + "resultStack": + [ + { + "type": "Integer", + "value": 1 + }, + { + "type": "Integer", + "value": 2 + }, + { + "type": "Integer", + "value": 3 + } + ] + } + } + ] + } + ] +} \ No newline at end of file