diff options
-rw-r--r-- | auto_tests/onion_test.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/auto_tests/onion_test.c b/auto_tests/onion_test.c index 31566471..5d59ab9b 100644 --- a/auto_tests/onion_test.c +++ b/auto_tests/onion_test.c | |||
@@ -331,33 +331,35 @@ uint8_t last_dht_pk[crypto_box_PUBLICKEYBYTES]; | |||
331 | 331 | ||
332 | static void dht_pk_callback(void *object, int32_t number, const uint8_t *dht_public_key) | 332 | static void dht_pk_callback(void *object, int32_t number, const uint8_t *dht_public_key) |
333 | { | 333 | { |
334 | Onions *on = object; | 334 | if ((NUM_FIRST == number && !first) || (NUM_LAST == number && !last)) { |
335 | uint16_t count = 0; | 335 | Onions *on = object; |
336 | int ret = DHT_addfriend(on->onion->dht, dht_public_key, &dht_ip_callback, object, number, &count); | 336 | uint16_t count = 0; |
337 | ck_assert_msg(count == 1, "Count not 1"); | 337 | int ret = DHT_addfriend(on->onion->dht, dht_public_key, &dht_ip_callback, object, number, &count); |
338 | ck_assert_msg(ret == 0, "DHT_addfriend() did not return 0"); | 338 | ck_assert_msg(ret == 0, "DHT_addfriend() did not return 0"); |
339 | ck_assert_msg(count == 1, "Count not 1, count is %u", count); | ||
339 | 340 | ||
340 | if (NUM_FIRST == number && !first) { | 341 | if (NUM_FIRST == number && !first) { |
341 | first = 1; | 342 | first = 1; |
342 | 343 | ||
343 | if (memcmp(dht_public_key, last_dht_pk, crypto_box_PUBLICKEYBYTES) != 0) { | 344 | if (memcmp(dht_public_key, last_dht_pk, crypto_box_PUBLICKEYBYTES) != 0) { |
344 | ck_abort_msg("Error wrong dht key."); | 345 | ck_abort_msg("Error wrong dht key."); |
346 | } | ||
347 | |||
348 | return; | ||
345 | } | 349 | } |
346 | 350 | ||
347 | return; | 351 | if (NUM_LAST == number && !last) { |
348 | } | 352 | last = 1; |
349 | 353 | ||
350 | if (NUM_LAST == number && !last) { | 354 | if (memcmp(dht_public_key, first_dht_pk, crypto_box_PUBLICKEYBYTES) != 0) { |
351 | last = 1; | 355 | ck_abort_msg("Error wrong dht key."); |
356 | } | ||
352 | 357 | ||
353 | if (memcmp(dht_public_key, first_dht_pk, crypto_box_PUBLICKEYBYTES) != 0) { | 358 | return; |
354 | ck_abort_msg("Error wrong dht key."); | ||
355 | } | 359 | } |
356 | 360 | ||
357 | return; | 361 | ck_abort_msg("Error."); |
358 | } | 362 | } |
359 | |||
360 | ck_abort_msg("Error."); | ||
361 | } | 363 | } |
362 | 364 | ||
363 | START_TEST(test_announce) | 365 | START_TEST(test_announce) |