Skip to content

Commit 9a87f03

Browse files
committed
Onion test fixed to work with faster DHT.
1 parent 836e180 commit 9a87f03

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

auto_tests/onion_test.c

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -331,33 +331,35 @@ uint8_t last_dht_pk[crypto_box_PUBLICKEYBYTES];
331331

332332
static void dht_pk_callback(void *object, int32_t number, const uint8_t *dht_public_key)
333333
{
334-
Onions *on = object;
335-
uint16_t count = 0;
336-
int ret = DHT_addfriend(on->onion->dht, dht_public_key, &dht_ip_callback, object, number, &count);
337-
ck_assert_msg(count == 1, "Count not 1");
338-
ck_assert_msg(ret == 0, "DHT_addfriend() did not return 0");
334+
if ((NUM_FIRST == number && !first) || (NUM_LAST == number && !last)) {
335+
Onions *on = object;
336+
uint16_t count = 0;
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");
339+
ck_assert_msg(count == 1, "Count not 1, count is %u", count);
339340

340-
if (NUM_FIRST == number && !first) {
341-
first = 1;
341+
if (NUM_FIRST == number && !first) {
342+
first = 1;
342343

343-
if (memcmp(dht_public_key, last_dht_pk, crypto_box_PUBLICKEYBYTES) != 0) {
344-
ck_abort_msg("Error wrong dht key.");
344+
if (memcmp(dht_public_key, last_dht_pk, crypto_box_PUBLICKEYBYTES) != 0) {
345+
ck_abort_msg("Error wrong dht key.");
346+
}
347+
348+
return;
345349
}
346350

347-
return;
348-
}
351+
if (NUM_LAST == number && !last) {
352+
last = 1;
349353

350-
if (NUM_LAST == number && !last) {
351-
last = 1;
354+
if (memcmp(dht_public_key, first_dht_pk, crypto_box_PUBLICKEYBYTES) != 0) {
355+
ck_abort_msg("Error wrong dht key.");
356+
}
352357

353-
if (memcmp(dht_public_key, first_dht_pk, crypto_box_PUBLICKEYBYTES) != 0) {
354-
ck_abort_msg("Error wrong dht key.");
358+
return;
355359
}
356360

357-
return;
361+
ck_abort_msg("Error.");
358362
}
359-
360-
ck_abort_msg("Error.");
361363
}
362364

363365
START_TEST(test_announce)

0 commit comments

Comments
 (0)