vm/tests: restore JSON tests parsing

Make sure we support new test format. Tests itself will be restored
later.
This commit is contained in:
Evgenii Stratonikov 2020-05-20 15:51:50 +03:00
parent 61b1722745
commit a44acd25bb

View file

@ -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)