diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-09-26 17:36:53 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-26 17:36:53 +0800 |
commit | 7a5843de318f4bf0e41ddaab2d690fbe6fd04099 (patch) | |
tree | b26a834bc371947cbdf93e6d60eea6476ab3de7a /tests | |
parent | 6999f1da6b0f8c93b40aa90250e55166018a11a5 (diff) | |
parent | 0cc6397195a9cbda719e6955e75be84fcf57ef7a (diff) | |
download | go-tangerine-7a5843de318f4bf0e41ddaab2d690fbe6fd04099.tar go-tangerine-7a5843de318f4bf0e41ddaab2d690fbe6fd04099.tar.gz go-tangerine-7a5843de318f4bf0e41ddaab2d690fbe6fd04099.tar.bz2 go-tangerine-7a5843de318f4bf0e41ddaab2d690fbe6fd04099.tar.lz go-tangerine-7a5843de318f4bf0e41ddaab2d690fbe6fd04099.tar.xz go-tangerine-7a5843de318f4bf0e41ddaab2d690fbe6fd04099.tar.zst go-tangerine-7a5843de318f4bf0e41ddaab2d690fbe6fd04099.zip |
Merge pull request #3038 from fjl/release/1.4
[release/1.4.13] core/state: track all accounts in canon state
Diffstat (limited to 'tests')
-rw-r--r-- | tests/state_test_util.go | 6 | ||||
-rw-r--r-- | tests/util.go | 15 | ||||
-rw-r--r-- | tests/vm_test_util.go | 8 |
3 files changed, 14 insertions, 15 deletions
diff --git a/tests/state_test_util.go b/tests/state_test_util.go index 36fa30881..67e4bf832 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -97,7 +97,7 @@ func benchStateTest(ruleSet RuleSet, test VmTest, env map[string]string, b *test db, _ := ethdb.NewMemDatabase() statedb, _ := state.New(common.Hash{}, db) for addr, account := range test.Pre { - obj := StateObjectFromAccount(db, addr, account) + obj := StateObjectFromAccount(db, addr, account, statedb.MarkStateObjectDirty) statedb.SetStateObject(obj) for a, v := range account.Storage { obj.SetState(common.HexToHash(a), common.HexToHash(v)) @@ -136,7 +136,7 @@ func runStateTest(ruleSet RuleSet, test VmTest) error { db, _ := ethdb.NewMemDatabase() statedb, _ := state.New(common.Hash{}, db) for addr, account := range test.Pre { - obj := StateObjectFromAccount(db, addr, account) + obj := StateObjectFromAccount(db, addr, account, statedb.MarkStateObjectDirty) statedb.SetStateObject(obj) for a, v := range account.Storage { obj.SetState(common.HexToHash(a), common.HexToHash(v)) @@ -187,7 +187,7 @@ func runStateTest(ruleSet RuleSet, test VmTest) error { } for addr, value := range account.Storage { - v := obj.GetState(common.HexToHash(addr)) + v := statedb.GetState(obj.Address(), common.HexToHash(addr)) vexp := common.HexToHash(value) if v != vexp { diff --git a/tests/util.go b/tests/util.go index a13ae3610..df3432bdf 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 } diff --git a/tests/vm_test_util.go b/tests/vm_test_util.go index 37f0af33c..4ad72d91c 100644 --- a/tests/vm_test_util.go +++ b/tests/vm_test_util.go @@ -103,7 +103,7 @@ func benchVmTest(test VmTest, env map[string]string, b *testing.B) { db, _ := ethdb.NewMemDatabase() statedb, _ := state.New(common.Hash{}, db) for addr, account := range test.Pre { - obj := StateObjectFromAccount(db, addr, account) + obj := StateObjectFromAccount(db, addr, account, statedb.MarkStateObjectDirty) statedb.SetStateObject(obj) for a, v := range account.Storage { obj.SetState(common.HexToHash(a), common.HexToHash(v)) @@ -154,7 +154,7 @@ func runVmTest(test VmTest) error { db, _ := ethdb.NewMemDatabase() statedb, _ := state.New(common.Hash{}, db) for addr, account := range test.Pre { - obj := StateObjectFromAccount(db, addr, account) + obj := StateObjectFromAccount(db, addr, account, statedb.MarkStateObjectDirty) statedb.SetStateObject(obj) for a, v := range account.Storage { obj.SetState(common.HexToHash(a), common.HexToHash(v)) @@ -205,11 +205,9 @@ func runVmTest(test VmTest) error { if obj == nil { continue } - for addr, value := range account.Storage { - v := obj.GetState(common.HexToHash(addr)) + v := statedb.GetState(obj.Address(), common.HexToHash(addr)) vexp := common.HexToHash(value) - if v != vexp { return fmt.Errorf("(%x: %s) storage failed. Expected %x, got %x (%v %v)\n", obj.Address().Bytes()[0:4], addr, vexp, v, vexp.Big(), v.Big()) } |