diff options
-rw-r--r-- | auto_tests/onion_test.c | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/auto_tests/onion_test.c b/auto_tests/onion_test.c index 73f69744..e1d2baba 100644 --- a/auto_tests/onion_test.c +++ b/auto_tests/onion_test.c | |||
@@ -262,9 +262,13 @@ START_TEST(test_announce) | |||
262 | ip_init(&ip, 1); | 262 | ip_init(&ip, 1); |
263 | ip.ip6.uint8[15] = 1; | 263 | ip.ip6.uint8[15] = 1; |
264 | 264 | ||
265 | for (i = 1; i < NUM_ONIONS; ++i) { | 265 | for (i = 3; i < NUM_ONIONS; ++i) { |
266 | IP_Port ip_port = {ip, onions[i - 1]->onion->net->port}; | 266 | IP_Port ip_port = {ip, onions[i - 1]->onion->net->port}; |
267 | DHT_bootstrap(onions[i]->onion->dht, ip_port, onions[i - 1]->onion->dht->self_public_key); | 267 | DHT_bootstrap(onions[i]->onion->dht, ip_port, onions[i - 1]->onion->dht->self_public_key); |
268 | IP_Port ip_port1 = {ip, onions[i - 2]->onion->net->port}; | ||
269 | DHT_bootstrap(onions[i]->onion->dht, ip_port1, onions[i - 2]->onion->dht->self_public_key); | ||
270 | IP_Port ip_port2 = {ip, onions[i - 3]->onion->net->port}; | ||
271 | DHT_bootstrap(onions[i]->onion->dht, ip_port2, onions[i - 3]->onion->dht->self_public_key); | ||
268 | } | 272 | } |
269 | 273 | ||
270 | uint32_t connected = 0; | 274 | uint32_t connected = 0; |
@@ -276,23 +280,41 @@ START_TEST(test_announce) | |||
276 | do_onions(onions[i]); | 280 | do_onions(onions[i]); |
277 | connected += DHT_isconnected(onions[i]->onion->dht); | 281 | connected += DHT_isconnected(onions[i]->onion->dht); |
278 | } | 282 | } |
283 | |||
284 | c_sleep(50); | ||
279 | } | 285 | } |
280 | 286 | ||
281 | onion_addfriend(onions[7]->onion_c, onions[23]->onion->dht->c->self_public_key); | 287 | onion_addfriend(onions[7]->onion_c, onions[33]->onion->dht->c->self_public_key); |
282 | int frnum = onion_addfriend(onions[23]->onion_c, onions[7]->onion->dht->c->self_public_key); | 288 | int frnum = onion_addfriend(onions[33]->onion_c, onions[7]->onion->dht->c->self_public_key); |
289 | |||
290 | int ok = -1; | ||
291 | |||
292 | IP_Port ip_port; | ||
293 | |||
294 | while (ok == -1) { | ||
295 | for (i = 0; i < NUM_ONIONS; ++i) { | ||
296 | networking_poll(onions[i]->onion->net); | ||
297 | do_onion_client(onions[i]->onion_c); | ||
298 | } | ||
299 | |||
300 | ok = onion_getfriendip(onions[33]->onion_c, frnum, &ip_port); | ||
301 | |||
302 | c_sleep(50); | ||
303 | } | ||
283 | 304 | ||
284 | uint32_t ok = 0; | 305 | printf("id discovered\n"); |
285 | 306 | ||
286 | while (ok != 1) { | 307 | while (ok != 1) { |
287 | for (i = 0; i < NUM_ONIONS; ++i) { | 308 | for (i = 0; i < NUM_ONIONS; ++i) { |
288 | do_onions(onions[i]); | 309 | do_onions(onions[i]); |
289 | } | 310 | } |
290 | 311 | ||
291 | IP_Port ip_port; | 312 | ok = onion_getfriendip(onions[33]->onion_c, frnum, &ip_port); |
292 | ok = onion_getfriendip(onions[23]->onion_c, frnum, &ip_port); | ||
293 | 313 | ||
294 | c_sleep(50); | 314 | c_sleep(50); |
295 | } | 315 | } |
316 | |||
317 | ck_assert_msg(ip_port.port == onions[7]->onion->net->port, "Port in returned ip not correct."); | ||
296 | } | 318 | } |
297 | END_TEST | 319 | END_TEST |
298 | 320 | ||
@@ -309,7 +331,7 @@ Suite *onion_suite(void) | |||
309 | Suite *s = suite_create("Onion"); | 331 | Suite *s = suite_create("Onion"); |
310 | 332 | ||
311 | DEFTESTCASE_SLOW(basic, 5); | 333 | DEFTESTCASE_SLOW(basic, 5); |
312 | DEFTESTCASE_SLOW(announce, 80); | 334 | DEFTESTCASE_SLOW(announce, 100); |
313 | return s; | 335 | return s; |
314 | } | 336 | } |
315 | 337 | ||