OSDN Git Service

Merge pull request #201 from Bytom/v0.1
[bytom/vapor.git] / database / leveldb / cache_test.go
diff --git a/database/leveldb/cache_test.go b/database/leveldb/cache_test.go
deleted file mode 100644 (file)
index 7dae1b9..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-package leveldb
-
-import (
-       "testing"
-
-       "github.com/vapor/protocol/bc"
-       "github.com/vapor/protocol/bc/types"
-)
-
-func TestBlockCache(t *testing.T) {
-       newBlock := func(h uint64) *types.Block {
-               return &types.Block{
-                       BlockHeader: types.BlockHeader{
-                               Height: h,
-                       },
-               }
-       }
-       blocks := make(map[bc.Hash]*types.Block)
-       for i := 0; i < maxCachedBlocks+10; i++ {
-               block := newBlock(uint64(i))
-               blocks[block.Hash()] = block
-       }
-
-       cache := newBlockCache(func(hash *bc.Hash) *types.Block {
-               return blocks[*hash]
-       })
-
-       for i := 0; i < maxCachedBlocks+10; i++ {
-               block := newBlock(uint64(i))
-               hash := block.Hash()
-               cache.lookup(&hash)
-       }
-
-       for i := 0; i < 10; i++ {
-               block := newBlock(uint64(i))
-               hash := block.Hash()
-               if b, _ := cache.get(&hash); b != nil {
-                       t.Fatalf("find old block")
-               }
-       }
-
-       for i := 10; i < maxCachedBlocks+10; i++ {
-               block := newBlock(uint64(i))
-               hash := block.Hash()
-               if b, _ := cache.get(&hash); b == nil {
-                       t.Fatalf("can't find new block")
-               }
-       }
-}