Skip to content

Commit 831d8f3

Browse files
committed
fix: reduce diff
1 parent 5cdf50c commit 831d8f3

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

graft/coreth/core/state/snapshot/wipe_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ import (
4242
// Tests that given a database with random data content, all parts of a snapshot
4343
// can be crrectly wiped without touching anything else.
4444
func TestWipe(t *testing.T) {
45-
// Create a database with some random snapshot data.
45+
// Create a database with some random snapshot data
4646
db := memorydb.New()
4747
for i := 0; i < 128; i++ {
4848
rawdb.WriteAccountSnapshot(db, randomHash(), randomHash().Bytes())
4949
}
5050
customrawdb.WriteSnapshotBlockHash(db, randomHash())
5151
rawdb.WriteSnapshotRoot(db, randomHash())
5252

53-
// Add some random non-snapshot data too to make wiping harder.
53+
// Add some random non-snapshot data too to make wiping harder
5454
for i := 0; i < 500; i++ {
55-
// Generate keys with wrong length for a state snapshot item.
55+
// Generate keys with wrong length for a state snapshot item
5656
keysuffix := make([]byte, 31)
5757
rand.Read(keysuffix)
5858
db.Put(append(rawdb.SnapshotAccountPrefix, keysuffix...), randomHash().Bytes())
@@ -70,9 +70,9 @@ func TestWipe(t *testing.T) {
7070
}
7171
return items
7272
}
73-
// Verify snapshot data exists before wipe.
73+
// Sanity check that all the keys are present
7474
if items := count(); items != 128 {
75-
t.Fatalf("snapshot size mismatch before wipe: have %d, want %d", items, 128)
75+
t.Fatalf("snapshot size mismatch: have %d, want %d", items, 128)
7676
}
7777
blockHash, err := customrawdb.ReadSnapshotBlockHash(db)
7878
switch {
@@ -81,26 +81,26 @@ func TestWipe(t *testing.T) {
8181
case blockHash == (common.Hash{}):
8282
t.Fatalf("snapshot block hash is empty before wipe")
8383
}
84-
if root := rawdb.ReadSnapshotRoot(db); root == (common.Hash{}) {
85-
t.Fatalf("snapshot root is empty before wipe")
84+
if hash := rawdb.ReadSnapshotRoot(db); hash == (common.Hash{}) {
85+
t.Errorf("snapshot block root marker mismatch: have %#x, want <not-nil>", hash)
8686
}
87+
// Wipe all snapshot entries from the database
8788

88-
// Wipe all snapshot entries from the database.
8989
<-WipeSnapshot(db, true)
9090

91-
// Verify snapshot data is removed.
91+
// Iterate over the database end ensure no snapshot information remains
9292
if items := count(); items != 0 {
93-
t.Fatalf("snapshot size mismatch after wipe: have %d, want %d", items, 0)
93+
t.Fatalf("snapshot size mismatch: have %d, want %d", items, 0)
9494
}
95-
// Verify miscellaneous items are preserved.
95+
// Iterate over the database and ensure miscellaneous items are present
9696
items := 0
9797
it := db.NewIterator(nil, nil)
9898
defer it.Release()
9999
for it.Next() {
100100
items++
101101
}
102102
if items != 1000 {
103-
t.Fatalf("misc item count mismatch after wipe: have %d, want %d", items, 1000)
103+
t.Fatalf("misc item count mismatch: have %d, want %d", items, 1000)
104104
}
105105

106106
// Verify snapshot markers are removed.
@@ -112,7 +112,7 @@ func TestWipe(t *testing.T) {
112112
case blockHash != (common.Hash{}):
113113
t.Errorf("snapshot block hash marker remained after wipe: %#x", blockHash)
114114
}
115-
if root := rawdb.ReadSnapshotRoot(db); root != (common.Hash{}) {
116-
t.Errorf("snapshot root marker remained after wipe: %#x", root)
115+
if hash := rawdb.ReadSnapshotRoot(db); hash != (common.Hash{}) {
116+
t.Errorf("snapshot block root marker remained after wipe: %#x", hash)
117117
}
118118
}

0 commit comments

Comments
 (0)