mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-23 12:07:17 +00:00
Updated tests and fixed suicide
This commit is contained in:
parent
93cdffca3a
commit
19efebe91e
@ -111,7 +111,7 @@ func NewStateObjectFromBytes(address, data []byte, db ethutil.Database) *StateOb
|
||||
func (self *StateObject) MarkForDeletion() {
|
||||
self.remove = true
|
||||
self.dirty = true
|
||||
statelogger.DebugDetailf("%x: #%d %v (deletion)\n", self.Address(), self.nonce, self.balance)
|
||||
statelogger.Debugf("%x: #%d %v X\n", self.Address(), self.nonce, self.balance)
|
||||
}
|
||||
|
||||
func (c *StateObject) getAddr(addr []byte) *ethutil.Value {
|
||||
|
@ -121,6 +121,7 @@ func (self *StateDB) Delete(addr []byte) bool {
|
||||
stateObject := self.GetOrNewStateObject(addr)
|
||||
if stateObject != nil {
|
||||
stateObject.MarkForDeletion()
|
||||
stateObject.balance = new(big.Int)
|
||||
|
||||
return true
|
||||
}
|
||||
@ -128,6 +129,14 @@ func (self *StateDB) Delete(addr []byte) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *StateDB) IsDeleted(addr []byte) bool {
|
||||
stateObject := self.GetStateObject(addr)
|
||||
if stateObject != nil {
|
||||
return stateObject.remove
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
//
|
||||
// Setting, updating & deleting state object methods
|
||||
//
|
||||
|
@ -75,10 +75,18 @@ type VmTest struct {
|
||||
}
|
||||
|
||||
func RunVmTest(p string, t *testing.T) {
|
||||
|
||||
tests := make(map[string]VmTest)
|
||||
helper.CreateFileTests(t, p, &tests)
|
||||
|
||||
for name, test := range tests {
|
||||
/*
|
||||
vm.Debug = true
|
||||
helper.Logger.SetLogLevel(4)
|
||||
if name != "refund_CallToSuicideTwice" {
|
||||
continue
|
||||
}
|
||||
*/
|
||||
db, _ := ethdb.NewMemDatabase()
|
||||
statedb := state.New(nil, db)
|
||||
for addr, account := range test.Pre {
|
||||
|
5
vm/vm.go
5
vm/vm.go
@ -736,6 +736,7 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
|
||||
self.Printf(" => (%x) %v", receiver.Address()[:4], balance)
|
||||
|
||||
receiver.AddBalance(balance)
|
||||
|
||||
statedb.Delete(context.Address())
|
||||
|
||||
fallthrough
|
||||
@ -905,6 +906,10 @@ func (self *Vm) calculateGasAndSize(context *Context, caller ContextRef, op OpCo
|
||||
g = GasStorageMod
|
||||
}
|
||||
gas.Set(g)
|
||||
case SUICIDE:
|
||||
if !statedb.IsDeleted(context.Address()) {
|
||||
statedb.Refund(self.env.Origin(), RefundSuicide)
|
||||
}
|
||||
case MLOAD:
|
||||
newMemSize = calcMemSize(stack.Peek(), u256(32))
|
||||
case MSTORE8:
|
||||
|
Loading…
Reference in New Issue
Block a user