diff options
Diffstat (limited to 'auto_tests/dht_test.c')
-rw-r--r-- | auto_tests/dht_test.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/auto_tests/dht_test.c b/auto_tests/dht_test.c index 25316496..232b7d95 100644 --- a/auto_tests/dht_test.c +++ b/auto_tests/dht_test.c | |||
@@ -600,12 +600,18 @@ static void ip_callback(void *data, int32_t number, IP_Port ip_port) | |||
600 | 600 | ||
601 | #define NUM_DHT_FRIENDS 20 | 601 | #define NUM_DHT_FRIENDS 20 |
602 | 602 | ||
603 | static uint64_t get_clock_callback(void *user_data) | ||
604 | { | ||
605 | return *(uint64_t *)user_data; | ||
606 | } | ||
607 | |||
603 | static void test_DHT_test(void) | 608 | static void test_DHT_test(void) |
604 | { | 609 | { |
605 | uint32_t to_comp = 8394782; | 610 | uint32_t to_comp = 8394782; |
606 | DHT *dhts[NUM_DHT]; | 611 | DHT *dhts[NUM_DHT]; |
607 | Logger *logs[NUM_DHT]; | 612 | Logger *logs[NUM_DHT]; |
608 | Mono_Time *mono_times[NUM_DHT]; | 613 | Mono_Time *mono_times[NUM_DHT]; |
614 | uint64_t clock[NUM_DHT]; | ||
609 | uint32_t index[NUM_DHT]; | 615 | uint32_t index[NUM_DHT]; |
610 | 616 | ||
611 | uint32_t i, j; | 617 | uint32_t i, j; |
@@ -619,6 +625,8 @@ static void test_DHT_test(void) | |||
619 | logger_callback_log(logs[i], (logger_cb *)print_debug_log, nullptr, &index[i]); | 625 | logger_callback_log(logs[i], (logger_cb *)print_debug_log, nullptr, &index[i]); |
620 | 626 | ||
621 | mono_times[i] = mono_time_new(); | 627 | mono_times[i] = mono_time_new(); |
628 | clock[i] = current_time_monotonic(mono_times[i]); | ||
629 | mono_time_set_current_time_callback(mono_times[i], get_clock_callback, &clock[i]); | ||
622 | 630 | ||
623 | dhts[i] = new_dht(logs[i], mono_times[i], new_networking(logs[i], ip, DHT_DEFAULT_PORT + i), true); | 631 | dhts[i] = new_dht(logs[i], mono_times[i], new_networking(logs[i], ip, DHT_DEFAULT_PORT + i), true); |
624 | ck_assert_msg(dhts[i] != nullptr, "Failed to create dht instances %u", i); | 632 | ck_assert_msg(dhts[i] != nullptr, "Failed to create dht instances %u", i); |
@@ -674,9 +682,10 @@ loop_top: | |||
674 | mono_time_update(mono_times[i]); | 682 | mono_time_update(mono_times[i]); |
675 | networking_poll(dhts[i]->net, nullptr); | 683 | networking_poll(dhts[i]->net, nullptr); |
676 | do_dht(dhts[i]); | 684 | do_dht(dhts[i]); |
685 | clock[i] += 500; | ||
677 | } | 686 | } |
678 | 687 | ||
679 | c_sleep(500); | 688 | c_sleep(20); |
680 | } | 689 | } |
681 | 690 | ||
682 | for (i = 0; i < NUM_DHT; ++i) { | 691 | for (i = 0; i < NUM_DHT; ++i) { |