|
|
@ -491,12 +491,12 @@ func TestGenerateWithExtraAccounts(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
// Identical in the snap
|
|
|
|
// Identical in the snap
|
|
|
|
key := hashData([]byte("acc-1")) |
|
|
|
key := hashData([]byte("acc-1")) |
|
|
|
rawdb.WriteAccountSnapshot(helper.triedb.DiskDB(), key, val) |
|
|
|
rawdb.WriteAccountSnapshot(helper.diskdb, key, val) |
|
|
|
rawdb.WriteStorageSnapshot(helper.triedb.DiskDB(), key, hashData([]byte("key-1")), []byte("val-1")) |
|
|
|
rawdb.WriteStorageSnapshot(helper.diskdb, key, hashData([]byte("key-1")), []byte("val-1")) |
|
|
|
rawdb.WriteStorageSnapshot(helper.triedb.DiskDB(), key, hashData([]byte("key-2")), []byte("val-2")) |
|
|
|
rawdb.WriteStorageSnapshot(helper.diskdb, key, hashData([]byte("key-2")), []byte("val-2")) |
|
|
|
rawdb.WriteStorageSnapshot(helper.triedb.DiskDB(), key, hashData([]byte("key-3")), []byte("val-3")) |
|
|
|
rawdb.WriteStorageSnapshot(helper.diskdb, key, hashData([]byte("key-3")), []byte("val-3")) |
|
|
|
rawdb.WriteStorageSnapshot(helper.triedb.DiskDB(), key, hashData([]byte("key-4")), []byte("val-4")) |
|
|
|
rawdb.WriteStorageSnapshot(helper.diskdb, key, hashData([]byte("key-4")), []byte("val-4")) |
|
|
|
rawdb.WriteStorageSnapshot(helper.triedb.DiskDB(), key, hashData([]byte("key-5")), []byte("val-5")) |
|
|
|
rawdb.WriteStorageSnapshot(helper.diskdb, key, hashData([]byte("key-5")), []byte("val-5")) |
|
|
|
} |
|
|
|
} |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Account two exists only in the snapshot
|
|
|
|
// Account two exists only in the snapshot
|
|
|
@ -508,15 +508,15 @@ func TestGenerateWithExtraAccounts(t *testing.T) { |
|
|
|
acc := &Account{Balance: big.NewInt(1), Root: stRoot, CodeHash: emptyCode.Bytes()} |
|
|
|
acc := &Account{Balance: big.NewInt(1), Root: stRoot, CodeHash: emptyCode.Bytes()} |
|
|
|
val, _ := rlp.EncodeToBytes(acc) |
|
|
|
val, _ := rlp.EncodeToBytes(acc) |
|
|
|
key := hashData([]byte("acc-2")) |
|
|
|
key := hashData([]byte("acc-2")) |
|
|
|
rawdb.WriteAccountSnapshot(helper.triedb.DiskDB(), key, val) |
|
|
|
rawdb.WriteAccountSnapshot(helper.diskdb, key, val) |
|
|
|
rawdb.WriteStorageSnapshot(helper.triedb.DiskDB(), key, hashData([]byte("b-key-1")), []byte("b-val-1")) |
|
|
|
rawdb.WriteStorageSnapshot(helper.diskdb, key, hashData([]byte("b-key-1")), []byte("b-val-1")) |
|
|
|
rawdb.WriteStorageSnapshot(helper.triedb.DiskDB(), key, hashData([]byte("b-key-2")), []byte("b-val-2")) |
|
|
|
rawdb.WriteStorageSnapshot(helper.diskdb, key, hashData([]byte("b-key-2")), []byte("b-val-2")) |
|
|
|
rawdb.WriteStorageSnapshot(helper.triedb.DiskDB(), key, hashData([]byte("b-key-3")), []byte("b-val-3")) |
|
|
|
rawdb.WriteStorageSnapshot(helper.diskdb, key, hashData([]byte("b-key-3")), []byte("b-val-3")) |
|
|
|
} |
|
|
|
} |
|
|
|
root := helper.Commit() |
|
|
|
root := helper.Commit() |
|
|
|
|
|
|
|
|
|
|
|
// To verify the test: If we now inspect the snap db, there should exist extraneous storage items
|
|
|
|
// To verify the test: If we now inspect the snap db, there should exist extraneous storage items
|
|
|
|
if data := rawdb.ReadStorageSnapshot(helper.triedb.DiskDB(), hashData([]byte("acc-2")), hashData([]byte("b-key-1"))); data == nil { |
|
|
|
if data := rawdb.ReadStorageSnapshot(helper.diskdb, hashData([]byte("acc-2")), hashData([]byte("b-key-1"))); data == nil { |
|
|
|
t.Fatalf("expected snap storage to exist") |
|
|
|
t.Fatalf("expected snap storage to exist") |
|
|
|
} |
|
|
|
} |
|
|
|
snap := generateSnapshot(helper.diskdb, helper.triedb, 16, root) |
|
|
|
snap := generateSnapshot(helper.diskdb, helper.triedb, 16, root) |
|
|
@ -534,7 +534,7 @@ func TestGenerateWithExtraAccounts(t *testing.T) { |
|
|
|
snap.genAbort <- stop |
|
|
|
snap.genAbort <- stop |
|
|
|
<-stop |
|
|
|
<-stop |
|
|
|
// If we now inspect the snap db, there should exist no extraneous storage items
|
|
|
|
// If we now inspect the snap db, there should exist no extraneous storage items
|
|
|
|
if data := rawdb.ReadStorageSnapshot(helper.triedb.DiskDB(), hashData([]byte("acc-2")), hashData([]byte("b-key-1"))); data != nil { |
|
|
|
if data := rawdb.ReadStorageSnapshot(helper.diskdb, hashData([]byte("acc-2")), hashData([]byte("b-key-1"))); data != nil { |
|
|
|
t.Fatalf("expected slot to be removed, got %v", string(data)) |
|
|
|
t.Fatalf("expected slot to be removed, got %v", string(data)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|