diff options
Diffstat (limited to 'auto_tests/tox_test.c')
-rw-r--r-- | auto_tests/tox_test.c | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c index 40022b0a..501c93dc 100644 --- a/auto_tests/tox_test.c +++ b/auto_tests/tox_test.c | |||
@@ -286,8 +286,8 @@ void tox_connection_status(Tox *tox, TOX_CONNECTION connection_status, void *use | |||
286 | 286 | ||
287 | START_TEST(test_one) | 287 | START_TEST(test_one) |
288 | { | 288 | { |
289 | Tox *tox1 = tox_new(0, 0, 0, 0); | 289 | Tox *tox1 = tox_new(0, 0); |
290 | Tox *tox2 = tox_new(0, 0, 0, 0); | 290 | Tox *tox2 = tox_new(0, 0); |
291 | 291 | ||
292 | { | 292 | { |
293 | TOX_ERR_GET_PORT error; | 293 | TOX_ERR_GET_PORT error; |
@@ -340,7 +340,12 @@ START_TEST(test_one) | |||
340 | tox_kill(tox2); | 340 | tox_kill(tox2); |
341 | TOX_ERR_NEW err_n; | 341 | TOX_ERR_NEW err_n; |
342 | 342 | ||
343 | tox2 = tox_new(0, data, save_size, &err_n); | 343 | struct Tox_Options options; |
344 | tox_options_default(&options); | ||
345 | options.savedata_type = TOX_SAVEDATA_TYPE_TOX_SAVE; | ||
346 | options.savedata_data = data; | ||
347 | options.savedata_length = save_size; | ||
348 | tox2 = tox_new(&options, &err_n); | ||
344 | ck_assert_msg(err_n == TOX_ERR_NEW_OK, "Load failed"); | 349 | ck_assert_msg(err_n == TOX_ERR_NEW_OK, "Load failed"); |
345 | 350 | ||
346 | ck_assert_msg(tox_self_get_name_size(tox2) == sizeof name, "Wrong name size."); | 351 | ck_assert_msg(tox_self_get_name_size(tox2) == sizeof name, "Wrong name size."); |
@@ -352,6 +357,23 @@ START_TEST(test_one) | |||
352 | tox_self_get_name(tox2, new_name); | 357 | tox_self_get_name(tox2, new_name); |
353 | ck_assert_msg(memcmp(name, new_name, TOX_MAX_NAME_LENGTH) == 0, "Wrong name"); | 358 | ck_assert_msg(memcmp(name, new_name, TOX_MAX_NAME_LENGTH) == 0, "Wrong name"); |
354 | 359 | ||
360 | uint8_t sk[TOX_SECRET_KEY_SIZE]; | ||
361 | tox_self_get_secret_key(tox2, sk); | ||
362 | tox_kill(tox2); | ||
363 | |||
364 | tox_options_default(&options); | ||
365 | options.savedata_type = TOX_SAVEDATA_TYPE_SECRET_KEY; | ||
366 | options.savedata_data = sk; | ||
367 | options.savedata_length = sizeof(sk); | ||
368 | tox2 = tox_new(&options, &err_n); | ||
369 | ck_assert_msg(err_n == TOX_ERR_NEW_OK, "Load failed"); | ||
370 | uint8_t address3[TOX_ADDRESS_SIZE]; | ||
371 | tox_self_get_address(tox2, address3); | ||
372 | ck_assert_msg(memcmp(address3, address, TOX_PUBLIC_KEY_SIZE) == 0, "Wrong public key."); | ||
373 | uint8_t pk[TOX_PUBLIC_KEY_SIZE]; | ||
374 | tox_self_get_public_key(tox2, pk); | ||
375 | ck_assert_msg(memcmp(pk, address, TOX_PUBLIC_KEY_SIZE) == 0, "Wrong public key."); | ||
376 | |||
355 | tox_kill(tox1); | 377 | tox_kill(tox1); |
356 | tox_kill(tox2); | 378 | tox_kill(tox2); |
357 | } | 379 | } |
@@ -361,11 +383,11 @@ START_TEST(test_few_clients) | |||
361 | { | 383 | { |
362 | long long unsigned int con_time, cur_time = time(NULL); | 384 | long long unsigned int con_time, cur_time = time(NULL); |
363 | TOX_ERR_NEW t_n_error; | 385 | TOX_ERR_NEW t_n_error; |
364 | Tox *tox1 = tox_new(0, 0, 0, &t_n_error); | 386 | Tox *tox1 = tox_new(0, &t_n_error); |
365 | ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error"); | 387 | ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error"); |
366 | Tox *tox2 = tox_new(0, 0, 0, &t_n_error); | 388 | Tox *tox2 = tox_new(0, &t_n_error); |
367 | ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error"); | 389 | ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error"); |
368 | Tox *tox3 = tox_new(0, 0, 0, &t_n_error); | 390 | Tox *tox3 = tox_new(0, &t_n_error); |
369 | ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error"); | 391 | ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error"); |
370 | 392 | ||
371 | ck_assert_msg(tox1 || tox2 || tox3, "Failed to create 3 tox instances"); | 393 | ck_assert_msg(tox1 || tox2 || tox3, "Failed to create 3 tox instances"); |
@@ -745,7 +767,7 @@ START_TEST(test_many_clients) | |||
745 | uint32_t to_comp = 974536; | 767 | uint32_t to_comp = 974536; |
746 | 768 | ||
747 | for (i = 0; i < NUM_TOXES; ++i) { | 769 | for (i = 0; i < NUM_TOXES; ++i) { |
748 | toxes[i] = tox_new(0, 0, 0, 0); | 770 | toxes[i] = tox_new(0, 0); |
749 | ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); | 771 | ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); |
750 | tox_callback_friend_request(toxes[i], accept_friend_request, &to_comp); | 772 | tox_callback_friend_request(toxes[i], accept_friend_request, &to_comp); |
751 | } | 773 | } |
@@ -832,7 +854,7 @@ START_TEST(test_many_clients_tcp) | |||
832 | opts.udp_enabled = 0; | 854 | opts.udp_enabled = 0; |
833 | } | 855 | } |
834 | 856 | ||
835 | toxes[i] = tox_new(&opts, 0, 0, 0); | 857 | toxes[i] = tox_new(&opts, 0); |
836 | ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); | 858 | ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); |
837 | tox_callback_friend_request(toxes[i], accept_friend_request, &to_comp); | 859 | tox_callback_friend_request(toxes[i], accept_friend_request, &to_comp); |
838 | uint8_t dpk[TOX_PUBLIC_KEY_SIZE]; | 860 | uint8_t dpk[TOX_PUBLIC_KEY_SIZE]; |
@@ -926,7 +948,7 @@ START_TEST(test_many_clients_tcp_b) | |||
926 | opts.udp_enabled = 0; | 948 | opts.udp_enabled = 0; |
927 | } | 949 | } |
928 | 950 | ||
929 | toxes[i] = tox_new(&opts, 0, 0, 0); | 951 | toxes[i] = tox_new(&opts, 0); |
930 | ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); | 952 | ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); |
931 | tox_callback_friend_request(toxes[i], accept_friend_request, &to_comp); | 953 | tox_callback_friend_request(toxes[i], accept_friend_request, &to_comp); |
932 | uint8_t dpk[TOX_PUBLIC_KEY_SIZE]; | 954 | uint8_t dpk[TOX_PUBLIC_KEY_SIZE]; |
@@ -1062,7 +1084,7 @@ START_TEST(test_many_group) | |||
1062 | uint32_t to_comp = 234212; | 1084 | uint32_t to_comp = 234212; |
1063 | 1085 | ||
1064 | for (i = 0; i < NUM_GROUP_TOX; ++i) { | 1086 | for (i = 0; i < NUM_GROUP_TOX; ++i) { |
1065 | toxes[i] = tox_new(0, 0, 0, 0); | 1087 | toxes[i] = tox_new(0, 0); |
1066 | ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); | 1088 | ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); |
1067 | tox_callback_friend_request(toxes[i], &g_accept_friend_request, &to_comp); | 1089 | tox_callback_friend_request(toxes[i], &g_accept_friend_request, &to_comp); |
1068 | tox_callback_group_invite(toxes[i], &print_group_invite_callback, &to_comp); | 1090 | tox_callback_group_invite(toxes[i], &print_group_invite_callback, &to_comp); |
@@ -1189,7 +1211,7 @@ Suite *tox_suite(void) | |||
1189 | 1211 | ||
1190 | DEFTESTCASE(one); | 1212 | DEFTESTCASE(one); |
1191 | DEFTESTCASE_SLOW(few_clients, 50); | 1213 | DEFTESTCASE_SLOW(few_clients, 50); |
1192 | DEFTESTCASE_SLOW(many_clients, 150); | 1214 | DEFTESTCASE_SLOW(many_clients, 80); |
1193 | DEFTESTCASE_SLOW(many_clients_tcp, 20); | 1215 | DEFTESTCASE_SLOW(many_clients_tcp, 20); |
1194 | DEFTESTCASE_SLOW(many_clients_tcp_b, 20); | 1216 | DEFTESTCASE_SLOW(many_clients_tcp_b, 20); |
1195 | DEFTESTCASE_SLOW(many_group, 100); | 1217 | DEFTESTCASE_SLOW(many_group, 100); |