diff options
author | obscuren <geffobscura@gmail.com> | 2015-04-01 16:53:32 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-04-01 16:53:32 +0800 |
commit | 0a554a1f27ece4235d180373643482ceb57d90ca (patch) | |
tree | 6ab7d4cd70f7c49f64822d8e626f422158c70e78 /tests | |
parent | d3e86f9208d775ee8020d5583d0aac8f3cfb52b2 (diff) | |
download | dexon-0a554a1f27ece4235d180373643482ceb57d90ca.tar.gz dexon-0a554a1f27ece4235d180373643482ceb57d90ca.tar.zst dexon-0a554a1f27ece4235d180373643482ceb57d90ca.zip |
Blocktest fixed, Execution fixed
* Added new CreateAccount method which properly overwrites previous
accounts (excluding balance)
* Fixed block tests (100% success)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/blocktest.go | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/tests/blocktest.go b/tests/blocktest.go index d813ebeec..fc62eda58 100644 --- a/tests/blocktest.go +++ b/tests/blocktest.go @@ -4,7 +4,6 @@ import ( "bytes" "encoding/hex" "encoding/json" - "errors" "fmt" "io/ioutil" "math/big" @@ -69,7 +68,7 @@ type btBlock struct { BlockHeader *btHeader Rlp string Transactions []btTransaction - UncleHeaders []string + UncleHeaders []*btHeader } type BlockTest struct { @@ -106,13 +105,13 @@ func (t *BlockTest) InsertPreState(db common.Database) (*state.StateDB, error) { balance, _ := new(big.Int).SetString(acct.Balance, 0) nonce, _ := strconv.ParseUint(acct.Nonce, 16, 64) - obj := statedb.NewStateObject(common.HexToAddress(addrString)) + obj := statedb.CreateAccount(common.HexToAddress(addrString)) obj.SetCode(code) obj.SetBalance(balance) obj.SetNonce(nonce) - // for k, v := range acct.Storage { - // obj.SetState(k, v) - // } + for k, v := range acct.Storage { + statedb.SetState(common.HexToAddress(addrString), common.HexToHash(k), common.FromHex(v)) + } } // sync objects to trie statedb.Update(nil) @@ -120,7 +119,7 @@ func (t *BlockTest) InsertPreState(db common.Database) (*state.StateDB, error) { statedb.Sync() if !bytes.Equal(t.Genesis.Root().Bytes(), statedb.Root().Bytes()) { - return nil, errors.New("computed state root does not match genesis block") + return nil, fmt.Errorf("computed state root does not match genesis block %x %x", t.Genesis.Root().Bytes()[:4], statedb.Root().Bytes()[:4]) } return statedb, nil } |