Onion test fixed to work with faster DHT.

This commit is contained in:
irungentoo 2015-12-15 14:58:36 -05:00
parent 836e180757
commit 9a87f03aec
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98

View File

@ -331,33 +331,35 @@ uint8_t last_dht_pk[crypto_box_PUBLICKEYBYTES];
static void dht_pk_callback(void *object, int32_t number, const uint8_t *dht_public_key) static void dht_pk_callback(void *object, int32_t number, const uint8_t *dht_public_key)
{ {
Onions *on = object; if ((NUM_FIRST == number && !first) || (NUM_LAST == number && !last)) {
uint16_t count = 0; Onions *on = object;
int ret = DHT_addfriend(on->onion->dht, dht_public_key, &dht_ip_callback, object, number, &count); uint16_t count = 0;
ck_assert_msg(count == 1, "Count not 1"); int ret = DHT_addfriend(on->onion->dht, dht_public_key, &dht_ip_callback, object, number, &count);
ck_assert_msg(ret == 0, "DHT_addfriend() did not return 0"); ck_assert_msg(ret == 0, "DHT_addfriend() did not return 0");
ck_assert_msg(count == 1, "Count not 1, count is %u", count);
if (NUM_FIRST == number && !first) { if (NUM_FIRST == number && !first) {
first = 1; first = 1;
if (memcmp(dht_public_key, last_dht_pk, crypto_box_PUBLICKEYBYTES) != 0) { if (memcmp(dht_public_key, last_dht_pk, crypto_box_PUBLICKEYBYTES) != 0) {
ck_abort_msg("Error wrong dht key."); ck_abort_msg("Error wrong dht key.");
}
return;
} }
return; if (NUM_LAST == number && !last) {
} last = 1;
if (NUM_LAST == number && !last) { if (memcmp(dht_public_key, first_dht_pk, crypto_box_PUBLICKEYBYTES) != 0) {
last = 1; ck_abort_msg("Error wrong dht key.");
}
if (memcmp(dht_public_key, first_dht_pk, crypto_box_PUBLICKEYBYTES) != 0) { return;
ck_abort_msg("Error wrong dht key.");
} }
return; ck_abort_msg("Error.");
} }
ck_abort_msg("Error.");
} }
START_TEST(test_announce) START_TEST(test_announce)