From 75cd9cd2de315f8680ff6a382e9b3bd48e17ecad Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 12 Jan 2015 14:40:40 +0100 Subject: updated tests --- core/execution.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'core/execution.go') diff --git a/core/execution.go b/core/execution.go index 43f4b58fb..1057089f1 100644 --- a/core/execution.go +++ b/core/execution.go @@ -13,7 +13,6 @@ type Execution struct { env vm.Environment address, input []byte Gas, price, value *big.Int - SkipTransfer bool } func NewExecution(env vm.Environment, address, input []byte, gas, gasPrice, value *big.Int) *Execution { @@ -43,14 +42,12 @@ func (self *Execution) exec(code, contextAddr []byte, caller vm.ContextRef) (ret from, to := env.State().GetStateObject(caller.Address()), env.State().GetOrNewStateObject(self.address) // Skipping transfer is used on testing for the initial call - if !self.SkipTransfer { - err = env.Transfer(from, to, self.value) - if err != nil { - caller.ReturnGas(self.Gas, self.price) - - err = fmt.Errorf("Insufficient funds to transfer value. Req %v, has %v", self.value, from.Balance) - return - } + err = env.Transfer(from, to, self.value) + if err != nil { + caller.ReturnGas(self.Gas, self.price) + + err = fmt.Errorf("insufficient funds to transfer value. Req %v, has %v", self.value, from.Balance()) + return } snapshot := env.State().Copy() -- cgit v1.2.3 From bb55307a9d8fa73b0fbc0727f8b80925a87627b7 Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 13 Jan 2015 20:31:31 +0100 Subject: Updated tests --- core/execution.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'core/execution.go') diff --git a/core/execution.go b/core/execution.go index 1057089f1..756a3ed03 100644 --- a/core/execution.go +++ b/core/execution.go @@ -5,6 +5,7 @@ import ( "math/big" "time" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/vm" ) @@ -40,14 +41,22 @@ func (self *Execution) exec(code, contextAddr []byte, caller vm.ContextRef) (ret return nil, vm.DepthError{} } + vsnapshot := env.State().Copy() + if len(self.address) == 0 { + // Generate a new address + nonce := env.State().GetNonce(caller.Address()) + self.address = crypto.CreateAddress(caller.Address(), nonce) + env.State().SetNonce(caller.Address(), nonce+1) + } + from, to := env.State().GetStateObject(caller.Address()), env.State().GetOrNewStateObject(self.address) - // Skipping transfer is used on testing for the initial call err = env.Transfer(from, to, self.value) if err != nil { + env.State().Set(vsnapshot) + caller.ReturnGas(self.Gas, self.price) - err = fmt.Errorf("insufficient funds to transfer value. Req %v, has %v", self.value, from.Balance()) - return + return nil, fmt.Errorf("insufficient funds to transfer value. Req %v, has %v", self.value, from.Balance()) } snapshot := env.State().Copy() -- cgit v1.2.3 From b03614527bea8fee378b406e50071948e6d02f93 Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 19 Jan 2015 11:20:55 +0100 Subject: VmDebug => StdVm --- core/execution.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/execution.go') diff --git a/core/execution.go b/core/execution.go index 756a3ed03..f1e6f83f5 100644 --- a/core/execution.go +++ b/core/execution.go @@ -33,7 +33,7 @@ func (self *Execution) Call(codeAddr []byte, caller vm.ContextRef) ([]byte, erro func (self *Execution) exec(code, contextAddr []byte, caller vm.ContextRef) (ret []byte, err error) { env := self.env - evm := vm.New(env, vm.DebugVmTy) + evm := vm.New(env, vm.StdVmTy) if env.Depth() == vm.MaxCallDepth { caller.ReturnGas(self.Gas, self.price) -- cgit v1.2.3 From 9845029a7535672746139084138f3e894e604e44 Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 20 Jan 2015 15:49:12 +0100 Subject: StdVm by default --- core/execution.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/execution.go') diff --git a/core/execution.go b/core/execution.go index f1e6f83f5..cad4e84aa 100644 --- a/core/execution.go +++ b/core/execution.go @@ -33,7 +33,7 @@ func (self *Execution) Call(codeAddr []byte, caller vm.ContextRef) ([]byte, erro func (self *Execution) exec(code, contextAddr []byte, caller vm.ContextRef) (ret []byte, err error) { env := self.env - evm := vm.New(env, vm.StdVmTy) + evm := vm.New(env) if env.Depth() == vm.MaxCallDepth { caller.ReturnGas(self.Gas, self.price) -- cgit v1.2.3