aboutsummaryrefslogtreecommitdiffstats
path: root/tests/transaction_test_util.go
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-06-15 05:55:03 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-06-19 04:24:07 +0800
commit01ec4dbb1251751b8bbf62ddb3b3a02dc50d29fc (patch)
treea07bed9da1fecc99f483b725f60283b01e8da845 /tests/transaction_test_util.go
parenta86452d22c2206fd05cfa72b547e7014a0859c7c (diff)
downloaddexon-01ec4dbb1251751b8bbf62ddb3b3a02dc50d29fc.tar.gz
dexon-01ec4dbb1251751b8bbf62ddb3b3a02dc50d29fc.tar.zst
dexon-01ec4dbb1251751b8bbf62ddb3b3a02dc50d29fc.zip
Add stdin option
Diffstat (limited to 'tests/transaction_test_util.go')
-rw-r--r--tests/transaction_test_util.go39
1 files changed, 34 insertions, 5 deletions
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)