@@ -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
4658func TestCachePutStoresClone (t * testing.T ) {
0 commit comments