aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-10-14 18:21:46 +0800
committerobscuren <geffobscura@gmail.com>2014-10-14 18:21:46 +0800
commit393a92811bd810e33cf1e0b281f9fefa09643cd2 (patch)
tree018fd610d3ac6b9ee9d3024dab3e331199b28aaf
parentc5bd32b0ad1a3d0fd20a3d1014cc8a97d889dc28 (diff)
downloadgo-tangerine-393a92811bd810e33cf1e0b281f9fefa09643cd2.tar.gz
go-tangerine-393a92811bd810e33cf1e0b281f9fefa09643cd2.tar.zst
go-tangerine-393a92811bd810e33cf1e0b281f9fefa09643cd2.zip
Changed VM Test code
-rw-r--r--ethvm/vm_test.go26
1 files changed, 16 insertions, 10 deletions
diff --git a/ethvm/vm_test.go b/ethvm/vm_test.go
index 40fb985a6..4f30ab39b 100644
--- a/ethvm/vm_test.go
+++ b/ethvm/vm_test.go
@@ -25,21 +25,27 @@ func (self TestEnv) Difficulty() *big.Int { return nil }
func (self TestEnv) Value() *big.Int { return nil }
func (self TestEnv) State() *ethstate.State { return nil }
+const mutcode = `
+var x = 0;
+for i := 0; i < 10; i++ {
+ x = i
+}
+
+return x`
+
func setup(level int, typ Type) (*Closure, VirtualMachine) {
+ code, err := ethutil.Compile(mutcode, true)
+ if err != nil {
+ log.Fatal(err)
+ }
+
// Pipe output to /dev/null
ethlog.AddLogSystem(ethlog.NewStdLogSystem(ioutil.Discard, log.LstdFlags, ethlog.LogLevel(level)))
ethutil.ReadConfig(".ethtest", "/tmp/ethtest", "")
stateObject := ethstate.NewStateObject([]byte{'j', 'e', 'f', 'f'})
- callerClosure := NewClosure(nil, stateObject, stateObject, []byte{
- PUSH1, 1,
- PUSH1, 0,
- MSTORE,
- PUSH1, 32,
- PUSH1, 0,
- RETURN,
- }, big.NewInt(1000000), big.NewInt(0))
+ callerClosure := NewClosure(nil, stateObject, stateObject, code, big.NewInt(1000000), big.NewInt(0))
return callerClosure, New(TestEnv{}, typ)
}
@@ -51,7 +57,7 @@ func TestDebugVm(t *testing.T) {
fmt.Println("error", e)
}
- if ret[len(ret)-1] != 1 {
+ if ret[len(ret)-1] != 9 {
t.Errorf("Expected VM to return 1, got", ret, "instead.")
}
}
@@ -63,7 +69,7 @@ func TestVm(t *testing.T) {
fmt.Println("error", e)
}
- if ret[len(ret)-1] != 1 {
+ if ret[len(ret)-1] != 9 {
t.Errorf("Expected VM to return 1, got", ret, "instead.")
}
}