diff options
author | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-04-10 17:55:31 +0800 |
---|---|---|
committer | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-04-10 17:55:31 +0800 |
commit | 9ac5671c18ae3c36370981cd42a99639f9799042 (patch) | |
tree | 8957bac6f83e33209686d2dc221783bc5b42cce7 /tests/blocktest.go | |
parent | 1e18f4544b7e85619c8902a5e2fb408984f277b6 (diff) | |
download | go-tangerine-9ac5671c18ae3c36370981cd42a99639f9799042.tar go-tangerine-9ac5671c18ae3c36370981cd42a99639f9799042.tar.gz go-tangerine-9ac5671c18ae3c36370981cd42a99639f9799042.tar.bz2 go-tangerine-9ac5671c18ae3c36370981cd42a99639f9799042.tar.lz go-tangerine-9ac5671c18ae3c36370981cd42a99639f9799042.tar.xz go-tangerine-9ac5671c18ae3c36370981cd42a99639f9799042.tar.zst go-tangerine-9ac5671c18ae3c36370981cd42a99639f9799042.zip |
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
Diffstat (limited to 'tests/blocktest.go')
-rw-r--r-- | tests/blocktest.go | 22 |
1 files changed, 19 insertions, 3 deletions
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 |