Skip to content
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

Random not being random enough. #1

Open
3rd-Eden opened this issue Oct 27, 2014 · 1 comment
Open

Random not being random enough. #1

3rd-Eden opened this issue Oct 27, 2014 · 1 comment

Comments

@3rd-Eden
Copy link
Member

One of the timeout tests fails randomly. In this test we generate 100 timeouts and assert that we got at least more than 70% unique timeout ranges generated. This test fails randomly because we sometimes generate less unique/random timeouts for a given range. There are some possible causes for this:

  • It could be that our test just makes an assumption that is just way to high, as we only generate timeouts within 150 and 300 but that would still leave 150 possibilities.
  • Our timeout algorithm is flawed.
  • The timeout is flawed.

With Math.random() analysis like this: https://github.com/nquinlan/better-random-numbers-for-javascript-mirror in the back of heads, it might be wise to come up something more random.

@connor4312
Copy link
Contributor

In this case, strong randomness isn't important, as it would be in a cryptographic application, for instance. Math.random() isn't great, but it's fast and random enough for the purpose of this library. If you're bent on testing this, perhaps the best way would be to make a random module/function to wrap Math.random() and spy on it during testing to ensure it gets called and the output used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants