From 29b8a0bc5ffa7a674a06a211e1c8bdd1b6ed07b1 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 23 Oct 2014 01:01:26 +0200 Subject: Updated the VM & VM tests * Stack Error shouldn't revert to previous state * Updated VM Test tool * Added Transfer method to VM Env --- ethchain/state_transition.go | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'ethchain/state_transition.go') diff --git a/ethchain/state_transition.go b/ethchain/state_transition.go index 79321eaac..1e6834729 100644 --- a/ethchain/state_transition.go +++ b/ethchain/state_transition.go @@ -89,8 +89,8 @@ func (self *StateTransition) BuyGas() error { var err error sender := self.Sender() - if sender.Balance.Cmp(self.tx.GasValue()) < 0 { - return fmt.Errorf("Insufficient funds to pre-pay gas. Req %v, has %v", self.tx.GasValue(), sender.Balance) + if sender.Balance().Cmp(self.tx.GasValue()) < 0 { + return fmt.Errorf("Insufficient funds to pre-pay gas. Req %v, has %v", self.tx.GasValue(), sender.Balance()) } coinbase := self.Coinbase() @@ -171,7 +171,7 @@ func (self *StateTransition) TransitionState() (err error) { return } - if sender.Balance.Cmp(self.value) < 0 { + if sender.Balance().Cmp(self.value) < 0 { return fmt.Errorf("Insufficient funds to transfer value. Req %v, has %v", self.value, sender.Balance) } @@ -243,19 +243,6 @@ func (self *StateTransition) TransitionState() (err error) { return } -func (self *StateTransition) transferValue(sender, receiver *ethstate.StateObject) error { - if sender.Balance.Cmp(self.value) < 0 { - return fmt.Errorf("Insufficient funds to transfer value. Req %v, has %v", self.value, sender.Balance) - } - - // Subtract the amount from the senders account - sender.SubAmount(self.value) - // Add the amount to receivers account which should conclude this transaction - receiver.AddAmount(self.value) - - return nil -} - func (self *StateTransition) Eval(msg *ethstate.Message, script []byte, context *ethstate.StateObject) (ret []byte, err error) { var ( transactor = self.Sender() @@ -265,9 +252,9 @@ func (self *StateTransition) Eval(msg *ethstate.Message, script []byte, context ) //vm := vm.New(env, vm.Type(ethutil.Config.VmType)) - vm := vm.New(env, vm.DebugVmTy) + evm := vm.New(env, vm.DebugVmTy) - ret, _, err = callerClosure.Call(vm, self.tx.Data) + ret, _, err = callerClosure.Call(evm, self.tx.Data) return } -- cgit