-
Notifications
You must be signed in to change notification settings - Fork 5.3k
add SslStream_RandomWrites_OK test #52682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Tagging subscribers to this area: @dotnet/ncl, @vcsjones Issue DetailsThis test helps with verification when IO does not land on frame a boundary or we get less than expected bytes.
|
src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNetworkStreamTest.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNetworkStreamTest.cs
Outdated
Show resolved
Hide resolved
|
Should this test be part of the Stream Conformance tests? It doesn't seem like it's specific to SslStream. I do think it's a really useful test to have, that's why I kind of want to put it in Stream Conformance.... |
|
Most streams (like NetworkStream or FileStream) do not have any internal structure and it is really opaque pipe. SslStream is different as it maintains state around messages of various types. |
src/libraries/Common/tests/System/Net/RandomReadWriteSizeStream.cs
Outdated
Show resolved
Hide resolved
I think there are other streams that have internal structure, like HTTP chunked encoding or crypto, that could benefit from this. Basically the wrapping streams (of which SslStream is one). |
src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNetworkStreamTest.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/tests/System/Net/RandomReadWriteSizeStream.cs
Outdated
Show resolved
Hide resolved
| public async Task SslStream_RandomSizeWrites_OK(int bufferSize, int readBufferSize, int writeBufferSize, bool useAsync) | ||
| { | ||
| byte[] dataToCopy = RandomNumberGenerator.GetBytes(bufferSize); | ||
| byte[] dataReceived = new byte[dataToCopy.Length + readBufferSize]; // make the buffer bigger to have chance to read more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is readBufferSize here significant? Could we just do dataToCopy.Length + 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
somewhat. It makes readBuffer.Slice(totalLength, readBufferSize) to always work without worrying about how much is left.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, seems reasonable, but a comment would explain that :)
|
In general this is in good shape, a couple nits above. |
This test helps with verification when IO does not land on frame a boundary or we get less than expected bytes.
This was originally part of #49743.