diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2016-03-02 06:32:43 +0800 |
---|---|---|
committer | Jeffrey Wilcke <geffobscura@gmail.com> | 2016-04-01 07:01:10 +0800 |
commit | f0cbebb19f3137ee3ba0e66dadd1b5b9dbf98b1c (patch) | |
tree | 02e31a0e31040980e30e3a835ff9eba73e419439 /tests/state_test_util.go | |
parent | 10d3466c934bd425a8c941270749a652a588527d (diff) | |
download | go-tangerine-f0cbebb19f3137ee3ba0e66dadd1b5b9dbf98b1c.tar.gz go-tangerine-f0cbebb19f3137ee3ba0e66dadd1b5b9dbf98b1c.tar.zst go-tangerine-f0cbebb19f3137ee3ba0e66dadd1b5b9dbf98b1c.zip |
core: added basic chain configuration
Added chain configuration options and write out during genesis database
insertion. If no "config" was found, nothing is written to the database.
Configurations are written on a per genesis base. This means
that any chain (which is identified by it's genesis hash) can have their
own chain settings.
Diffstat (limited to 'tests/state_test_util.go')
-rw-r--r-- | tests/state_test_util.go | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/tests/state_test_util.go b/tests/state_test_util.go index 50be3a1ac..9d6069ac7 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -34,26 +34,26 @@ import ( "github.com/ethereum/go-ethereum/logger/glog" ) -func RunStateTestWithReader(r io.Reader, skipTests []string) error { +func RunStateTestWithReader(ruleSet RuleSet, r io.Reader, skipTests []string) error { tests := make(map[string]VmTest) if err := readJson(r, &tests); err != nil { return err } - if err := runStateTests(tests, skipTests); err != nil { + if err := runStateTests(ruleSet, tests, skipTests); err != nil { return err } return nil } -func RunStateTest(p string, skipTests []string) error { +func RunStateTest(ruleSet RuleSet, p string, skipTests []string) error { tests := make(map[string]VmTest) if err := readJsonFile(p, &tests); err != nil { return err } - if err := runStateTests(tests, skipTests); err != nil { + if err := runStateTests(ruleSet, tests, skipTests); err != nil { return err } @@ -61,7 +61,7 @@ func RunStateTest(p string, skipTests []string) error { } -func BenchStateTest(p string, conf bconf, b *testing.B) error { +func BenchStateTest(ruleSet RuleSet, p string, conf bconf, b *testing.B) error { tests := make(map[string]VmTest) if err := readJsonFile(p, &tests); err != nil { return err @@ -71,11 +71,6 @@ func BenchStateTest(p string, conf bconf, b *testing.B) error { return fmt.Errorf("test not found: %s", conf.name) } - pJit := vm.EnableJit - vm.EnableJit = conf.jit - pForceJit := vm.ForceJit - vm.ForceJit = conf.precomp - // XXX Yeah, yeah... env := make(map[string]string) env["currentCoinbase"] = test.Env.CurrentCoinbase @@ -91,16 +86,13 @@ func BenchStateTest(p string, conf bconf, b *testing.B) error { b.ResetTimer() for i := 0; i < b.N; i++ { - benchStateTest(test, env, b) + benchStateTest(ruleSet, test, env, b) } - vm.EnableJit = pJit - vm.ForceJit = pForceJit - return nil } -func benchStateTest(test VmTest, env map[string]string, b *testing.B) { +func benchStateTest(ruleSet RuleSet, test VmTest, env map[string]string, b *testing.B) { b.StopTimer() db, _ := ethdb.NewMemDatabase() statedb, _ := state.New(common.Hash{}, db) @@ -113,10 +105,10 @@ func benchStateTest(test VmTest, env map[string]string, b *testing.B) { } b.StartTimer() - RunState(statedb, env, test.Exec) + RunState(ruleSet, statedb, env, test.Exec) } -func runStateTests(tests map[string]VmTest, skipTests []string) error { +func runStateTests(ruleSet RuleSet, tests map[string]VmTest, skipTests []string) error { skipTest := make(map[string]bool, len(skipTests)) for _, name := range skipTests { skipTest[name] = true @@ -129,7 +121,7 @@ func runStateTests(tests map[string]VmTest, skipTests []string) error { } //fmt.Println("StateTest:", name) - if err := runStateTest(test); err != nil { + if err := runStateTest(ruleSet, test); err != nil { return fmt.Errorf("%s: %s\n", name, err.Error()) } @@ -140,7 +132,7 @@ func runStateTests(tests map[string]VmTest, skipTests []string) error { } -func runStateTest(test VmTest) error { +func runStateTest(ruleSet RuleSet, test VmTest) error { db, _ := ethdb.NewMemDatabase() statedb, _ := state.New(common.Hash{}, db) for addr, account := range test.Pre { @@ -171,7 +163,7 @@ func runStateTest(test VmTest) error { logs vm.Logs ) - ret, logs, _, _ = RunState(statedb, env, test.Transaction) + ret, logs, _, _ = RunState(ruleSet, statedb, env, test.Transaction) // Compare expected and actual return rexp := common.FromHex(test.Out) @@ -219,7 +211,7 @@ func runStateTest(test VmTest) error { return nil } -func RunState(statedb *state.StateDB, env, tx map[string]string) ([]byte, vm.Logs, *big.Int, error) { +func RunState(ruleSet RuleSet, statedb *state.StateDB, env, tx map[string]string) ([]byte, vm.Logs, *big.Int, error) { var ( data = common.FromHex(tx["data"]) gas = common.Big(tx["gasLimit"]) @@ -241,7 +233,7 @@ func RunState(statedb *state.StateDB, env, tx map[string]string) ([]byte, vm.Log key, _ := hex.DecodeString(tx["secretKey"]) addr := crypto.PubkeyToAddress(crypto.ToECDSA(key).PublicKey) message := NewMessage(addr, to, data, value, gas, price, nonce) - vmenv := NewEnvFromMap(statedb, env, tx) + vmenv := NewEnvFromMap(ruleSet, statedb, env, tx) vmenv.origin = addr ret, _, err := core.ApplyMessage(vmenv, message, gaspool) if core.IsNonceErr(err) || core.IsInvalidTxErr(err) || core.IsGasLimitErr(err) { |