aboutsummaryrefslogtreecommitdiffstats
path: root/tests/block_test_util.go
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-06-11 04:10:33 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-06-19 04:20:44 +0800
commitc5d6fcbaba545d1078f5411dc67208d5d388222e (patch)
tree20d4e6592ba8411a0ab5980522029c4aac4a8244 /tests/block_test_util.go
parent24554629b162d20a1f945386a45e3221c58adc2b (diff)
downloaddexon-c5d6fcbaba545d1078f5411dc67208d5d388222e.tar.gz
dexon-c5d6fcbaba545d1078f5411dc67208d5d388222e.tar.zst
dexon-c5d6fcbaba545d1078f5411dc67208d5d388222e.zip
Return error up stack instead of passing testing var down
Diffstat (limited to 'tests/block_test_util.go')
-rw-r--r--tests/block_test_util.go23
1 files changed, 13 insertions, 10 deletions
diff --git a/tests/block_test_util.go b/tests/block_test_util.go
index e60607c0f..ec532d178 100644
--- a/tests/block_test_util.go
+++ b/tests/block_test_util.go
@@ -11,7 +11,6 @@ import (
"runtime"
"strconv"
"strings"
- "testing"
"time"
"github.com/ethereum/go-ethereum/accounts"
@@ -87,10 +86,10 @@ type btTransaction struct {
Value string
}
-func runBlockTestsInFile(filepath string, snafus []string, t *testing.T) {
+func runBlockTestsInFile(filepath string, snafus []string) error {
bt, err := LoadBlockTests(filepath)
if err != nil {
- t.Fatal(err)
+ return nil
}
notWorking := make(map[string]bool, 100)
@@ -100,21 +99,24 @@ func runBlockTestsInFile(filepath string, snafus []string, t *testing.T) {
for name, test := range bt {
if !notWorking[name] {
- runBlockTest(name, test, t)
+ if err := runBlockTest(name, test); err != nil {
+ return err
+ }
}
}
+ return nil
}
-func runBlockTest(name string, test *BlockTest, t *testing.T) {
+func runBlockTest(name string, test *BlockTest) error {
cfg := testEthConfig()
ethereum, err := eth.New(cfg)
if err != nil {
- t.Fatalf("%v", err)
+ return err
}
err = ethereum.Start()
if err != nil {
- t.Fatalf("%v", err)
+ return err
}
// import the genesis block
@@ -123,19 +125,20 @@ func runBlockTest(name string, test *BlockTest, t *testing.T) {
// import pre accounts
statedb, err := test.InsertPreState(ethereum)
if err != nil {
- t.Fatalf("InsertPreState: %v", err)
+ return fmt.Errorf("InsertPreState: %v", err)
}
err = test.TryBlocksInsert(ethereum.ChainManager())
if err != nil {
- t.Fatal(err)
+ return err
}
if err = test.ValidatePostState(statedb); err != nil {
- t.Fatal("post state validation failed: %v", err)
+ return fmt.Errorf("post state validation failed: %v", err)
}
fmt.Println("Block test passed: ", name)
// t.Log("Block test passed: ", name)
+ return nil
}
func testEthConfig() *eth.Config {