|
|
@ -208,10 +208,22 @@ func (t *BlockTest) InsertPreState(ethereum *eth.Ethereum) (*state.StateDB, erro |
|
|
|
db := ethereum.StateDb() |
|
|
|
db := ethereum.StateDb() |
|
|
|
statedb := state.New(common.Hash{}, db) |
|
|
|
statedb := state.New(common.Hash{}, db) |
|
|
|
for addrString, acct := range t.preAccounts { |
|
|
|
for addrString, acct := range t.preAccounts { |
|
|
|
addr, _ := hex.DecodeString(addrString) |
|
|
|
addr, err := hex.DecodeString(addrString) |
|
|
|
code, _ := hex.DecodeString(strings.TrimPrefix(acct.Code, "0x")) |
|
|
|
if err != nil { |
|
|
|
balance, _ := new(big.Int).SetString(acct.Balance, 0) |
|
|
|
return nil, err |
|
|
|
nonce, _ := strconv.ParseUint(acct.Nonce, 16, 64) |
|
|
|
} |
|
|
|
|
|
|
|
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 != "" { |
|
|
|
if acct.PrivateKey != "" { |
|
|
|
privkey, err := hex.DecodeString(strings.TrimPrefix(acct.PrivateKey, "0x")) |
|
|
|
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 { |
|
|
|
func (t *BlockTest) ValidatePostState(statedb *state.StateDB) error { |
|
|
|
for addrString, acct := range t.preAccounts { |
|
|
|
for addrString, acct := range t.preAccounts { |
|
|
|
// XXX: is is worth it checking for errors here?
|
|
|
|
// XXX: is is worth it checking for errors here?
|
|
|
|
addr, _ := hex.DecodeString(addrString) |
|
|
|
addr, err := hex.DecodeString(addrString) |
|
|
|
code, _ := hex.DecodeString(strings.TrimPrefix(acct.Code, "0x")) |
|
|
|
if err != nil { |
|
|
|
balance, _ := new(big.Int).SetString(acct.Balance, 0) |
|
|
|
return err |
|
|
|
nonce, _ := strconv.ParseUint(acct.Nonce, 16, 64) |
|
|
|
} |
|
|
|
|
|
|
|
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
|
|
|
|
// address is indirectly verified by the other fields, as it's the db key
|
|
|
|
code2 := statedb.GetCode(common.BytesToAddress(addr)) |
|
|
|
code2 := statedb.GetCode(common.BytesToAddress(addr)) |
|
|
|