vm/tests: restore JSON tests parsing
Make sure we support new test format. Tests itself will be restored later.
This commit is contained in:
parent
61b1722745
commit
a44acd25bb
1 changed files with 14 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue