|
|
|
@ -422,3 +422,19 @@ func (s *StateSuite) TestTouchDelete(c *check.C) { |
|
|
|
|
c.Fatal("expected no dirty state object") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TestCopyOfCopy tests that modified objects are carried over to the copy, and the copy of the copy.
|
|
|
|
|
// See https://github.com/ethereum/go-ethereum/pull/15225#issuecomment-380191512
|
|
|
|
|
func TestCopyOfCopy(t *testing.T) { |
|
|
|
|
db, _ := ethdb.NewMemDatabase() |
|
|
|
|
sdb, _ := New(common.Hash{}, NewDatabase(db)) |
|
|
|
|
addr := common.HexToAddress("aaaa") |
|
|
|
|
sdb.SetBalance(addr, big.NewInt(42)) |
|
|
|
|
|
|
|
|
|
if got := sdb.Copy().GetBalance(addr).Uint64(); got != 42 { |
|
|
|
|
t.Fatalf("1st copy fail, expected 42, got %v", got) |
|
|
|
|
} |
|
|
|
|
if got := sdb.Copy().Copy().GetBalance(addr).Uint64(); got != 42 { |
|
|
|
|
t.Fatalf("2nd copy fail, expected 42, got %v", got) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|