Skip to content

Commit e5336fc

Browse files
committed
fix: test to ensure testing cache is used
1 parent c6240d3 commit e5336fc

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

x/blockdb/entry_cache_test.go

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,32 @@ func TestCacheOnMiss(t *testing.T) {
2727
require.True(t, ok)
2828
}
2929

30-
func TestCacheHas(t *testing.T) {
30+
func TestCacheGet(t *testing.T) {
3131
db, _ := newTestDatabase(t, DefaultConfig())
3232
height := uint64(30)
3333
block := randomBlock(t)
34-
require.NoError(t, db.Put(height, block))
3534

35+
// Populate cache directly without writing to database
36+
db.entryCache.Put(height, block)
37+
38+
// Get should return the block from cache
39+
data, err := db.Get(height)
40+
require.NoError(t, err)
41+
require.Equal(t, block, data)
42+
}
43+
44+
func TestCacheHas(t *testing.T) {
45+
db, _ := newTestDatabase(t, DefaultConfig())
46+
height := uint64(40)
47+
block := randomBlock(t)
48+
49+
// Populate cache directly without writing to database
50+
db.entryCache.Put(height, block)
51+
52+
// Has should return true from cache even though block is not in database
3653
has, err := db.Has(height)
3754
require.NoError(t, err)
3855
require.True(t, has)
39-
40-
// Verify block is in cache
41-
cached, ok := db.entryCache.Get(height)
42-
require.True(t, ok)
43-
require.Equal(t, block, cached)
4456
}
4557

4658
func TestCachePutStoresClone(t *testing.T) {

0 commit comments

Comments
 (0)