aboutsummaryrefslogtreecommitdiffstats
path: root/tests/state_test_util.go
diff options
context:
space:
mode:
Diffstat (limited to 'tests/state_test_util.go')
-rw-r--r--tests/state_test_util.go22
1 files changed, 4 insertions, 18 deletions
diff --git a/tests/state_test_util.go b/tests/state_test_util.go
index 67e4bf832..3c4b42a18 100644
--- a/tests/state_test_util.go
+++ b/tests/state_test_util.go
@@ -95,14 +95,7 @@ func BenchStateTest(ruleSet RuleSet, p string, conf bconf, b *testing.B) error {
func benchStateTest(ruleSet RuleSet, test VmTest, env map[string]string, b *testing.B) {
b.StopTimer()
db, _ := ethdb.NewMemDatabase()
- statedb, _ := state.New(common.Hash{}, db)
- for addr, account := range test.Pre {
- obj := StateObjectFromAccount(db, addr, account, statedb.MarkStateObjectDirty)
- statedb.SetStateObject(obj)
- for a, v := range account.Storage {
- obj.SetState(common.HexToHash(a), common.HexToHash(v))
- }
- }
+ statedb := makePreState(db, test.Pre)
b.StartTimer()
RunState(ruleSet, statedb, env, test.Exec)
@@ -134,14 +127,7 @@ func runStateTests(ruleSet RuleSet, tests map[string]VmTest, skipTests []string)
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, statedb.MarkStateObjectDirty)
- statedb.SetStateObject(obj)
- for a, v := range account.Storage {
- obj.SetState(common.HexToHash(a), common.HexToHash(v))
- }
- }
+ statedb := makePreState(db, test.Pre)
// XXX Yeah, yeah...
env := make(map[string]string)
@@ -227,7 +213,7 @@ func RunState(ruleSet RuleSet, statedb *state.StateDB, env, tx map[string]string
}
// Set pre compiled contracts
vm.Precompiled = vm.PrecompiledContracts()
- snapshot := statedb.Copy()
+ snapshot := statedb.Snapshot()
gaspool := new(core.GasPool).AddGas(common.Big(env["currentGasLimit"]))
key, _ := hex.DecodeString(tx["secretKey"])
@@ -237,7 +223,7 @@ func RunState(ruleSet RuleSet, statedb *state.StateDB, env, tx map[string]string
vmenv.origin = addr
ret, _, err := core.ApplyMessage(vmenv, message, gaspool)
if core.IsNonceErr(err) || core.IsInvalidTxErr(err) || core.IsGasLimitErr(err) {
- statedb.Set(snapshot)
+ statedb.RevertToSnapshot(snapshot)
}
statedb.Commit()