diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-03-18 09:41:59 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2019-04-30 11:11:39 -0400 |
commit | 64d5ed0415d69c226b56e518abc8e003780368f0 (patch) | |
tree | 9fe877a448678f3581a783a766afa10cc49558ff /src | |
parent | d3526d3f2c0e3e56dd9fa0e91b78d2787c2d8701 (diff) | |
download | tor-64d5ed0415d69c226b56e518abc8e003780368f0.tar.gz tor-64d5ed0415d69c226b56e518abc8e003780368f0.zip |
Update circuit_timeout test to use deterministic prng
Diffstat (limited to 'src')
-rw-r--r-- | src/test/test.c | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/src/test/test.c b/src/test/test.c index fbc30fb64e..be5cb12b1e 100644 --- a/src/test/test.c +++ b/src/test/test.c @@ -12,6 +12,7 @@ #include "lib/crypt_ops/crypto_dh.h" #include "lib/crypt_ops/crypto_rand.h" #include "app/config/or_state_st.h" +#include "test/rng_test_helpers.h" #include <stdio.h> #ifdef HAVE_FCNTL_H @@ -354,18 +355,6 @@ test_onion_queues(void *arg) tor_free(onionskin); } -static crypto_cipher_t *crypto_rand_aes_cipher = NULL; - -// Mock replacement for crypto_rand: Generates bytes from a provided AES_CTR -// cipher in <b>crypto_rand_aes_cipher</b>. -static void -crypto_rand_deterministic_aes(char *out, size_t n) -{ - tor_assert(crypto_rand_aes_cipher); - memset(out, 0, n); - crypto_cipher_crypt_inplace(crypto_rand_aes_cipher, out, n); -} - static void test_circuit_timeout(void *arg) { @@ -397,8 +386,7 @@ test_circuit_timeout(void *arg) // Use a deterministic RNG here, or else we'll get nondeterministic // coverage in some of the circuitstats functions. - MOCK(crypto_rand, crypto_rand_deterministic_aes); - crypto_rand_aes_cipher = crypto_cipher_new("xyzzyplughplover"); + testing_enable_deterministic_rng(); circuitbuild_running_unit_tests(); #define timeout0 (build_time_t)(30*1000.0) @@ -534,8 +522,8 @@ test_circuit_timeout(void *arg) circuit_build_times_free_timeouts(&final); or_state_free(state); teardown_periodic_events(); - UNMOCK(crypto_rand); - crypto_cipher_free(crypto_rand_aes_cipher); + + testing_disable_deterministic_rng(); } /** Test encoding and parsing of rendezvous service descriptors. */ |