You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CBG-5784: add test accessors for the channel cache
Adds the accessors db/channelcachetest needs to drive channelCacheImpl,
singleChannelCacheImpl and the bypass cache from outside package db. Derived by
attempting the move and compiling to closure - three probe rounds, then three
more accessors surfaced during the move itself, because newSingleChannelCache
and newChannelCache return unnameable types and mask every method call on their
results. A single pass finds six of them.
Notable shapes: singleChannelCacheImpl.options is already a
*ChannelCacheOptions, so OptionsForTest is a plain getter and the twelve sites
that adjust cache caps in place keep working. addChannelCache returns the
concrete cache and a capacity flag rather than an error, so
AddChannelCacheForTest mirrors that. WaitForChannelCacheCompactionForTest
absorbs the waitForCompaction helper from channel_cache_test.go, whose
*channelCacheImpl parameter cannot be named from another package.
Two exceptions to the accessor-only rule, both because test code has to name a
type rather than merely hold it - a type assertion, and a closure whose result
type is the concrete cache. ChannelCacheImplForTest and
SingleChannelCacheImplForTest are aliases for exactly those cases; no accessor
can stand in for a result type.
AddListenerToNewestLateLogForTest is the one accessor that is not a bare
pass-through: it takes lateLogLock for precisely the operation
TestLateLogsSpikeForcePrunedBoundsLateLogsAndForcesRollback performed inline,
so the critical section is unchanged. Encapsulating it avoids stranding that
test in package db the way TestAddPendingLogs is.
No wrapper struct: an exported constructor returning an unexported type is
usable by inference, so the 78 addToCache call sites need one exported method
rather than a parallel type.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
0 commit comments