diff options
author | Felix Lange <fjl@users.noreply.github.com> | 2017-07-11 19:49:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-11 19:49:14 +0800 |
commit | 225de7ca0a9e861696a5a43b666090b574c4c769 (patch) | |
tree | 68aff6fb74fece37626ced330fa9c5da91b483a4 /tests/init.go | |
parent | bd01cd7183e771984fb9c008e7a7ebf0a0c3f9ba (diff) | |
download | dexon-225de7ca0a9e861696a5a43b666090b574c4c769.tar dexon-225de7ca0a9e861696a5a43b666090b574c4c769.tar.gz dexon-225de7ca0a9e861696a5a43b666090b574c4c769.tar.bz2 dexon-225de7ca0a9e861696a5a43b666090b574c4c769.tar.lz dexon-225de7ca0a9e861696a5a43b666090b574c4c769.tar.xz dexon-225de7ca0a9e861696a5a43b666090b574c4c769.tar.zst dexon-225de7ca0a9e861696a5a43b666090b574c4c769.zip |
tests: update tests and implement general state tests (#14734)
Tests are now included as a submodule. This should make updating easier
and removes ~60MB of JSON data from the working copy.
State tests are replaced by General State Tests, which run the same test
with multiple fork configurations.
With the new test runner, consensus tests are run as subtests by walking
json files. Many hex issues have been fixed upstream since the last
update and most custom parsing code is replaced by existing JSON hex
types. Tests can now be marked as 'expected failures', ensuring that
fixes for those tests will trigger an update to test configuration. The
new test runner also supports parallel execution and the -short flag.
Diffstat (limited to 'tests/init.go')
-rw-r--r-- | tests/init.go | 119 |
1 files changed, 0 insertions, 119 deletions
diff --git a/tests/init.go b/tests/init.go deleted file mode 100644 index 7b0924bc3..000000000 --- a/tests/init.go +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright 2015 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. - -// Package tests implements execution of Ethereum JSON tests. -package tests - -import ( - "encoding/json" - "fmt" - "io" - "io/ioutil" - "net/http" - "os" - "path/filepath" -) - -var ( - baseDir = filepath.Join(".", "files") - blockTestDir = filepath.Join(baseDir, "BlockchainTests") - stateTestDir = filepath.Join(baseDir, "StateTests") - transactionTestDir = filepath.Join(baseDir, "TransactionTests") - vmTestDir = filepath.Join(baseDir, "VMTests") - rlpTestDir = filepath.Join(baseDir, "RLPTests") - - BlockSkipTests = []string{ - // These tests are not valid, as they are out of scope for RLP and - // the consensus protocol. - "BLOCK__RandomByteAtTheEnd", - "TRANSCT__RandomByteAtTheEnd", - "BLOCK__ZeroByteAtTheEnd", - "TRANSCT__ZeroByteAtTheEnd", - - "ChainAtoChainB_blockorder2", - "ChainAtoChainB_blockorder1", - - "GasLimitHigherThan2p63m1", // not yet ;) - "SuicideIssue", // fails genesis check - } - - /* Go client does not support transaction (account) nonces above 2^64. This - technically breaks consensus but is regarded as "reasonable - engineering constraint" as accounts cannot easily reach such high - nonce values in practice - */ - TransSkipTests = []string{ - "TransactionWithHihghNonce256", - "Vitalik_15", - "Vitalik_16", - "Vitalik_17", - } - StateSkipTests = []string{} - VmSkipTests = []string{} -) - -func readJson(reader io.Reader, value interface{}) error { - data, err := ioutil.ReadAll(reader) - if err != nil { - return fmt.Errorf("error reading JSON file: %v", err) - } - if err = json.Unmarshal(data, &value); err != nil { - if syntaxerr, ok := err.(*json.SyntaxError); ok { - line := findLine(data, syntaxerr.Offset) - return fmt.Errorf("JSON syntax error at line %v: %v", line, err) - } - return fmt.Errorf("JSON unmarshal error: %v", err) - } - return nil -} - -func readJsonHttp(uri string, value interface{}) error { - resp, err := http.Get(uri) - if err != nil { - return err - } - defer resp.Body.Close() - - return readJson(resp.Body, value) -} - -func readJsonFile(fn string, value interface{}) error { - file, err := os.Open(fn) - if err != nil { - return err - } - defer file.Close() - - err = readJson(file, value) - if err != nil { - return fmt.Errorf("%s in file %s", err.Error(), fn) - } - return nil -} - -// findLine returns the line number for the given offset into data. -func findLine(data []byte, offset int64) (line int) { - line = 1 - for i, r := range string(data) { - if int64(i) >= offset { - return - } - if r == '\n' { - line++ - } - } - return -} |