- price map: guard with a RWMutex (fatal concurrent map access) - InvoiceStream: stop on client disconnect, unsubscribe once, cap streams per wallet - join tickets: key the ticket event per joiner; enforce tickets that expired while the bot was down Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
22 lines
452 B
Go
22 lines
452 B
Go
package api
|
|
|
|
import "testing"
|
|
|
|
func TestStreamSlotsAreBoundedPerWallet(t *testing.T) {
|
|
for i := 0; i < maxStreamsPerWallet; i++ {
|
|
if !acquireStream("w1") {
|
|
t.Fatalf("slot %d refused", i)
|
|
}
|
|
}
|
|
if acquireStream("w1") {
|
|
t.Error("slot beyond the limit was granted")
|
|
}
|
|
if !acquireStream("w2") {
|
|
t.Error("another wallet must not be affected")
|
|
}
|
|
releaseStream("w1")
|
|
if !acquireStream("w1") {
|
|
t.Error("released slot was not reusable")
|
|
}
|
|
}
|