aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustav Simonsson <gustav.simonsson@gmail.com>2015-07-08 05:57:54 +0800
committerGustav Simonsson <gustav.simonsson@gmail.com>2015-07-08 19:09:22 +0800
commitb08abe64e4d2e3fa8d10c89647595226d6b31b19 (patch)
tree30e1f8b499313bd71a7910b62d773a586fbbd156
parent0b53a5c67381b3843ae01bf4210b57416ab5d210 (diff)
downloaddexon-b08abe64e4d2e3fa8d10c89647595226d6b31b19.tar
dexon-b08abe64e4d2e3fa8d10c89647595226d6b31b19.tar.gz
dexon-b08abe64e4d2e3fa8d10c89647595226d6b31b19.tar.bz2
dexon-b08abe64e4d2e3fa8d10c89647595226d6b31b19.tar.lz
dexon-b08abe64e4d2e3fa8d10c89647595226d6b31b19.tar.xz
dexon-b08abe64e4d2e3fa8d10c89647595226d6b31b19.tar.zst
dexon-b08abe64e4d2e3fa8d10c89647595226d6b31b19.zip
Unskip SimpleTx3, check err in pre/post state validations
-rw-r--r--tests/block_test_util.go40
-rw-r--r--tests/init.go7
2 files changed, 33 insertions, 14 deletions
diff --git a/tests/block_test_util.go b/tests/block_test_util.go
index 5432bf845..e624cced0 100644
--- a/tests/block_test_util.go
+++ b/tests/block_test_util.go
@@ -208,10 +208,22 @@ func (t *BlockTest) InsertPreState(ethereum *eth.Ethereum) (*state.StateDB, erro
db := ethereum.StateDb()
statedb := state.New(common.Hash{}, db)
for addrString, acct := range t.preAccounts {
- addr, _ := hex.DecodeString(addrString)
- code, _ := hex.DecodeString(strings.TrimPrefix(acct.Code, "0x"))
- balance, _ := new(big.Int).SetString(acct.Balance, 0)
- nonce, _ := strconv.ParseUint(acct.Nonce, 16, 64)
+ addr, err := hex.DecodeString(addrString)
+ if err != nil {
+ return nil, err
+ }
+ code, err := hex.DecodeString(strings.TrimPrefix(acct.Code, "0x"))
+ if err != nil {
+ return nil, err
+ }
+ balance, ok := new(big.Int).SetString(acct.Balance, 0)
+ if !ok {
+ return nil, err
+ }
+ nonce, err := strconv.ParseUint(prepInt(16, acct.Nonce), 16, 64)
+ if err != nil {
+ return nil, err
+ }
if acct.PrivateKey != "" {
privkey, err := hex.DecodeString(strings.TrimPrefix(acct.PrivateKey, "0x"))
@@ -365,10 +377,22 @@ func (s *BlockTest) validateBlockHeader(h *btHeader, h2 *types.Header) error {
func (t *BlockTest) ValidatePostState(statedb *state.StateDB) error {
for addrString, acct := range t.preAccounts {
// XXX: is is worth it checking for errors here?
- addr, _ := hex.DecodeString(addrString)
- code, _ := hex.DecodeString(strings.TrimPrefix(acct.Code, "0x"))
- balance, _ := new(big.Int).SetString(acct.Balance, 0)
- nonce, _ := strconv.ParseUint(acct.Nonce, 16, 64)
+ addr, err := hex.DecodeString(addrString)
+ if err != nil {
+ return err
+ }
+ code, err := hex.DecodeString(strings.TrimPrefix(acct.Code, "0x"))
+ if err != nil {
+ return err
+ }
+ balance, ok := new(big.Int).SetString(acct.Balance, 0)
+ if !ok {
+ return err
+ }
+ nonce, err := strconv.ParseUint(prepInt(16, acct.Nonce), 16, 64)
+ if err != nil {
+ return err
+ }
// address is indirectly verified by the other fields, as it's the db key
code2 := statedb.GetCode(common.BytesToAddress(addr))
diff --git a/tests/init.go b/tests/init.go
index 94178af5f..f149c11f1 100644
--- a/tests/init.go
+++ b/tests/init.go
@@ -37,11 +37,6 @@ var (
vmTestDir = filepath.Join(baseDir, "VMTests")
BlockSkipTests = []string{
- // Fails in InsertPreState with: computed state root does not
- // match genesis block bba25a96 0d8f85c8 Christoph said it will be
- // fixed eventually
- "SimpleTx3",
-
// These tests are not valid, as they are out of scope for RLP and
// the consensus protocol.
"BLOCK__RandomByteAtTheEnd",
@@ -50,7 +45,7 @@ var (
"TRANSCT__ZeroByteAtTheEnd",
}
- /* Go does not support transaction (account) nonces above 2^64. This
+ /* 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