@cryptotaxi247 / kubo / commits / 6acc152f0

backpressure: explanation + more rounds

Juan Batiz-Benet committed Dec 17, 2014 at 19:21 UTC 6acc152f0c7c4e9bf7dfdd5599aaeb34bfe48fd6
1 file changed +12 -4
net/backpressure/backpressure_test.go
+12 -4
@@ -354,6 +354,7 @@ func TestStBackpressureStreamWrite(t *testing.T) {
354 stop <- struct{}{}
355 contTime := time.Now().Sub(contStart)
356
357 + // now compare! continuous should've been faster AND larger
358 if roundsTime < contTime {
359 t.Error("continuous should have been faster")
360 }
@@ -362,10 +363,17 @@ func TestStBackpressureStreamWrite(t *testing.T) {
363 t.Error("continuous should have been larger, too!")
364 }
365
365 - <-time.After(300 * time.Millisecond)
366 - writeStats()
367 - testSenderWrote(0)
368 - testSenderWrote(0)
366 + // and a couple rounds more for good measure ;)
367 + for i := 0; i < 3; i++ {
368 + // let the sender fill its buffers, it will stop sending.
369 + <-time.After(300 * time.Millisecond)
370 + b, _ := writeStats()
371 + testSenderWrote(0)
372 + testSenderWrote(0)
373 +
374 + // drain it all, wait again
375 + receive(s, b)
376 + }
377
378 // this doesn't work :(:
379 // // now for the sugar on top: let's tear down the receiver. it should