mirror of
https://github.com/J3vb/OwnCord.git
synced 2026-09-03 03:50:00 +03:00
fix(ws): wire topicLimiter into hand-rolled test hubs
newEmitTestHub and NewHubForTest built raw Hub literals without the topic rate limiter, so deliverBroadcast panicked on a nil receiver and TestEmitEvents_ChannelEvent_CallsBroadcastToChannel could never pass. CI never surfaced it because the pipeline died at govulncheck first. Wire the limiter exactly as NewHub does; no production nil-guard, since a nil limiter in production would silently disable rate limiting. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -34,6 +34,7 @@ func newEmitTestHub() *Hub {
|
||||
pubsub: NewPubSub(),
|
||||
replayBuf: NewEventRingBuffer(100),
|
||||
voiceKeyHolders: make(map[int64]int64),
|
||||
topicLimiter: NewTopicRateLimiter(topicRateLimitPerSecond, time.Second),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,8 +93,9 @@ func (p *LiveKitProcess) SetProcessStoppedForTest() {
|
||||
// NewHubForTest creates a minimal Hub with no DB or limiter for webhook testing.
|
||||
func NewHubForTest() *Hub {
|
||||
return &Hub{
|
||||
clients: make(map[int64]*Client),
|
||||
pubsub: NewPubSub(),
|
||||
clients: make(map[int64]*Client),
|
||||
pubsub: NewPubSub(),
|
||||
topicLimiter: NewTopicRateLimiter(topicRateLimitPerSecond, time.Second),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user