Skip to content

Commit 0262ecd

Browse files
nits
1 parent cb0d37c commit 0262ecd

File tree

5 files changed

+18
-11
lines changed

5 files changed

+18
-11
lines changed

cache/lru_cache_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ import (
1212
func TestLRU(t *testing.T) {
1313
cache := &LRU{Size: 1}
1414

15-
BasicCache(t, cache)
15+
TestBasic(t, cache)
16+
}
17+
18+
func TestLRUEviction(t *testing.T) {
19+
cache := &LRU{Size: 2}
20+
21+
TestEviction(t, cache)
1622
}
1723

1824
func TestLRUResize(t *testing.T) {
File renamed without changes.

cache/metercacher/meter_cacher_test.go renamed to cache/metercacher/cache_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import (
1010

1111
func TestInterface(t *testing.T) {
1212
for _, test := range cache.CacherTests {
13-
cache := &cache.LRU{Size: 1}
13+
cache := &cache.LRU{Size: test.Size}
1414
c, err := New("", prometheus.NewRegistry(), cache)
1515
if err != nil {
1616
t.Fatal(err)
1717
}
1818

19-
test(t, c)
19+
test.Func(t, c)
2020
}
2121
}

cache/test_cache.go renamed to cache/test_cacher.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ import (
1010
)
1111

1212
var (
13-
// Tests is a list of all LRU cache tests
14-
CacherTests = []func(t *testing.T, c Cacher){
15-
BasicCache,
13+
// CacherTests is a list of all Cacher tests
14+
CacherTests = []struct {
15+
Size int
16+
Func func(t *testing.T, c Cacher)
17+
}{
18+
{Size: 1, Func: TestBasic},
19+
{Size: 2, Func: TestEviction},
1620
}
1721
)
1822

19-
func BasicCache(t *testing.T, cache Cacher) {
23+
func TestBasic(t *testing.T, cache Cacher) {
2024
id1 := ids.ID{1}
2125
if _, found := cache.Get(id1); found {
2226
t.Fatalf("Retrieved value when none exists")
@@ -58,9 +62,7 @@ func BasicCache(t *testing.T, cache Cacher) {
5862
}
5963
}
6064

61-
func TestLRUEviction(t *testing.T) {
62-
cache := LRU{Size: 2}
63-
65+
func TestEviction(t *testing.T, cache Cacher) {
6466
id1 := ids.ID{1}
6567
id2 := ids.ID{2}
6668
id3 := ids.ID{3}

vms/rpcchainvm/vm_client.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,6 @@ func (vm *VMClient) GetBlock(id ids.ID) (snowman.Block, error) {
361361
if blk, cached := vm.blks[id]; cached {
362362
return blk, nil
363363
}
364-
365364
if blkIntf, cached := vm.decidedBlocks.Get(id); cached {
366365
return blkIntf.(*BlockClient), nil
367366
}

0 commit comments

Comments
 (0)