@@ -402,21 +402,22 @@ func TestSnaphotInDepth(t *testing.T) {
402402 last = common .HexToHash ("0x01" )
403403 head common.Hash
404404 )
405+ // Flush another 128 layers, one diff will be flatten into the parent.
405406 for i := 0 ; i < 128 ; i ++ {
406407 head = makeRoot (uint64 (i + 2 ))
407408 snaps .Update (head , last , nil , setAccount (fmt .Sprintf ("%d" , i + 2 )), nil )
408409 last = head
410+ snaps .Cap (head , 127 ) // 128 layers are allowed, 128th is the persistent layer
409411 }
410412 var cases = []struct {
411413 headRoot common.Hash
412414 depth int
413415 expect common.Hash
414416 }{
415- {common .HexToHash ("0x01" ), 0 , common .HexToHash ("0x01" )}, // Disk layer
416417 {head , 0 , head },
417418 {head , 1 , makeRoot (127 + 2 - 1 )},
418- {head , 127 , makeRoot (127 + 2 - 127 )},
419- {head , 128 , common .HexToHash ("0x01" )},
419+ {head , 126 , makeRoot (127 + 2 - 126 )}, // The bottom-most diff layer
420+ {head , 127 , common .HexToHash ("0x01" )}, // The disk layer
420421 }
421422 for _ , c := range cases {
422423 snap := snaps .SnapshotInDepth (c .headRoot , c .depth )
@@ -430,7 +431,7 @@ func TestSnaphotInDepth(t *testing.T) {
430431 t .Fatal ("Snapshot is not available" )
431432 }
432433 if snap .Root () != c .expect {
433- t .Fatal ("Snapshot mismatch" )
434+ t .Fatalf ("Snapshot mismatch, want %v, get %v" , c . expect , snap . Root () )
434435 }
435436 }
436437 }
0 commit comments