diff --git a/execution/commitment/branch_cache_test.go b/execution/commitment/branch_cache_test.go index 11cdac4a4df..a332e7138fc 100644 --- a/execution/commitment/branch_cache_test.go +++ b/execution/commitment/branch_cache_test.go @@ -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} @@ -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}