diff options
Diffstat (limited to 'tests/vm')
-rw-r--r-- | tests/vm/gh_test.go | 65 |
1 files changed, 46 insertions, 19 deletions
diff --git a/tests/vm/gh_test.go b/tests/vm/gh_test.go index c62f6a4bb..cf4b018f7 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,14 +63,15 @@ 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) { @@ -115,6 +115,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 +155,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 +188,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 +208,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 +239,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) |