MCPcopy Create free account
hub / github.com/CPChain/chain / TestCopyOfCopy

Function TestCopyOfCopy

core/state/statedb_test.go:425–436  ·  view source on GitHub ↗

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

(t *testing.T)

Source from the content-addressed store, hash-verified

423// TestCopyOfCopy tests that modified objects are carried over to the copy, and the copy of the copy.
424// See https://github.com/ethereum/go-ethereum/pull/15225#issuecomment-380191512
425func TestCopyOfCopy(t *testing.T) {
426 sdb, _ := New(common.Hash{}, NewDatabase(database.NewMemDatabase()))
427 addr := common.HexToAddress("aaaa")
428 sdb.SetBalance(addr, big.NewInt(42))
429
430 if got := sdb.Copy().GetBalance(addr).Uint64(); got != 42 {
431 t.Fatalf("1st copy fail, expected 42, got %v", got)
432 }
433 if got := sdb.Copy().Copy().GetBalance(addr).Uint64(); got != 42 {
434 t.Fatalf("2nd copy fail, expected 42, got %v", got)
435 }
436}

Callers

nothing calls this directly

Calls 6

NewDatabaseFunction · 0.85
Uint64Method · 0.80
NewFunction · 0.70
GetBalanceMethod · 0.65
SetBalanceMethod · 0.45
CopyMethod · 0.45

Tested by

no test coverage detected