summaryrefslogtreecommitdiff
path: root/auto_tests
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2014-12-05 22:37:02 -0500
committerirungentoo <irungentoo@gmail.com>2014-12-05 22:37:02 -0500
commit422f228921ca77b8a7c7ef1f1c4d95797d4ad0aa (patch)
tree10ca43eee8124b875a0a4e375ec897d81f44efda /auto_tests
parent51121569531b504de6dc21303453f960b199ac56 (diff)
Test now works with large groups.
Diffstat (limited to 'auto_tests')
-rw-r--r--auto_tests/tox_test.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c
index b1a314f2..65364ea8 100644
--- a/auto_tests/tox_test.c
+++ b/auto_tests/tox_test.c
@@ -430,7 +430,7 @@ loop_top:
430} 430}
431END_TEST 431END_TEST
432 432
433#define NUM_GROUP_TOX 6 433#define NUM_GROUP_TOX 32
434 434
435void g_accept_friend_request(Tox *m, const uint8_t *public_key, const uint8_t *data, uint16_t length, void *userdata) 435void g_accept_friend_request(Tox *m, const uint8_t *public_key, const uint8_t *data, uint16_t length, void *userdata)
436{ 436{
@@ -442,6 +442,9 @@ void g_accept_friend_request(Tox *m, const uint8_t *public_key, const uint8_t *d
442 } 442 }
443} 443}
444 444
445static Tox *invite_tox;
446static unsigned int invite_counter;
447
445void print_group_invite_callback(Tox *tox, int32_t friendnumber, uint8_t type, const uint8_t *data, uint16_t length, 448void print_group_invite_callback(Tox *tox, int32_t friendnumber, uint8_t type, const uint8_t *data, uint16_t length,
446 void *userdata) 449 void *userdata)
447{ 450{
@@ -457,8 +460,8 @@ void print_group_invite_callback(Tox *tox, int32_t friendnumber, uint8_t type, c
457 ck_assert_msg(tox_join_groupchat(tox, friendnumber, data, length) == -1, 460 ck_assert_msg(tox_join_groupchat(tox, friendnumber, data, length) == -1,
458 "Joining groupchat twice should be impossible."); 461 "Joining groupchat twice should be impossible.");
459 462
460 if (tox_invite_friend(tox, 0, g_num) == -1) 463 invite_tox = tox;
461 return; 464 invite_counter = 4;
462} 465}
463 466
464static unsigned int num_recv; 467static unsigned int num_recv;
@@ -521,24 +524,32 @@ START_TEST(test_many_group)
521 524
522 ck_assert_msg(tox_add_groupchat(toxes[0]) != -1, "Failed to create group"); 525 ck_assert_msg(tox_add_groupchat(toxes[0]) != -1, "Failed to create group");
523 ck_assert_msg(tox_invite_friend(toxes[0], 0, 0) == 0, "Failed to invite friend"); 526 ck_assert_msg(tox_invite_friend(toxes[0], 0, 0) == 0, "Failed to invite friend");
527 invite_counter = ~0;
528
529 unsigned int done = ~0;
530 done -= 5;
524 531
525 while (1) { 532 while (1) {
526 for (i = 0; i < NUM_GROUP_TOX; ++i) { 533 for (i = 0; i < NUM_GROUP_TOX; ++i) {
527 if (tox_group_number_peers(toxes[i], 0) != NUM_GROUP_TOX) { 534 tox_do(toxes[i]);
528 break;
529 }
530 } 535 }
531 536
532 if (i == NUM_GROUP_TOX) 537 if (!invite_counter) {
533 break; 538 ck_assert_msg(tox_invite_friend(invite_tox, 0, 0) == 0, "Failed to invite friend");
539 }
534 540
535 for (i = 0; i < NUM_GROUP_TOX; ++i) { 541 if (done == invite_counter) {
536 tox_do(toxes[i]); 542 break;
537 } 543 }
538 544
545 --invite_counter;
539 c_sleep(50); 546 c_sleep(50);
540 } 547 }
541 548
549 for (i = 0; i < NUM_GROUP_TOX; ++i) {
550 ck_assert_msg(tox_group_number_peers(toxes[i], 0) == NUM_GROUP_TOX, "Bad number of group peers.");
551 }
552
542 printf("group connected\n"); 553 printf("group connected\n");
543 554
544 for (i = 0; i < NUM_GROUP_TOX; ++i) { 555 for (i = 0; i < NUM_GROUP_TOX; ++i) {