Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions execution/commitment/branch_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,20 @@ func TestBranchCache_Stats(t *testing.T) {
require.True(t, strings.HasPrefix(s, "branch-cache "))
}

// newUnwindTestCache sizes the tail large enough that LRU eviction can't
// interfere with the txN/epoch invalidation these tests exercise. The tail is
// sharded (branchCacheTailShards); under a tiny capacity most shards hold a
// single entry, so two keys hashing into the same shard evict each other
// depending on the per-process hash seed.
func newUnwindTestCache() *BranchCache {
return NewBranchCache(DefaultBranchCacheTailCapacity)
}

// TestBranchCache_Unwind_DropsStaleAboveFloorLazily verifies Unwind drops
// (lazily, on the next Get) every superseded-epoch entry whose txN is at or
// above the unwind floor, while entries below the floor survive untouched.
func TestBranchCache_Unwind_DropsStaleAboveFloorLazily(t *testing.T) {
c := NewBranchCache(100)
c := newUnwindTestCache()

rootKey := []byte{0x00}
tailKeyKeep := []byte{0xa0, 0xb0}
Expand Down Expand Up @@ -243,7 +252,7 @@ func TestBranchCache_Unwind_AcrossAllTiers(t *testing.T) {
// entry stamped exactly at the unwind floor belongs to a rolled-back block and
// drops; an entry one txN below the floor survives.
func TestBranchCache_Unwind_FloorBoundary(t *testing.T) {
c := NewBranchCache(100)
c := newUnwindTestCache()

belowKey := []byte{0xa0, 0xb0}
atKey := []byte{0xa0, 0xb1}
Expand Down
Loading