github.com/0xPolygon/supernets2-node@v0.0.0-20230711153321-2fe574524eaa/test/vectors/statetransition.go (about)

     1  package vectors
     2  
     3  import (
     4  	"encoding/json"
     5  	"io"
     6  	"os"
     7  	"path/filepath"
     8  )
     9  
    10  // LoadStateTransitionTestCases loads the state-transition.json into a
    11  // StateTransitionVector instance
    12  func LoadStateTransitionTestCases(path string) ([]StateTransitionTestCase, error) {
    13  	var testCases []StateTransitionTestCase
    14  
    15  	jsonFile, err := os.Open(filepath.Clean(path))
    16  	if err != nil {
    17  		return testCases, err
    18  	}
    19  	defer func() { _ = jsonFile.Close() }()
    20  
    21  	bytes, err := io.ReadAll(jsonFile)
    22  	if err != nil {
    23  		return testCases, err
    24  	}
    25  
    26  	err = json.Unmarshal(bytes, &testCases)
    27  	if err != nil {
    28  		return testCases, err
    29  	}
    30  
    31  	return testCases, nil
    32  }