BitBoxSwiss / bitbox02-firmware

Firmware code of the BitBox02 hardware wallet
https://bitbox.swiss/bitbox02
Apache License 2.0
256 stars 91 forks source link

testing/random: allow resetting the test PRNG seed #952

Closed benma closed 2 years ago

benma commented 2 years ago

If multiple unit tests exercise code that use random_32_bytes() (or one of the other randomness functions) to generate randomness, they could get different values depending on the order in which they run, as in unit tests, the randomness function use rand().

This commit adds a way for unit tests to reset the PRNG seed so that unit tests can make sure to get the same values every time, independent of other tests.