mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-20 21:33:19 -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
|
./scripts/find-lint.sh
|
||||||
|
|
||||||
echo "Testing..."
|
echo "Testing..."
|
||||||
go test ./...
|
go test -v ./...
|
||||||
|
|
|
||||||
|
|
@ -160,14 +160,23 @@ func TestCorrectStreamWakeup(t *testing.T) {
|
||||||
streamone := lockedFetchUserStream(n, alice, "one")
|
streamone := lockedFetchUserStream(n, alice, "one")
|
||||||
streamtwo := lockedFetchUserStream(n, alice, "two")
|
streamtwo := lockedFetchUserStream(n, alice, "two")
|
||||||
|
|
||||||
go waitForBlocking(streamone, 1)
|
wait := func(stream *UserDeviceStream) {
|
||||||
go waitForBlocking(streamtwo, 1)
|
select {
|
||||||
|
case <-time.After(time.Second * 10):
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
waitForBlocking(stream, 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
go wait(streamone)
|
||||||
|
go wait(streamtwo)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
select {
|
select {
|
||||||
case <-n.userDeviceStreams[alice]["one"].signalChannel:
|
case <-streamone.signalChannel:
|
||||||
awoken <- "one"
|
awoken <- "one"
|
||||||
case <-n.userDeviceStreams[alice]["two"].signalChannel:
|
case <-streamtwo.signalChannel:
|
||||||
awoken <- "two"
|
awoken <- "two"
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
@ -180,9 +189,6 @@ func TestCorrectStreamWakeup(t *testing.T) {
|
||||||
if result := <-awoken; result != wake {
|
if result := <-awoken; result != wake {
|
||||||
t.Fatalf("expected to wake %q, got %q", wake, result)
|
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
|
// Test that an invite unblocks the request
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue