From 9ac5671c18ae3c36370981cd42a99639f9799042 Mon Sep 17 00:00:00 2001 From: Gustav Simonsson Date: Fri, 10 Apr 2015 11:55:31 +0200 Subject: Add TransactionTests wrapped as Go tests * Add initial go wrapping for TransactionTests with some tests disabled in lieu of consistent HEX encodings and a few other pending bugfixes * TODO: Consider better way of perhaps modelling each test in the JSON files as a single Go test, instead of one Go test per JSON file --- tests/blocktest.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'tests/blocktest.go') diff --git a/tests/blocktest.go b/tests/blocktest.go index 6b8ee9d4a..84b70678d 100644 --- a/tests/blocktest.go +++ b/tests/blocktest.go @@ -81,7 +81,7 @@ type BlockTest struct { // LoadBlockTests loads a block test JSON file. func LoadBlockTests(file string) (map[string]*BlockTest, error) { bt := make(map[string]*btJSON) - if err := loadJSON(file, &bt); err != nil { + if err := LoadJSON(file, &bt); err != nil { return nil, err } out := make(map[string]*BlockTest) @@ -250,6 +250,14 @@ func mustConvertBigInt10(in string) *big.Int { return out } +func mustConvertBigIntHex(in string) *big.Int { + out, ok := new(big.Int).SetString(in, 16) + if !ok { + panic(fmt.Errorf("invalid integer: %q", in)) + } + return out +} + func mustConvertUint(in string) uint64 { out, err := strconv.ParseUint(in, 0, 64) if err != nil { @@ -258,8 +266,16 @@ func mustConvertUint(in string) uint64 { return out } -// loadJSON reads the given file and unmarshals its content. -func loadJSON(file string, val interface{}) error { +func mustConvertUintHex(in string) uint64 { + out, err := strconv.ParseUint(in, 16, 64) + if err != nil { + panic(fmt.Errorf("invalid integer: %q", in)) + } + return out +} + +// LoadJSON reads the given file and unmarshals its content. +func LoadJSON(file string, val interface{}) error { content, err := ioutil.ReadFile(file) if err != nil { return err -- cgit v1.2.3