merged from gramsrv upstream

This commit is contained in:
onysd 2026-09-01 12:06:31 +03:00
parent 79c64ee916
commit 21a0856587
651 changed files with 54774 additions and 4590 deletions

View file

@ -55,6 +55,29 @@ func TestChannelMemberCachePutGetDeleteFlush(t *testing.T) {
}
}
func TestChannelMemberCachePutIfEpochRejectsStaleSnapshot(t *testing.T) {
c := NewChannelMemberCache(16)
epoch := c.cacheEpoch()
c.delete(10, 20)
c.putIfEpoch(domain.ChannelMember{
ChannelID: 10,
UserID: 20,
Status: domain.ChannelMemberActive,
}, epoch)
if _, ok := c.get(10, 20); ok {
t.Fatal("stale materialized membership restored after invalidation")
}
freshEpoch := c.cacheEpoch()
c.putIfEpoch(domain.ChannelMember{
ChannelID: 10,
UserID: 20,
Status: domain.ChannelMemberActive,
}, freshEpoch)
if member, ok := c.get(10, 20); !ok || member.Status != domain.ChannelMemberActive {
t.Fatalf("fresh materialized membership = %+v ok=%v", member, ok)
}
}
func TestChannelMemberCacheDeleteChannelAndCap(t *testing.T) {
c := NewChannelMemberCache(2)
c.put(domain.ChannelMember{ChannelID: 1, UserID: 10})