diff options
author | obscuren <geffobscura@gmail.com> | 2014-07-22 17:54:48 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-07-22 17:54:48 +0800 |
commit | 1e8b54abfb7129fcdf4812ad01b6a7cd61e4f65d (patch) | |
tree | 6ad93d5117d8194ee700e3347b59d0602cd4c40c /ethvm/vm_test.go | |
parent | 20ee1ae65e57ef7d60404277162c84c572c6bb10 (diff) | |
download | dexon-1e8b54abfb7129fcdf4812ad01b6a7cd61e4f65d.tar dexon-1e8b54abfb7129fcdf4812ad01b6a7cd61e4f65d.tar.gz dexon-1e8b54abfb7129fcdf4812ad01b6a7cd61e4f65d.tar.bz2 dexon-1e8b54abfb7129fcdf4812ad01b6a7cd61e4f65d.tar.lz dexon-1e8b54abfb7129fcdf4812ad01b6a7cd61e4f65d.tar.xz dexon-1e8b54abfb7129fcdf4812ad01b6a7cd61e4f65d.tar.zst dexon-1e8b54abfb7129fcdf4812ad01b6a7cd61e4f65d.zip |
Refactored state, state object and vm
* The State and StateObject have been moved to their own package
* The VM is moved to it's own package
Diffstat (limited to 'ethvm/vm_test.go')
-rw-r--r-- | ethvm/vm_test.go | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/ethvm/vm_test.go b/ethvm/vm_test.go new file mode 100644 index 000000000..f0bdc8e2c --- /dev/null +++ b/ethvm/vm_test.go @@ -0,0 +1,48 @@ +package ethvm + +import ( + "fmt" + "github.com/ethereum/eth-go/ethdb" + "github.com/ethereum/eth-go/ethlog" + "github.com/ethereum/eth-go/ethstate" + "github.com/ethereum/eth-go/ethutil" + "log" + "math/big" + "os" + "testing" +) + +type TestEnv struct { +} + +func (self TestEnv) GetObject() Object { return nil } +func (self TestEnv) Origin() []byte { return nil } +func (self TestEnv) BlockNumber() *big.Int { return nil } +func (self TestEnv) PrevHash() []byte { return nil } +func (self TestEnv) Coinbase() []byte { return nil } +func (self TestEnv) Time() int64 { return 0 } +func (self TestEnv) Difficulty() *big.Int { return nil } +func (self TestEnv) Data() []string { return nil } +func (self TestEnv) Value() *big.Int { return nil } +func (self TestEnv) GetBalance(addr []byte) *big.Int { return nil } +func (self TestEnv) State() *ethstate.State { return nil } + +func TestVm(t *testing.T) { + ethlog.AddLogSystem(ethlog.NewStdLogSystem(os.Stdout, log.LstdFlags, ethlog.LogLevel(4))) + + db, _ := ethdb.NewMemDatabase() + ethutil.ReadConfig(".ethtest", "/tmp/ethtest", "") + ethutil.Config.Db = db + + stateObject := ethstate.NewStateObject([]byte{'j', 'e', 'f', 'f'}) + callerClosure := NewClosure(stateObject, stateObject, []byte{0x60, 0x01}, big.NewInt(1000000), big.NewInt(0)) + + vm := New(TestEnv{}) + vm.Verbose = true + + ret, _, e := callerClosure.Call(vm, nil) + if e != nil { + fmt.Println("error", e) + } + fmt.Println(ret) +} |