diff options
Diffstat (limited to 'auto_tests')
-rw-r--r-- | auto_tests/messenger_test.c | 13 | ||||
-rw-r--r-- | auto_tests/onion_test.c | 36 |
2 files changed, 30 insertions, 19 deletions
diff --git a/auto_tests/messenger_test.c b/auto_tests/messenger_test.c index 5c8e242e..0393e6d9 100644 --- a/auto_tests/messenger_test.c +++ b/auto_tests/messenger_test.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include "config.h" | 14 | #include "config.h" |
15 | #endif | 15 | #endif |
16 | 16 | ||
17 | #include "../testing/misc_tools.c" // hex_string_to_bin | ||
17 | #include "../toxcore/Messenger.h" | 18 | #include "../toxcore/Messenger.h" |
18 | #include "../toxcore/Lossless_UDP.h" | 19 | #include "../toxcore/Lossless_UDP.h" |
19 | #include <sys/types.h> | 20 | #include <sys/types.h> |
@@ -41,18 +42,6 @@ int friend_id_num = 0; | |||
41 | 42 | ||
42 | Messenger *m; | 43 | Messenger *m; |
43 | 44 | ||
44 | unsigned char *hex_string_to_bin(char hex_string[]) | ||
45 | { | ||
46 | size_t i, len = strlen(hex_string); | ||
47 | unsigned char *val = calloc(1, len); | ||
48 | char *pos = hex_string; | ||
49 | |||
50 | for (i = 0; i < len; ++i, pos += 2) | ||
51 | sscanf(pos, "%2hhx", &val[i]); | ||
52 | |||
53 | return val; | ||
54 | } | ||
55 | |||
56 | START_TEST(test_m_sendmesage) | 45 | START_TEST(test_m_sendmesage) |
57 | { | 46 | { |
58 | char *message = "h-hi :3"; | 47 | char *message = "h-hi :3"; |
diff --git a/auto_tests/onion_test.c b/auto_tests/onion_test.c index 73f69744..1a458f65 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[27]->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[27]->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[27]->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[27]->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, 200); |
313 | return s; | 335 | return s; |
314 | } | 336 | } |
315 | 337 | ||