@@ -23,7 +23,6 @@ import (
2323 "math/big"
2424 "math/rand"
2525 "os"
26- "reflect"
2726 "testing"
2827
2928 "github.com/ethereum/go-ethereum/common"
@@ -249,13 +248,6 @@ func TestBadBlockStorage(t *testing.T) {
249248 t .Fatalf ("The bad blocks are not sorted #[%d](%d) < #[%d](%d)" , i , badBlocks [i ].NumberU64 (), i + 1 , badBlocks [i + 1 ].NumberU64 ())
250249 }
251250 }
252-
253- // Delete all bad blocks
254- DeleteBadBlocks (db )
255- badBlocks = ReadAllBadBlocks (db )
256- if len (badBlocks ) != 0 {
257- t .Fatalf ("Failed to delete bad blocks" )
258- }
259251}
260252
261253// Tests that canonical numbers can be mapped to hashes and retrieved.
@@ -516,37 +508,6 @@ func TestWriteAncientHeaderChain(t *testing.T) {
516508 }
517509}
518510
519- func TestCanonicalHashIteration (t * testing.T ) {
520- var cases = []struct {
521- from , to uint64
522- limit int
523- expect []uint64
524- }{
525- {1 , 8 , 0 , nil },
526- {1 , 8 , 1 , []uint64 {1 }},
527- {1 , 8 , 10 , []uint64 {1 , 2 , 3 , 4 , 5 , 6 , 7 }},
528- {1 , 9 , 10 , []uint64 {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 }},
529- {2 , 9 , 10 , []uint64 {2 , 3 , 4 , 5 , 6 , 7 , 8 }},
530- {9 , 10 , 10 , nil },
531- }
532- // Test empty db iteration
533- db := NewMemoryDatabase ()
534- numbers , _ := ReadAllCanonicalHashes (db , 0 , 10 , 10 )
535- if len (numbers ) != 0 {
536- t .Fatalf ("No entry should be returned to iterate an empty db" )
537- }
538- // Fill database with testing data.
539- for i := uint64 (1 ); i <= 8 ; i ++ {
540- WriteCanonicalHash (db , common.Hash {}, i )
541- }
542- for i , c := range cases {
543- numbers , _ := ReadAllCanonicalHashes (db , c .from , c .to , c .limit )
544- if ! reflect .DeepEqual (numbers , c .expect ) {
545- t .Fatalf ("Case %d failed, want %v, got %v" , i , c .expect , numbers )
546- }
547- }
548- }
549-
550511func TestHashesInRange (t * testing.T ) {
551512 mkHeader := func (number , seq int ) * types.Header {
552513 h := types.Header {
@@ -565,18 +526,6 @@ func TestHashesInRange(t *testing.T) {
565526 total ++
566527 }
567528 }
568- if have , want := len (ReadAllHashesInRange (db , 10 , 10 )), 10 ; have != want {
569- t .Fatalf ("Wrong number of hashes read, want %d, got %d" , want , have )
570- }
571- if have , want := len (ReadAllHashesInRange (db , 10 , 9 )), 0 ; have != want {
572- t .Fatalf ("Wrong number of hashes read, want %d, got %d" , want , have )
573- }
574- if have , want := len (ReadAllHashesInRange (db , 0 , 100 )), total ; have != want {
575- t .Fatalf ("Wrong number of hashes read, want %d, got %d" , want , have )
576- }
577- if have , want := len (ReadAllHashesInRange (db , 9 , 10 )), 9 + 10 ; have != want {
578- t .Fatalf ("Wrong number of hashes read, want %d, got %d" , want , have )
579- }
580529 if have , want := len (ReadAllHashes (db , 10 )), 10 ; have != want {
581530 t .Fatalf ("Wrong number of hashes read, want %d, got %d" , want , have )
582531 }
0 commit comments