aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-10-19 05:20:25 +0800
committerobscuren <geffobscura@gmail.com>2014-10-19 05:20:25 +0800
commit3bc64b6b6edf380aaa145e612988a4aa640e0d23 (patch)
treed495f81a7e7b27334ef35ddaeff7ce3757e403c0 /tests
parent73c1c2c4af17115b1b1d39d947d5d9cc4d8b07fb (diff)
downloaddexon-3bc64b6b6edf380aaa145e612988a4aa640e0d23.tar.gz
dexon-3bc64b6b6edf380aaa145e612988a4aa640e0d23.tar.zst
dexon-3bc64b6b6edf380aaa145e612988a4aa640e0d23.zip
Readers
Diffstat (limited to 'tests')
-rw-r--r--tests/helper/http.go25
-rw-r--r--tests/helper/readers.go42
-rw-r--r--tests/vm/gh_test.go4
3 files changed, 44 insertions, 27 deletions
diff --git a/tests/helper/http.go b/tests/helper/http.go
deleted file mode 100644
index 3c570d106..000000000
--- a/tests/helper/http.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package helper
-
-import (
- "encoding/json"
- "io/ioutil"
- "net/http"
- "testing"
-)
-
-func CreateTests(t *testing.T, uri string, value interface{}) {
- resp, err := http.Get(uri)
- if err != nil {
- t.Error(err)
-
- return
- }
- defer resp.Body.Close()
-
- data, err := ioutil.ReadAll(resp.Body)
-
- err = json.Unmarshal(data, &value)
- if err != nil {
- t.Error(err)
- }
-}
diff --git a/tests/helper/readers.go b/tests/helper/readers.go
new file mode 100644
index 000000000..03313aeda
--- /dev/null
+++ b/tests/helper/readers.go
@@ -0,0 +1,42 @@
+package helper
+
+import (
+ "encoding/json"
+ "io"
+ "io/ioutil"
+ "net/http"
+ "os"
+ "testing"
+)
+
+func readJSON(t *testing.T, reader io.Reader, value interface{}) {
+ data, err := ioutil.ReadAll(reader)
+ err = json.Unmarshal(data, &value)
+ if err != nil {
+ t.Error(err)
+ }
+}
+
+func CreateHttpTests(t *testing.T, uri string, value interface{}) {
+ resp, err := http.Get(uri)
+ if err != nil {
+ t.Error(err)
+
+ return
+ }
+ defer resp.Body.Close()
+
+ readJSON(t, resp.Body, value)
+}
+
+func CreateFileTests(t *testing.T, fn string, value interface{}) {
+ file, err := os.Open(fn)
+ if err != nil {
+ t.Error(err)
+
+ return
+ }
+ defer file.Close()
+
+ readJSON(t, file, value)
+}
diff --git a/tests/vm/gh_test.go b/tests/vm/gh_test.go
index c7f88a112..bfccef072 100644
--- a/tests/vm/gh_test.go
+++ b/tests/vm/gh_test.go
@@ -41,7 +41,7 @@ type VmTest struct {
func RunVmTest(url string, t *testing.T) {
tests := make(map[string]VmTest)
- helper.CreateTests(t, url, &tests)
+ helper.CreateHttpTests(t, url, &tests)
for name, test := range tests {
state := ethstate.New(helper.NewTrie())
@@ -88,12 +88,12 @@ func RunVmTest(url string, t *testing.T) {
// I've created a new function for each tests so it's easier to identify where the problem lies if any of them fail.
func TestVMArithmetic(t *testing.T) {
+ //helper.Logger.SetLogLevel(5)
const url = "https://raw.githubusercontent.com/ethereum/tests/develop/vmtests/vmArithmeticTest.json"
RunVmTest(url, t)
}
func TestVMSystemOperation(t *testing.T) {
- //helper.Logger.SetLogLevel(5)
const url = "https://raw.githubusercontent.com/ethereum/tests/develop/vmtests/vmSystemOperationsTest.json"
RunVmTest(url, t)
}