aboutsummaryrefslogtreecommitdiffstats
path: root/tests/vm_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/vm_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/vm_test_util.go')
-rw-r--r--tests/vm_test_util.go18
1 files changed, 11 insertions, 7 deletions
diff --git a/tests/vm_test_util.go b/tests/vm_test_util.go
index 6743a0872..5d9635afd 100644
--- a/tests/vm_test_util.go
+++ b/tests/vm_test_util.go
@@ -6,7 +6,7 @@ import (
"fmt"
"math/big"
"strconv"
- "testing"
+ // "testing"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
@@ -79,10 +79,13 @@ type VmTest struct {
PostStateRoot string
}
-func RunVmTest(p string, t *testing.T) {
+func RunVmTest(p string) error {
tests := make(map[string]VmTest)
- CreateFileTests(t, p, &tests)
+ err := CreateFileTests(p, &tests)
+ if err != nil {
+ return err
+ }
for name, test := range tests {
/*
@@ -128,16 +131,16 @@ func RunVmTest(p string, t *testing.T) {
// Compare expectedand actual return
rexp := common.FromHex(test.Out)
if bytes.Compare(rexp, ret) != 0 {
- t.Errorf("%s's return failed. Expected %x, got %x\n", name, rexp, ret)
+ return fmt.Errorf("%s's return failed. Expected %x, got %x\n", name, rexp, ret)
}
// Check gas usage
if len(test.Gas) == 0 && err == nil {
- t.Errorf("%s's gas unspecified, indicating an error. VM returned (incorrectly) successfull", name)
+ return fmt.Errorf("%s's gas unspecified, indicating an error. VM returned (incorrectly) successfull", name)
} else {
gexp := common.Big(test.Gas)
if gexp.Cmp(gas) != 0 {
- t.Errorf("%s's gas failed. Expected %v, got %v\n", name, gexp, gas)
+ return fmt.Errorf("%s's gas failed. Expected %v, got %v\n", name, gexp, gas)
}
}
@@ -153,7 +156,7 @@ func RunVmTest(p string, t *testing.T) {
vexp := common.HexToHash(value)
if v != vexp {
- t.Errorf("%s's : (%x: %s) storage failed. Expected %x, got %x (%v %v)\n", name, obj.Address().Bytes()[0:4], addr, vexp, v, vexp.Big(), v.Big())
+ return t.Errorf("%s's : (%x: %s) storage failed. Expected %x, got %x (%v %v)\n", name, obj.Address().Bytes()[0:4], addr, vexp, v, vexp.Big(), v.Big())
}
}
}
@@ -168,6 +171,7 @@ func RunVmTest(p string, t *testing.T) {
//fmt.Println(string(statedb.Dump()))
}
// logger.Flush()
+ return nil
}
type Env struct {