diff options
author | obscuren <geffobscura@gmail.com> | 2015-03-10 08:22:38 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-03-10 08:22:38 +0800 |
commit | 0db4a0e898d09ffa7b6b1289e9a334edc0001cfa (patch) | |
tree | a0b5c8381ab482550ef4800a06d4db086d76a983 /tests/vm | |
parent | 94e543bc398efbb5c712b6e4cb48d8a57eb3400d (diff) | |
parent | 0d64163fea3a266ceb71cb4c4ee5682052c9ca6c (diff) | |
download | dexon-0db4a0e898d09ffa7b6b1289e9a334edc0001cfa.tar dexon-0db4a0e898d09ffa7b6b1289e9a334edc0001cfa.tar.gz dexon-0db4a0e898d09ffa7b6b1289e9a334edc0001cfa.tar.bz2 dexon-0db4a0e898d09ffa7b6b1289e9a334edc0001cfa.tar.lz dexon-0db4a0e898d09ffa7b6b1289e9a334edc0001cfa.tar.xz dexon-0db4a0e898d09ffa7b6b1289e9a334edc0001cfa.tar.zst dexon-0db4a0e898d09ffa7b6b1289e9a334edc0001cfa.zip |
Merge branch 'poc-9' into develop
Diffstat (limited to 'tests/vm')
-rw-r--r-- | tests/vm/gh_test.go | 66 |
1 files changed, 47 insertions, 19 deletions
diff --git a/tests/vm/gh_test.go b/tests/vm/gh_test.go index c62f6a4bb..959f20463 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,17 +63,19 @@ 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) @@ -115,6 +116,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 { @@ -154,14 +156,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() } @@ -172,11 +189,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) @@ -197,6 +209,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) @@ -217,6 +240,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) |