diff options
author | mannol <eniz_vukovic@hotmail.com> | 2014-02-01 12:44:08 +0100 |
---|---|---|
committer | mannol <eniz_vukovic@hotmail.com> | 2014-02-01 12:44:08 +0100 |
commit | 984c564cba528328b134578a93a3795a0e0436f3 (patch) | |
tree | 107e1fe071f9861c873a52c953e55fffce4f3aa3 /auto_tests/onion_test.c | |
parent | 88f97078a2700e1a988a225f8b25be0b2e80949a (diff) | |
parent | d5c005f02462b996c067d7ed4f1ef71bbd4e5dd2 (diff) |
Added fixes to rtp and updated phone
Diffstat (limited to 'auto_tests/onion_test.c')
-rw-r--r-- | auto_tests/onion_test.c | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/auto_tests/onion_test.c b/auto_tests/onion_test.c index 4dae2136..73f69744 100644 --- a/auto_tests/onion_test.c +++ b/auto_tests/onion_test.c | |||
@@ -11,6 +11,7 @@ | |||
11 | 11 | ||
12 | #include "../toxcore/onion.h" | 12 | #include "../toxcore/onion.h" |
13 | #include "../toxcore/onion_announce.h" | 13 | #include "../toxcore/onion_announce.h" |
14 | #include "../toxcore/onion_client.h" | ||
14 | #include "../toxcore/util.h" | 15 | #include "../toxcore/util.h" |
15 | 16 | ||
16 | #if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) | 17 | #if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) |
@@ -218,6 +219,7 @@ END_TEST | |||
218 | typedef struct { | 219 | typedef struct { |
219 | Onion *onion; | 220 | Onion *onion; |
220 | Onion_Announce *onion_a; | 221 | Onion_Announce *onion_a; |
222 | Onion_Client *onion_c; | ||
221 | } Onions; | 223 | } Onions; |
222 | 224 | ||
223 | Onions *new_onions(uint16_t port) | 225 | Onions *new_onions(uint16_t port) |
@@ -229,14 +231,22 @@ Onions *new_onions(uint16_t port) | |||
229 | DHT *dht = new_DHT(new_net_crypto(new_networking(ip, port))); | 231 | DHT *dht = new_DHT(new_net_crypto(new_networking(ip, port))); |
230 | on->onion = new_onion(dht); | 232 | on->onion = new_onion(dht); |
231 | on->onion_a = new_onion_announce(dht); | 233 | on->onion_a = new_onion_announce(dht); |
234 | on->onion_c = new_onion_client(dht); | ||
232 | 235 | ||
233 | if (on->onion && on->onion_a) | 236 | if (on->onion && on->onion_a && on->onion_c) |
234 | return on; | 237 | return on; |
235 | 238 | ||
236 | return NULL; | 239 | return NULL; |
237 | } | 240 | } |
238 | 241 | ||
239 | #define NUM_ONIONS 64 | 242 | void do_onions(Onions *on) |
243 | { | ||
244 | networking_poll(on->onion->net); | ||
245 | do_DHT(on->onion->dht); | ||
246 | do_onion_client(on->onion_c); | ||
247 | } | ||
248 | |||
249 | #define NUM_ONIONS 50 | ||
240 | 250 | ||
241 | START_TEST(test_announce) | 251 | START_TEST(test_announce) |
242 | { | 252 | { |
@@ -248,7 +258,41 @@ START_TEST(test_announce) | |||
248 | ck_assert_msg(onions[i] != 0, "Failed to create onions. %u"); | 258 | ck_assert_msg(onions[i] != 0, "Failed to create onions. %u"); |
249 | } | 259 | } |
250 | 260 | ||
261 | IP ip; | ||
262 | ip_init(&ip, 1); | ||
263 | ip.ip6.uint8[15] = 1; | ||
264 | |||
265 | for (i = 1; i < NUM_ONIONS; ++i) { | ||
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); | ||
268 | } | ||
269 | |||
270 | uint32_t connected = 0; | ||
251 | 271 | ||
272 | while (connected != NUM_ONIONS) { | ||
273 | connected = 0; | ||
274 | |||
275 | for (i = 0; i < NUM_ONIONS; ++i) { | ||
276 | do_onions(onions[i]); | ||
277 | connected += DHT_isconnected(onions[i]->onion->dht); | ||
278 | } | ||
279 | } | ||
280 | |||
281 | onion_addfriend(onions[7]->onion_c, onions[23]->onion->dht->c->self_public_key); | ||
282 | int frnum = onion_addfriend(onions[23]->onion_c, onions[7]->onion->dht->c->self_public_key); | ||
283 | |||
284 | uint32_t ok = 0; | ||
285 | |||
286 | while (ok != 1) { | ||
287 | for (i = 0; i < NUM_ONIONS; ++i) { | ||
288 | do_onions(onions[i]); | ||
289 | } | ||
290 | |||
291 | IP_Port ip_port; | ||
292 | ok = onion_getfriendip(onions[23]->onion_c, frnum, &ip_port); | ||
293 | |||
294 | c_sleep(50); | ||
295 | } | ||
252 | } | 296 | } |
253 | END_TEST | 297 | END_TEST |
254 | 298 | ||
@@ -265,7 +309,7 @@ Suite *onion_suite(void) | |||
265 | Suite *s = suite_create("Onion"); | 309 | Suite *s = suite_create("Onion"); |
266 | 310 | ||
267 | DEFTESTCASE_SLOW(basic, 5); | 311 | DEFTESTCASE_SLOW(basic, 5); |
268 | DEFTESTCASE_SLOW(announce, 5); | 312 | DEFTESTCASE_SLOW(announce, 80); |
269 | return s; | 313 | return s; |
270 | } | 314 | } |
271 | 315 | ||