4 ms·
First thing I do when I join a group that has code that writes and reads bytes from the wire is write really big stress tests and keep fixing things till it has
by lanstin 3y ago
First thing I do when I join a group that has code that writes and reads bytes from the wire is write really big stress tests and keep fixing things till it has 100% reliability, short messages, long messages, slow messages, pipe lined messageds, etc. etc. There's so many bugs where the code fails if len > N, len % N == 0, len < small N, len < what is read, etc. Like does this mean the driver had never worked for len > 126 or whatever?
- gmac 3y agoYeah: interestingly, they had a test for the biggest category of frame, but not for the two other categories: https://github.com/nodejs/undici/blob/main/test/websocket/send.js https://github.com/nodejs/undici/blob/main/test/websocket/se... The test I contributed is very specific to the frame fix I made, but I should probably go back and contribute more tests in send.js that test other lengths too.
- pacaro 3y agoThis. And profile guided fuzz testing. Ideally every basis path that serializes/deserializes should be tested
- hinkley 3y agoDon't forget the perennial classic: len > N && len % N == 1 Due to off by one error, the last byte of a message is never sent if the message is larger than the buffer or the packet size (or not sent until the next message arrives, for stream protocols)
- lanstin 3y agoYeah, I had a djb net parser my (work) friends wrote that would end up dropping the connection if the last byte read was the byte before the separating comma. https://en.wikipedia.org/wiki/Netstring https://en.wikipedia.org/wiki/Netstring Only happened with very large database reads so that the 1440 byte segments hit that spot. New manager and he started mocking me during team meetings on why I was so obsessed with these load tests succeeding and then was amazed at the 2 char fix (adding +1 to the read till length call).
- deleted 3y ago[deleted]