From 0a554a1f27ece4235d180373643482ceb57d90ca Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 1 Apr 2015 10:53:32 +0200 Subject: Blocktest fixed, Execution fixed * Added new CreateAccount method which properly overwrites previous accounts (excluding balance) * Fixed block tests (100% success) --- tests/blocktest.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'tests/blocktest.go') 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 } -- cgit