github.com/0xPolygon/supernets2-node@v0.0.0-20230711153321-2fe574524eaa/test/vectors/smartcontract.go (about) 1 package vectors 2 3 import ( 4 "encoding/json" 5 "io" 6 "os" 7 "path/filepath" 8 ) 9 10 // LoadTxEventsSendBatchTestCases loads the calldata-test-vector.json 11 func LoadTxEventsSendBatchTestCases(path string) ([]TxEventsSendBatchTestCase, error) { 12 var testCases []TxEventsSendBatchTestCase 13 14 jsonFile, err := os.Open(filepath.Clean(path)) 15 if err != nil { 16 return testCases, err 17 } 18 defer func() { _ = jsonFile.Close() }() 19 20 bytes, err := io.ReadAll(jsonFile) 21 if err != nil { 22 return testCases, err 23 } 24 25 err = json.Unmarshal(bytes, &testCases) 26 if err != nil { 27 return testCases, err 28 } 29 30 return testCases, nil 31 }