hashicorp / yamux

Golang connection multiplexing library
Mozilla Public License 2.0
2.24k stars 236 forks source link

Fix the ping test by adding a delay to the write operation #41

Open Matthias247 opened 8 years ago

Matthias247 commented 8 years ago

The TestPing unit test failed on my machine since it always reported a rtt of 0. I guess that is since the Go timers are not very accurate on windows and writing through pipes is really fast.

I fixed that now by introducing a delay/sleep to the write. It's a little hacky since I grab and modify the connection from the session which would be unsafe if it sends anything while not externally called. But I think it doesn't do that as long as there are not streams, pings or keepalives running and works for that test.

The other alternative is to introduce a general delay option to pipeConn which I did first. But there unit tests need to be modified in lots of places to set that new parameter.

hashicorp-cla commented 5 years ago

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes


1 out of 2 committers have signed the CLA.

Have you signed the CLA already but the status is still pending? Recheck it.

evanphx commented 2 years ago

This is a good fix for the tests, @Matthias247 I realize this is quite old, did you want to sign the CLA so I can merge this? Thanks!