diff options
author | obscuren <geffobscura@gmail.com> | 2015-03-10 00:55:01 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-03-10 00:55:01 +0800 |
commit | 8560004f380dc688a1171ad5aeffa593aae41193 (patch) | |
tree | fea395acf042b51e97a86e2c4cbcf8c16b2912b7 /tests/vm | |
parent | 9723191b19f6ddc12f0c3376ede7529b2d72e6a2 (diff) | |
parent | 676a0de58d3d7c508b0eeeff192d2095a46f7382 (diff) | |
download | go-tangerine-8560004f380dc688a1171ad5aeffa593aae41193.tar go-tangerine-8560004f380dc688a1171ad5aeffa593aae41193.tar.gz go-tangerine-8560004f380dc688a1171ad5aeffa593aae41193.tar.bz2 go-tangerine-8560004f380dc688a1171ad5aeffa593aae41193.tar.lz go-tangerine-8560004f380dc688a1171ad5aeffa593aae41193.tar.xz go-tangerine-8560004f380dc688a1171ad5aeffa593aae41193.tar.zst go-tangerine-8560004f380dc688a1171ad5aeffa593aae41193.zip |
wip
Diffstat (limited to 'tests/vm')
-rw-r--r-- | tests/vm/gh_test.go | 77 |
1 files changed, 54 insertions, 23 deletions
diff --git a/tests/vm/gh_test.go b/tests/vm/gh_test.go index 2151cf9a5..2db7a0fd0 100644 --- a/tests/vm/gh_test.go +++ b/tests/vm/gh_test.go @@ -6,7 +6,6 @@ import ( "strconv" "testing" - "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/logger" @@ -64,25 +63,30 @@ type Env struct { type VmTest struct { Callcreates interface{} //Env map[string]string - Env Env - Exec map[string]string - Transaction map[string]string - Logs []Log - Gas string - Out string - Post map[string]Account - Pre map[string]Account + Env Env + Exec map[string]string + Transaction map[string]string + Logs []Log + Gas string + Out string + Post map[string]Account + Pre map[string]Account + PostStateRoot string } func RunVmTest(p string, t *testing.T) { + tests := make(map[string]VmTest) helper.CreateFileTests(t, p, &tests) for name, test := range tests { - helper.Logger.SetLogLevel(4) - if name != "TransactionNonceCheck2" { - continue - } + /* + vm.Debug = true + helper.Logger.SetLogLevel(4) + if name != "refund_CallToSuicideTwice" { + continue + } + */ db, _ := ethdb.NewMemDatabase() statedb := state.New(nil, db) for addr, account := range test.Pre { @@ -119,6 +123,7 @@ func RunVmTest(p string, t *testing.T) { } else { ret, logs, gas, err = helper.RunState(statedb, env, test.Transaction) } + statedb.Sync() rexp := helper.FromHex(test.Out) if bytes.Compare(rexp, ret) != 0 { @@ -158,14 +163,29 @@ func RunVmTest(p string, t *testing.T) { } } + if !isVmTest { + if !bytes.Equal(ethutil.Hex2Bytes(test.PostStateRoot), statedb.Root()) { + t.Errorf("%s's : Post state root error. Expected %s, got %x", name, test.PostStateRoot, statedb.Root()) + } + } + if len(test.Logs) > 0 { - for i, log := range test.Logs { - genBloom := ethutil.LeftPadBytes(types.LogsBloom(state.Logs{logs[i]}).Bytes(), 64) - if !bytes.Equal(genBloom, ethutil.Hex2Bytes(log.BloomF)) { - t.Errorf("bloom mismatch") - } + if len(test.Logs) != len(logs) { + t.Errorf("log length mismatch. Expected %d, got %d", len(test.Logs), len(logs)) + } else { + /* + fmt.Println("A", test.Logs) + fmt.Println("B", logs) + for i, log := range test.Logs { + genBloom := ethutil.LeftPadBytes(types.LogsBloom(state.Logs{logs[i]}).Bytes(), 256) + if !bytes.Equal(genBloom, ethutil.Hex2Bytes(log.BloomF)) { + t.Errorf("bloom mismatch") + } + } + */ } } + //statedb.Trie().PrintRoot() } logger.Flush() } @@ -176,11 +196,6 @@ func TestVMArithmetic(t *testing.T) { RunVmTest(fn, t) } -func TestSystemOperations(t *testing.T) { - const fn = "../files/VMTests/vmSystemOperationsTest.json" - RunVmTest(fn, t) -} - func TestBitwiseLogicOperation(t *testing.T) { const fn = "../files/VMTests/vmBitwiseLogicOperationTest.json" RunVmTest(fn, t) @@ -201,6 +216,17 @@ func TestFlowOperation(t *testing.T) { RunVmTest(fn, t) } +func TestLogTest(t *testing.T) { + const fn = "../files/VMTests/vmLogTest.json" + RunVmTest(fn, t) +} + +func TestPerformance(t *testing.T) { + t.Skip() + const fn = "../files/VMTests/vmPerformance.json" + RunVmTest(fn, t) +} + func TestPushDupSwap(t *testing.T) { const fn = "../files/VMTests/vmPushDupSwapTest.json" RunVmTest(fn, t) @@ -221,6 +247,11 @@ func TestVmLog(t *testing.T) { RunVmTest(fn, t) } +func TestStateExample(t *testing.T) { + const fn = "../files/StateTests/stExample.json" + RunVmTest(fn, t) +} + func TestStateSystemOperations(t *testing.T) { const fn = "../files/StateTests/stSystemOperationsTest.json" RunVmTest(fn, t) |