aboutsummaryrefslogtreecommitdiffstats
path: root/tests/transaction_test_util.go
diff options
context:
space:
mode:
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)