diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test_circuitpadding.c | 39 | ||||
-rw-r--r-- | src/test/test_util.c | 2 |
2 files changed, 19 insertions, 22 deletions
diff --git a/src/test/test_circuitpadding.c b/src/test/test_circuitpadding.c index 78f93f7b24..5693c98e41 100644 --- a/src/test/test_circuitpadding.c +++ b/src/test/test_circuitpadding.c @@ -12,6 +12,7 @@ #include <event.h> #include "lib/evloop/compat_libevent.h" #include "lib/time/compat_time.h" +#include "lib/defs/time.h" #include "core/or/relay.h" #include "core/or/circuitlist.h" #include "core/or/circuitbuild.h" @@ -32,10 +33,6 @@ extern smartlist_t *connection_array; -#define USEC_PER_SEC (1000000) -#define NSEC_PER_USEC (1000) -#define NSEC_PER_MSEC (1000*1000) - circid_t get_unique_circ_id_by_chan(channel_t *chan); void helper_create_basic_machine(void); static void helper_create_conditional_machines(void); @@ -69,7 +66,7 @@ static circpad_machine_t circ_client_machine; static void timers_advance_and_run(int64_t msec_update) { - curr_mocked_time += msec_update*NSEC_PER_MSEC; + curr_mocked_time += msec_update*TOR_NSEC_PER_MSEC; monotime_coarse_set_mock_time_nsec(curr_mocked_time); monotime_set_mock_time_nsec(curr_mocked_time); timers_run_pending(); @@ -304,9 +301,9 @@ test_circuitpadding_rtt(void *arg) monotime_init(); monotime_enable_test_mocking(); - monotime_set_mock_time_nsec(1*NSEC_PER_USEC); - monotime_coarse_set_mock_time_nsec(1*NSEC_PER_USEC); - curr_mocked_time = 1*NSEC_PER_USEC; + monotime_set_mock_time_nsec(1*TOR_NSEC_PER_USEC); + monotime_coarse_set_mock_time_nsec(1*TOR_NSEC_PER_USEC); + curr_mocked_time = 1*TOR_NSEC_PER_USEC; timers_initialize(); circpad_machines_init(); @@ -994,9 +991,9 @@ test_circuitpadding_tokens(void *arg) monotime_init(); monotime_enable_test_mocking(); - monotime_set_mock_time_nsec(1*NSEC_PER_USEC); - monotime_coarse_set_mock_time_nsec(1*NSEC_PER_USEC); - curr_mocked_time = 1*NSEC_PER_USEC; + monotime_set_mock_time_nsec(1*TOR_NSEC_PER_USEC); + monotime_coarse_set_mock_time_nsec(1*TOR_NSEC_PER_USEC); + curr_mocked_time = 1*TOR_NSEC_PER_USEC; timers_initialize(); @@ -1441,9 +1438,9 @@ test_circuitpadding_negotiation(void *arg) monotime_init(); monotime_enable_test_mocking(); - monotime_set_mock_time_nsec(1*NSEC_PER_USEC); - monotime_coarse_set_mock_time_nsec(1*NSEC_PER_USEC); - curr_mocked_time = 1*NSEC_PER_USEC; + monotime_set_mock_time_nsec(1*TOR_NSEC_PER_USEC); + monotime_coarse_set_mock_time_nsec(1*TOR_NSEC_PER_USEC); + curr_mocked_time = 1*TOR_NSEC_PER_USEC; timers_initialize(); circpad_machines_init(); @@ -1562,7 +1559,7 @@ simulate_single_hop_extend(circuit_t *client, circuit_t *mid_relay, circpad_cell_event_nonpadding_received((circuit_t*)mid_relay); // Advance time a tiny bit so we can calculate an RTT - curr_mocked_time += 10 * NSEC_PER_MSEC; + curr_mocked_time += 10 * TOR_NSEC_PER_MSEC; monotime_coarse_set_mock_time_nsec(curr_mocked_time); monotime_set_mock_time_nsec(curr_mocked_time); @@ -1715,9 +1712,9 @@ test_circuitpadding_conditions(void *arg) monotime_init(); monotime_enable_test_mocking(); - monotime_set_mock_time_nsec(1*NSEC_PER_USEC); - monotime_coarse_set_mock_time_nsec(1*NSEC_PER_USEC); - curr_mocked_time = 1*NSEC_PER_USEC; + monotime_set_mock_time_nsec(1*TOR_NSEC_PER_USEC); + monotime_coarse_set_mock_time_nsec(1*TOR_NSEC_PER_USEC); + curr_mocked_time = 1*TOR_NSEC_PER_USEC; timers_initialize(); helper_create_conditional_machines(); @@ -1835,9 +1832,9 @@ test_circuitpadding_circuitsetup_machine(void *arg) monotime_init(); monotime_enable_test_mocking(); - monotime_set_mock_time_nsec(1*NSEC_PER_USEC); - monotime_coarse_set_mock_time_nsec(1*NSEC_PER_USEC); - curr_mocked_time = 1*NSEC_PER_USEC; + monotime_set_mock_time_nsec(1*TOR_NSEC_PER_USEC); + monotime_coarse_set_mock_time_nsec(1*TOR_NSEC_PER_USEC); + curr_mocked_time = 1*TOR_NSEC_PER_USEC; timers_initialize(); circpad_machines_init(); diff --git a/src/test/test_util.c b/src/test/test_util.c index b983cbb0bf..bf64cff7ef 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -19,6 +19,7 @@ #include "feature/client/transports.h" #include "lib/crypt_ops/crypto_format.h" #include "lib/crypt_ops/crypto_rand.h" +#include "lib/defs/time.h" #include "test/test.h" #include "lib/memarea/memarea.h" #include "lib/process/waitpid.h" @@ -404,7 +405,6 @@ test_util_time(void *arg) /* Assume tv_usec is an unsigned integer until proven otherwise */ #define TV_USEC_MAX UINT_MAX -#define TOR_USEC_PER_SEC 1000000 /* Overflows in the result type */ |