From a44acd25bb36aa87e5f6a4195759cf630e1034ff Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 20 May 2020 15:51:50 +0300 Subject: [PATCH] vm/tests: restore JSON tests parsing Make sure we support new test format. Tests itself will be restored later. --- pkg/vm/json_test.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pkg/vm/json_test.go b/pkg/vm/json_test.go index 34e2d2d46..2bcfc72ef 100644 --- a/pkg/vm/json_test.go +++ b/pkg/vm/json_test.go @@ -94,7 +94,6 @@ const ( ) func TestUT(t *testing.T) { - t.Skip() testsRan := false err := filepath.Walk(testsDir, func(path string, info os.FileInfo, err error) error { if !strings.HasSuffix(path, ".json") { @@ -124,12 +123,25 @@ func testFile(t *testing.T, filename string) { data, err := ioutil.ReadFile(filename) require.NoError(t, err) + // get rid of possible BOM + if len(data) > 2 && data[0] == 0xef && data[1] == 0xbb && data[2] == 0xbf { + data = data[3:] + } + if strings.HasSuffix(filename, "MEMCPY.json") { + return // FIXME not a valid JSON https://github.com/neo-project/neo-vm/issues/322 + } + ut := new(vmUT) - require.NoError(t, json.Unmarshal(data, ut)) + require.NoErrorf(t, json.Unmarshal(data, ut), "file: %s", filename) + return t.Run(ut.Category+":"+ut.Name, func(t *testing.T) { + isRot := strings.HasSuffix(filename, "ROT.json") for i := range ut.Tests { test := ut.Tests[i] + if isRot && test.Name == "Without push" { + return // FIXME #927 single ROT is interpreted as PUSH1 + } t.Run(ut.Tests[i].Name, func(t *testing.T) { prog := []byte(test.Script) vm := load(prog)