mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-20 05:13:11 -06:00
Try to ensure that TestCorrectStreamWakeup doesn't block forever
This commit is contained in:
parent
7a4d9e222d
commit
c859164597
|
|
@ -13,4 +13,4 @@ go build ./cmd/...
|
|||
./scripts/find-lint.sh
|
||||
|
||||
echo "Testing..."
|
||||
go test ./...
|
||||
go test -v ./...
|
||||
|
|
|
|||
|
|
@ -160,14 +160,23 @@ func TestCorrectStreamWakeup(t *testing.T) {
|
|||
streamone := lockedFetchUserStream(n, alice, "one")
|
||||
streamtwo := lockedFetchUserStream(n, alice, "two")
|
||||
|
||||
go waitForBlocking(streamone, 1)
|
||||
go waitForBlocking(streamtwo, 1)
|
||||
wait := func(stream *UserDeviceStream) {
|
||||
select {
|
||||
case <-time.After(time.Second * 10):
|
||||
return
|
||||
default:
|
||||
waitForBlocking(stream, 1)
|
||||
}
|
||||
}
|
||||
|
||||
go wait(streamone)
|
||||
go wait(streamtwo)
|
||||
|
||||
go func() {
|
||||
select {
|
||||
case <-n.userDeviceStreams[alice]["one"].signalChannel:
|
||||
case <-streamone.signalChannel:
|
||||
awoken <- "one"
|
||||
case <-n.userDeviceStreams[alice]["two"].signalChannel:
|
||||
case <-streamtwo.signalChannel:
|
||||
awoken <- "two"
|
||||
}
|
||||
}()
|
||||
|
|
@ -180,9 +189,6 @@ func TestCorrectStreamWakeup(t *testing.T) {
|
|||
if result := <-awoken; result != wake {
|
||||
t.Fatalf("expected to wake %q, got %q", wake, result)
|
||||
}
|
||||
|
||||
close(n.userDeviceStreams[alice]["one"].signalChannel)
|
||||
close(n.userDeviceStreams[alice]["two"].signalChannel)
|
||||
}
|
||||
|
||||
// Test that an invite unblocks the request
|
||||
|
|
|
|||
Loading…
Reference in a new issue