Open wedens opened 7 years ago
@wedens thanks for this. Any chance you can drop in test verifying the behaviour? Thanks
I'll try to do that. Should I just add tests for controlStream
to WebSocketSpec
?
yes, that would be awesome @wedens.
Sorry, I don't know how to implement such test :/
My best attempt so far was something ridiculous like:
property("fail-on-unanswered-pings") = secure {
val s = Stream.eval(async.unboundedQueue[Task, Unit]).flatMap { pingsQ =>
Stream.eval(async.unboundedQueue[Task, PingPong]).flatMap { pongsQ =>
val s = time.awakeEvery[Task](1.second).mapAccumulate(0) {
case (x, _) if x >= 3 =>
val s = Stream.eval_(pingsQ.enqueue1(()))
(x + 1, s)
case (x, _) =>
val s = Stream.eval_(pingsQ.enqueue1(())) ++
Stream.eval_(pongsQ.enqueue1(PingPong.Pong))
(x + 1, s)
}.flatMap(_._2)
val s0 = WebSocket.impl.controlStream(pongsQ.dequeue, pingsQ.dequeue, 3)
s mergeHaltR s0
}
}
Prop.throws(classOf[Throwable]) {
s.run.unsafeRun ?= (())
}
}
It was unused.
Also deleted unused
flag
parameter.