From 16460b0048b738b0474bc1556d0df469f64bcf26 Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 30 Dec 2014 17:16:28 +0100 Subject: Fixed gas check for vm test --- tests/vm/gh_test.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'tests/vm') diff --git a/tests/vm/gh_test.go b/tests/vm/gh_test.go index 1efda7fe0..e06b0ed82 100644 --- a/tests/vm/gh_test.go +++ b/tests/vm/gh_test.go @@ -107,7 +107,9 @@ func RunVmTest(p string, t *testing.T) { logs state.Logs ) - if len(test.Exec) > 0 { + isVmTest := len(test.Exec) > 0 + + if isVmTest { ret, logs, gas, err = helper.RunVm(statedb, env, test.Exec) } else { ret, logs, gas, err = helper.RunState(statedb, env, test.Transaction) @@ -124,10 +126,14 @@ func RunVmTest(p string, t *testing.T) { t.Errorf("%s's return failed. Expected %x, got %x\n", name, rexp, ret) } - if len(test.Gas) > 0 { - gexp := ethutil.Big(test.Gas) - if gexp.Cmp(gas) != 0 { - t.Errorf("%s's gas failed. Expected %v, got %v\n", name, gexp, gas) + if isVmTest { + if len(test.Gas) == 0 && err == nil { + t.Errorf("%s's gas unspecified, indicating an error. VM returned (incorrectly) successfull") + } else { + gexp := ethutil.Big(test.Gas) + if gexp.Cmp(gas) != 0 { + t.Errorf("%s's gas failed. Expected %v, got %v\n", name, gexp, gas) + } } } -- cgit v1.2.3 From a4dc12f12c7a06f5e28d5b1e760249875ef7a8c5 Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 31 Dec 2014 11:21:39 +0100 Subject: Additional comments and added name to error output --- tests/vm/gh_test.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'tests/vm') diff --git a/tests/vm/gh_test.go b/tests/vm/gh_test.go index e06b0ed82..f1e4d1acc 100644 --- a/tests/vm/gh_test.go +++ b/tests/vm/gh_test.go @@ -108,17 +108,16 @@ func RunVmTest(p string, t *testing.T) { ) isVmTest := len(test.Exec) > 0 - if isVmTest { ret, logs, gas, err = helper.RunVm(statedb, env, test.Exec) } else { ret, logs, gas, err = helper.RunState(statedb, env, test.Transaction) } - // When an error is returned it doesn't always mean the tests fails. - // Have to come up with some conditional failing mechanism. + // Log the error if there is one. Error does not mean failing test. + // A test fails if err != nil and post params are specified in the test. if err != nil { - helper.Log.Infoln(err) + helper.Log.Infof("%s's: %v\n", name, err) } rexp := helper.FromHex(test.Out) @@ -160,7 +159,6 @@ func RunVmTest(p string, t *testing.T) { } if len(test.Logs) > 0 { - // Logs within the test itself aren't correct, missing empty fields (32 0s) 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)) { -- cgit v1.2.3 From 55e55826ee3b763be8805dcdef0468a179619ba1 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 2 Jan 2015 17:35:55 +0100 Subject: Changed JUMP(I) behaviour. * All jumps must land on a JUMPDEST instruction byte. * The byte may not be part of a PUSH* --- tests/vm/gh_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tests/vm') diff --git a/tests/vm/gh_test.go b/tests/vm/gh_test.go index f1e4d1acc..698b0aefc 100644 --- a/tests/vm/gh_test.go +++ b/tests/vm/gh_test.go @@ -78,6 +78,12 @@ func RunVmTest(p string, t *testing.T) { helper.CreateFileTests(t, p, &tests) for name, test := range tests { + /* + helper.Logger.SetLogLevel(5) + if name != "jump0_jumpdest2" { + continue + } + */ statedb := state.New(helper.NewTrie()) for addr, account := range test.Pre { obj := StateObjectFromAccount(addr, account) @@ -127,7 +133,7 @@ func RunVmTest(p string, t *testing.T) { if isVmTest { if len(test.Gas) == 0 && err == nil { - t.Errorf("%s's gas unspecified, indicating an error. VM returned (incorrectly) successfull") + t.Errorf("%s's gas unspecified, indicating an error. VM returned (incorrectly) successfull", name) } else { gexp := ethutil.Big(test.Gas) if gexp.Cmp(gas) != 0 { -- cgit v1.2.3 From fed3e6a808921fb8274b50043c5c39a24a1bbccf Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 7 Jan 2015 13:17:48 +0100 Subject: Refactored ethutil.Config.Db out --- tests/vm/gh_test.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'tests/vm') diff --git a/tests/vm/gh_test.go b/tests/vm/gh_test.go index 698b0aefc..2aece215e 100644 --- a/tests/vm/gh_test.go +++ b/tests/vm/gh_test.go @@ -7,6 +7,7 @@ import ( "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" "github.com/ethereum/go-ethereum/state" @@ -38,8 +39,8 @@ func (self Log) Topics() [][]byte { return t } -func StateObjectFromAccount(addr string, account Account) *state.StateObject { - obj := state.NewStateObject(ethutil.Hex2Bytes(addr)) +func StateObjectFromAccount(db ethutil.Database, addr string, account Account) *state.StateObject { + obj := state.NewStateObject(ethutil.Hex2Bytes(addr), db) obj.SetBalance(ethutil.Big(account.Balance)) if ethutil.IsHex(account.Code) { @@ -84,9 +85,10 @@ func RunVmTest(p string, t *testing.T) { continue } */ - statedb := state.New(helper.NewTrie()) + db, _ := ethdb.NewMemDatabase() + statedb := state.New(nil, db) for addr, account := range test.Pre { - obj := StateObjectFromAccount(addr, account) + obj := StateObjectFromAccount(db, addr, account) statedb.SetStateObject(obj) for a, v := range account.Storage { obj.SetState(helper.FromHex(a), ethutil.NewValue(helper.FromHex(v))) -- cgit v1.2.3 From 491c23a728e4f5cdedfa040aded6a6b136f6bee0 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 9 Jan 2015 22:42:36 +0100 Subject: Moved the TD method from block processor. --- tests/vm/gh_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/vm') diff --git a/tests/vm/gh_test.go b/tests/vm/gh_test.go index 2aece215e..47b588268 100644 --- a/tests/vm/gh_test.go +++ b/tests/vm/gh_test.go @@ -81,7 +81,7 @@ func RunVmTest(p string, t *testing.T) { for name, test := range tests { /* helper.Logger.SetLogLevel(5) - if name != "jump0_jumpdest2" { + if name != "createNameRegistratorZeroMem" { continue } */ -- cgit v1.2.3 From 750d70c2024784227c8ac920d651c337c2de207e Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 13 Jan 2015 00:25:45 +0100 Subject: updated tests --- tests/vm/gh_test.go | 6 ------ 1 file changed, 6 deletions(-) (limited to 'tests/vm') diff --git a/tests/vm/gh_test.go b/tests/vm/gh_test.go index 47b588268..699225e90 100644 --- a/tests/vm/gh_test.go +++ b/tests/vm/gh_test.go @@ -79,12 +79,6 @@ func RunVmTest(p string, t *testing.T) { helper.CreateFileTests(t, p, &tests) for name, test := range tests { - /* - helper.Logger.SetLogLevel(5) - if name != "createNameRegistratorZeroMem" { - continue - } - */ db, _ := ethdb.NewMemDatabase() statedb := state.New(nil, db) for addr, account := range test.Pre { -- cgit v1.2.3 From 4704a0a288af89795e251db98eb253de117ff031 Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 13 Jan 2015 10:30:52 +0100 Subject: remove pre compiled for tests --- tests/vm/gh_test.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'tests/vm') diff --git a/tests/vm/gh_test.go b/tests/vm/gh_test.go index 699225e90..7b41411de 100644 --- a/tests/vm/gh_test.go +++ b/tests/vm/gh_test.go @@ -79,6 +79,7 @@ func RunVmTest(p string, t *testing.T) { helper.CreateFileTests(t, p, &tests) for name, test := range tests { + //helper.Log.Infoln("Running", name) db, _ := ethdb.NewMemDatabase() statedb := state.New(nil, db) for addr, account := range test.Pre { @@ -116,12 +117,6 @@ func RunVmTest(p string, t *testing.T) { ret, logs, gas, err = helper.RunState(statedb, env, test.Transaction) } - // Log the error if there is one. Error does not mean failing test. - // A test fails if err != nil and post params are specified in the test. - if err != nil { - helper.Log.Infof("%s's: %v\n", name, err) - } - rexp := helper.FromHex(test.Out) if bytes.Compare(rexp, ret) != 0 { t.Errorf("%s's return failed. Expected %x, got %x\n", name, rexp, ret) @@ -129,10 +124,14 @@ func RunVmTest(p string, t *testing.T) { if isVmTest { if len(test.Gas) == 0 && err == nil { + // Log VM err + helper.Log.Infof("%s's: %v\n", name, err) t.Errorf("%s's gas unspecified, indicating an error. VM returned (incorrectly) successfull", name) } else { gexp := ethutil.Big(test.Gas) if gexp.Cmp(gas) != 0 { + // Log VM err + helper.Log.Infof("%s's: %v\n", name, err) t.Errorf("%s's gas failed. Expected %v, got %v\n", name, gexp, gas) } } -- cgit v1.2.3 From 82beaabf6a8b5a146a38e1d6a31a78157c79a0cf Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 13 Jan 2015 14:57:51 +0100 Subject: Fixed consensus issue --- tests/vm/gh_test.go | 1 - 1 file changed, 1 deletion(-) (limited to 'tests/vm') diff --git a/tests/vm/gh_test.go b/tests/vm/gh_test.go index 7b41411de..e1fdcd658 100644 --- a/tests/vm/gh_test.go +++ b/tests/vm/gh_test.go @@ -79,7 +79,6 @@ func RunVmTest(p string, t *testing.T) { helper.CreateFileTests(t, p, &tests) for name, test := range tests { - //helper.Log.Infoln("Running", name) db, _ := ethdb.NewMemDatabase() statedb := state.New(nil, db) for addr, account := range test.Pre { -- cgit v1.2.3 From d5f38f5690caeb30794e62d4a1b2683a6107cfbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 22 Jan 2015 18:00:15 +0100 Subject: JitVM: the EVM JIT bridge --- tests/vm/gh_test.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'tests/vm') diff --git a/tests/vm/gh_test.go b/tests/vm/gh_test.go index e1fdcd658..41ebba957 100644 --- a/tests/vm/gh_test.go +++ b/tests/vm/gh_test.go @@ -172,47 +172,47 @@ func RunVmTest(p string, t *testing.T) { // I've created a new function for each tests so it's easier to identify where the problem lies if any of them fail. func TestVMArithmetic(t *testing.T) { - const fn = "../files/vmtests/vmArithmeticTest.json" + const fn = "../files/VMTests/vmArithmeticTest.json" RunVmTest(fn, t) } func TestBitwiseLogicOperation(t *testing.T) { - const fn = "../files/vmtests/vmBitwiseLogicOperationTest.json" + const fn = "../files/VMTests/vmBitwiseLogicOperationTest.json" RunVmTest(fn, t) } func TestBlockInfo(t *testing.T) { - const fn = "../files/vmtests/vmBlockInfoTest.json" + const fn = "../files/VMTests/vmBlockInfoTest.json" RunVmTest(fn, t) } func TestEnvironmentalInfo(t *testing.T) { - const fn = "../files/vmtests/vmEnvironmentalInfoTest.json" + const fn = "../files/VMTests/vmEnvironmentalInfoTest.json" RunVmTest(fn, t) } func TestFlowOperation(t *testing.T) { - const fn = "../files/vmtests/vmIOandFlowOperationsTest.json" + const fn = "../files/VMTests/vmIOandFlowOperationsTest.json" RunVmTest(fn, t) } func TestPushDupSwap(t *testing.T) { - const fn = "../files/vmtests/vmPushDupSwapTest.json" + const fn = "../files/VMTests/vmPushDupSwapTest.json" RunVmTest(fn, t) } func TestVMSha3(t *testing.T) { - const fn = "../files/vmtests/vmSha3Test.json" + const fn = "../files/VMTests/vmSha3Test.json" RunVmTest(fn, t) } func TestVm(t *testing.T) { - const fn = "../files/vmtests/vmtests.json" + const fn = "../files/VMTests/vmtests.json" RunVmTest(fn, t) } func TestVmLog(t *testing.T) { - const fn = "../files/vmtests/vmLogTest.json" + const fn = "../files/VMTests/vmLogTest.json" RunVmTest(fn, t) } -- cgit v1.2.3 From 6fecb150d6f2bb36d3f1b7b9095cac428df2ce5a Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 2 Feb 2015 19:55:38 -0800 Subject: Updated tests --- tests/vm/gh_test.go | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'tests/vm') diff --git a/tests/vm/gh_test.go b/tests/vm/gh_test.go index 41ebba957..d9b1ded7a 100644 --- a/tests/vm/gh_test.go +++ b/tests/vm/gh_test.go @@ -79,6 +79,10 @@ func RunVmTest(p string, t *testing.T) { helper.CreateFileTests(t, p, &tests) for name, test := range tests { + helper.Logger.SetLogLevel(4) + if name != "TransactionNonceCheck2" { + continue + } db, _ := ethdb.NewMemDatabase() statedb := state.New(nil, db) for addr, account := range test.Pre { @@ -123,14 +127,10 @@ func RunVmTest(p string, t *testing.T) { if isVmTest { if len(test.Gas) == 0 && err == nil { - // Log VM err - helper.Log.Infof("%s's: %v\n", name, err) t.Errorf("%s's gas unspecified, indicating an error. VM returned (incorrectly) successfull", name) } else { gexp := ethutil.Big(test.Gas) if gexp.Cmp(gas) != 0 { - // Log VM err - helper.Log.Infof("%s's: %v\n", name, err) t.Errorf("%s's gas failed. Expected %v, got %v\n", name, gexp, gas) } } @@ -176,6 +176,11 @@ 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) @@ -240,3 +245,23 @@ func TestStateRefund(t *testing.T) { const fn = "../files/StateTests/stRefundTest.json" RunVmTest(fn, t) } + +func TestStateBlockHash(t *testing.T) { + const fn = "../files/StateTests/stBlockHashTest.json" + RunVmTest(fn, t) +} + +func TestStateInitCode(t *testing.T) { + const fn = "../files/StateTests/stInitCodeTest.json" + RunVmTest(fn, t) +} + +func TestStateLog(t *testing.T) { + const fn = "../files/StateTests/stLogTests.json" + RunVmTest(fn, t) +} + +func TestStateTransaction(t *testing.T) { + const fn = "../files/StateTests/stTransactionTest.json" + RunVmTest(fn, t) +} -- cgit v1.2.3 From 95cfaa1b37c417de45cc754b0ade9746f15f0805 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 13 Feb 2015 23:26:41 +0100 Subject: disabled test --- tests/vm/gh_test.go | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/vm') diff --git a/tests/vm/gh_test.go b/tests/vm/gh_test.go index d9b1ded7a..17f945910 100644 --- a/tests/vm/gh_test.go +++ b/tests/vm/gh_test.go @@ -262,6 +262,7 @@ func TestStateLog(t *testing.T) { } func TestStateTransaction(t *testing.T) { + t.Skip() const fn = "../files/StateTests/stTransactionTest.json" RunVmTest(fn, t) } -- cgit v1.2.3 From b3b6210886abd0962f97add91c081ac732639102 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 20 Feb 2015 11:38:52 +0100 Subject: tests/vm: add non-test Go file This removes the annoying warning printed by "go install ./...". --- tests/vm/nowarn.go | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/vm/nowarn.go (limited to 'tests/vm') diff --git a/tests/vm/nowarn.go b/tests/vm/nowarn.go new file mode 100644 index 000000000..2a45a6cc6 --- /dev/null +++ b/tests/vm/nowarn.go @@ -0,0 +1,3 @@ +// This silences the warning given by 'go install ./...'. + +package vm -- cgit v1.2.3 From ea9a549bbdc8377bca73f1417f2dc4a18396a382 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 20 Feb 2015 14:19:34 +0100 Subject: Removed exported fields from state object and added proper set/getters --- tests/vm/gh_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/vm') diff --git a/tests/vm/gh_test.go b/tests/vm/gh_test.go index 17f945910..2151cf9a5 100644 --- a/tests/vm/gh_test.go +++ b/tests/vm/gh_test.go @@ -46,8 +46,8 @@ func StateObjectFromAccount(db ethutil.Database, addr string, account Account) * if ethutil.IsHex(account.Code) { account.Code = account.Code[2:] } - obj.Code = ethutil.Hex2Bytes(account.Code) - obj.Nonce = ethutil.Big(account.Nonce).Uint64() + obj.SetCode(ethutil.Hex2Bytes(account.Code)) + obj.SetNonce(ethutil.Big(account.Nonce).Uint64()) return obj } -- cgit v1.2.3