{
channelpadding_decision_t decision;
channel_t *chans[CHANNELS_TO_TEST];
+ int64_t new_time;
(void)arg;
tor_libevent_postfork();
connection_array = smartlist_new();
monotime_init();
+ monotime_enable_test_mocking();
+ monotime_set_mock_time_nsec(1);
+ monotime_coarse_set_mock_time_nsec(1);
+
timers_initialize();
channelpadding_new_consensus_params(NULL);
}
// Wait for the timers and then kill the event loop.
- dont_stop_libevent = 1;
- dummy_nop_timer();
+ new_time = (monotime_coarse_absolute_msec()+1001)*NSEC_PER_MSEC;
+ monotime_coarse_set_mock_time_nsec(new_time);
+ monotime_set_mock_time_nsec(new_time);
+ timers_run_pending();
tt_int_op(tried_to_write_cell, OP_EQ, CHANNELS_TO_TEST);
smartlist_free(connection_array);
timers_shutdown();
+ monotime_disable_test_mocking();
channel_free_all();
return;
test_channelpadding_killonehop(void *arg)
{
channelpadding_decision_t decision;
+ int64_t new_time;
(void)arg;
tor_libevent_postfork();
routerstatus_t *relay = tor_malloc_zero(sizeof(routerstatus_t));
monotime_init();
- timers_initialize();
+ monotime_enable_test_mocking();
+ monotime_set_mock_time_nsec(1);
+ monotime_coarse_set_mock_time_nsec(1);
+ timers_initialize();
setup_mock_consensus();
setup_mock_network();
tt_int_op(decision, OP_EQ, CHANNELPADDING_PADDING_ALREADY_SCHEDULED);
// Wait for the timer
- event_base_loop(tor_libevent_get_base(), 0);
+ new_time = (monotime_coarse_absolute_msec()+101)*NSEC_PER_MSEC;
+ monotime_coarse_set_mock_time_nsec(new_time);
+ monotime_set_mock_time_nsec(new_time);
+ timers_run_pending();
tt_int_op(tried_to_write_cell, OP_EQ, 1);
tt_assert(!client_relay3->pending_padding_callback);
tt_assert(relay3_client->pending_padding_callback);
// Wait for the timer
- event_base_loop(tor_libevent_get_base(), 0);
+ new_time = (monotime_coarse_absolute_msec()+101)*NSEC_PER_MSEC;
+ monotime_coarse_set_mock_time_nsec(new_time);
+ monotime_set_mock_time_nsec(new_time);
+ timers_run_pending();
tt_int_op(tried_to_write_cell, OP_EQ, 1);
tt_assert(!client_relay3->pending_padding_callback);
tt_int_op(decision, OP_EQ, CHANNELPADDING_PADDING_ALREADY_SCHEDULED);
// Wait for the timer
- event_base_loop(tor_libevent_get_base(), 0);
+ new_time = (monotime_coarse_absolute_msec()+101)*NSEC_PER_MSEC;
+ monotime_coarse_set_mock_time_nsec(new_time);
+ monotime_set_mock_time_nsec(new_time);
+ timers_run_pending();
tt_int_op(tried_to_write_cell, OP_EQ, 1);
tt_assert(!client_relay3->pending_padding_callback);
tt_assert(relay3_client->pending_padding_callback);
// Wait for the timer
- event_base_loop(tor_libevent_get_base(), 0);
+ new_time = (monotime_coarse_absolute_msec()+101)*NSEC_PER_MSEC;
+ monotime_coarse_set_mock_time_nsec(new_time);
+ monotime_set_mock_time_nsec(new_time);
+ timers_run_pending();
tt_int_op(tried_to_write_cell, OP_EQ, 1);
tt_assert(!client_relay3->pending_padding_callback);
tor_free(relay);
timers_shutdown();
+ monotime_disable_test_mocking();
channel_free_all();
}
* 4. Test channelpadding_reduced_padding
*/
monotime_init();
+ monotime_enable_test_mocking();
+ monotime_set_mock_time_nsec(1);
+ monotime_coarse_set_mock_time_nsec(1);
timers_initialize();
setup_mock_consensus();
setup_mock_network();
free_mock_consensus();
timers_shutdown();
+ monotime_disable_test_mocking();
channel_free_all();
return;