aboutsummaryrefslogtreecommitdiffstats
path: root/tests/util.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-09-23 03:04:58 +0800
committerFelix Lange <fjl@twurst.com>2016-09-26 16:09:52 +0800
commita59a93f476434f2805c8fd3e10bf1b2f579b078f (patch)
tree17d1f3abefabfd7f8cb9149994a4788d2c0f08bc /tests/util.go
parente859f3696783ec75d9bb39c0c66eda3a88cea8c6 (diff)
downloaddexon-a59a93f476434f2805c8fd3e10bf1b2f579b078f.tar.gz
dexon-a59a93f476434f2805c8fd3e10bf1b2f579b078f.tar.zst
dexon-a59a93f476434f2805c8fd3e10bf1b2f579b078f.zip
core/state: track all accounts in canon state
This change introduces a global, per-state cache that keeps account data in the canon state. Thanks to @karalabe for lots of fixes.
Diffstat (limited to 'tests/util.go')
-rw-r--r--tests/util.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/tests/util.go b/tests/util.go
index 79c3bfad1..08fac2dd1 100644
--- a/tests/util.go
+++ b/tests/util.go
@@ -103,16 +103,17 @@ func (self Log) Topics() [][]byte {
return t
}
-func StateObjectFromAccount(db ethdb.Database, addr string, account Account) *state.StateObject {
- obj := state.NewStateObject(common.HexToAddress(addr), db)
- obj.SetBalance(common.Big(account.Balance))
-
+func StateObjectFromAccount(db ethdb.Database, addr string, account Account, onDirty func(common.Address)) *state.StateObject {
if common.IsHex(account.Code) {
account.Code = account.Code[2:]
}
- obj.SetCode(common.Hex2Bytes(account.Code))
- obj.SetNonce(common.Big(account.Nonce).Uint64())
-
+ code := common.Hex2Bytes(account.Code)
+ obj := state.NewObject(common.HexToAddress(addr), state.Account{
+ Balance: common.Big(account.Balance),
+ CodeHash: crypto.Keccak256(code),
+ Nonce: common.Big(account.Nonce).Uint64(),
+ }, onDirty)
+ obj.SetCode(code)
return obj
}