-
-
Notifications
You must be signed in to change notification settings - Fork 396
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
Make quinn-proto::{Connection, Endpoint}
deterministic
#1691
Conversation
`quinn-proto::{Connection, Endpoint}` structs call `StdRng::from_entropy()` in their implementation. It makes it hard to reproduce errors in an otherwise deterministic test case. This PR addresses the issue by adding a `StdRng` argument to the respective `new` functions. For other functions that may create an endpoint/connection, an argument of type `impl FnOnce() -> StdRng` is added. This avoids eager calls to generate fresh entropy. e.g. the `Endpoint::handle` function is frequently called but we'd only need the rng when handling a new incoming connection. Fixes lint errors.
b9c205e
to
3748e1e
Compare
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.
I'd prefer to avoid making rand
a public dependency if possible. Could we accept a seed instead of an RNG?
85a93d1
to
166752b
Compare
Put up another version that always use |
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.
Thanks, that looks cleaner!
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.
Thanks!
quinn-proto::{Connection, Endpoint}
structs callStdRng::from_entropy()
in their implementation. It makes it hard to reproduce errors in an otherwise deterministic test case.This PR addresses the issue by adding a
StdRng
argument to the respectivenew
functions. For other functions that may create an endpoint/connection, an argument of typeimpl FnOnce() -> StdRng
is added. This avoids eager calls to generate fresh entropy. e.g. theEndpoint::handle
function is frequently called but we'd only need the rng when handling a new incoming connection.Fixes an unrelated lint error.
Closes #1684