From 01ec4dbb1251751b8bbf62ddb3b3a02dc50d29fc Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Sun, 14 Jun 2015 17:55:03 -0400 Subject: Add stdin option --- tests/transaction_test_util.go | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) (limited to 'tests/transaction_test_util.go') diff --git a/tests/transaction_test_util.go b/tests/transaction_test_util.go index ef133a99d..af33f2c58 100644 --- a/tests/transaction_test_util.go +++ b/tests/transaction_test_util.go @@ -4,6 +4,7 @@ import ( "bytes" "errors" "fmt" + "io" "runtime" "github.com/ethereum/go-ethereum/common" @@ -31,14 +32,41 @@ type TransactionTest struct { Transaction TtTransaction } +func RunTransactionTestsWithReader(r io.Reader) error { + skipTest := make(map[string]bool, len(TransSkipTests)) + for _, name := range TransSkipTests { + skipTest[name] = true + } + + bt := make(map[string]TransactionTest) + if err := readJson(r, &bt); err != nil { + return err + } + + for name, test := range bt { + // if the test should be skipped, return + if skipTest[name] { + glog.Infoln("Skipping transaction test", name) + return nil + } + // test the block + if err := runTransactionTest(test); err != nil { + return err + } + glog.Infoln("Transaction test passed: ", name) + + } + return nil +} + func RunTransactionTests(file string) error { - skipTest := make(map[string]bool, len(transSkipTests)) - for _, name := range transSkipTests { + skipTest := make(map[string]bool, len(TransSkipTests)) + for _, name := range TransSkipTests { skipTest[name] = true } bt := make(map[string]TransactionTest) - if err := readTestFile(file, &bt); err != nil { + if err := readJsonFile(file, &bt); err != nil { return err } @@ -48,8 +76,9 @@ func RunTransactionTests(file string) error { glog.Infoln("Skipping transaction test", name) return nil } + // test the block - if err := runTest(test); err != nil { + if err := runTransactionTest(test); err != nil { return err } glog.Infoln("Transaction test passed: ", name) @@ -58,7 +87,7 @@ func RunTransactionTests(file string) error { return nil } -func runTest(txTest TransactionTest) (err error) { +func runTransactionTest(txTest TransactionTest) (err error) { tx := new(types.Transaction) err = rlp.DecodeBytes(mustConvertBytes(txTest.Rlp), tx) -- cgit v1.2.3