Commit 49437a02 authored by gary rong's avatar gary rong Committed by Felix Lange

core/state: make TestSnapshotRandom work again (#3816)

In `touch` operation, only `touched` filed has been changed. Therefore
in the related undo function, only `touched` field should be reverted.
In addition, whether remove this obj from dirty map should depend on
prevDirty flag.
parent b319f027
...@@ -73,6 +73,7 @@ type ( ...@@ -73,6 +73,7 @@ type (
touchChange struct { touchChange struct {
account *common.Address account *common.Address
prev bool prev bool
prevDirty bool
} }
) )
...@@ -97,8 +98,10 @@ var ripemd = common.HexToAddress("0000000000000000000000000000000000000003") ...@@ -97,8 +98,10 @@ var ripemd = common.HexToAddress("0000000000000000000000000000000000000003")
func (ch touchChange) undo(s *StateDB) { func (ch touchChange) undo(s *StateDB) {
if !ch.prev && *ch.account != ripemd { if !ch.prev && *ch.account != ripemd {
delete(s.stateObjects, *ch.account) s.getStateObject(*ch.account).touched = ch.prev
delete(s.stateObjectsDirty, *ch.account) if !ch.prevDirty {
delete(s.stateObjectsDirty, *ch.account)
}
} }
} }
......
...@@ -137,8 +137,9 @@ func (self *stateObject) markSuicided() { ...@@ -137,8 +137,9 @@ func (self *stateObject) markSuicided() {
func (c *stateObject) touch() { func (c *stateObject) touch() {
c.db.journal = append(c.db.journal, touchChange{ c.db.journal = append(c.db.journal, touchChange{
account: &c.address, account: &c.address,
prev: c.touched, prev: c.touched,
prevDirty: c.onDirty == nil,
}) })
if c.onDirty != nil { if c.onDirty != nil {
c.onDirty(c.Address()) c.onDirty(c.Address())
......
...@@ -116,7 +116,6 @@ func TestIntermediateLeaks(t *testing.T) { ...@@ -116,7 +116,6 @@ func TestIntermediateLeaks(t *testing.T) {
} }
func TestSnapshotRandom(t *testing.T) { func TestSnapshotRandom(t *testing.T) {
t.Skip("@fjl fix me please")
config := &quick.Config{MaxCount: 1000} config := &quick.Config{MaxCount: 1000}
err := quick.Check((*snapshotTest).run, config) err := quick.Check((*snapshotTest).run, config)
if cerr, ok := err.(*quick.CheckError); ok { if cerr, ok := err.(*quick.CheckError); ok {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment