summaryrefslogtreecommitdiff
path: root/auto_tests/tox_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'auto_tests/tox_test.c')
-rw-r--r--auto_tests/tox_test.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c
index 7e74fba7..e8c10b7e 100644
--- a/auto_tests/tox_test.c
+++ b/auto_tests/tox_test.c
@@ -19,12 +19,13 @@
19#define c_sleep(x) usleep(1000*x) 19#define c_sleep(x) usleep(1000*x)
20#endif 20#endif
21 21
22void accept_friend_request(uint8_t *public_key, uint8_t *data, uint16_t length, void *userdata) 22void accept_friend_request(Tox *m, uint8_t *public_key, uint8_t *data, uint16_t length, void *userdata)
23{ 23{
24 Tox *t = userdata; 24 if (*((uint32_t *)userdata) != 974536)
25 return;
25 26
26 if (length == 7 && memcmp("Gentoo", data, 7) == 0) { 27 if (length == 7 && memcmp("Gentoo", data, 7) == 0) {
27 tox_add_friend_norequest(t, public_key); 28 tox_add_friend_norequest(m, public_key);
28 } 29 }
29} 30}
30uint32_t messages_received; 31uint32_t messages_received;
@@ -114,7 +115,8 @@ START_TEST(test_few_clients)
114 Tox *tox2 = tox_new(TOX_ENABLE_IPV6_DEFAULT); 115 Tox *tox2 = tox_new(TOX_ENABLE_IPV6_DEFAULT);
115 Tox *tox3 = tox_new(TOX_ENABLE_IPV6_DEFAULT); 116 Tox *tox3 = tox_new(TOX_ENABLE_IPV6_DEFAULT);
116 ck_assert_msg(tox1 || tox2 || tox3, "Failed to create 3 tox instances"); 117 ck_assert_msg(tox1 || tox2 || tox3, "Failed to create 3 tox instances");
117 tox_callback_friend_request(tox2, accept_friend_request, tox2); 118 uint32_t to_compare = 974536;
119 tox_callback_friend_request(tox2, accept_friend_request, &to_compare);
118 uint8_t address[TOX_FRIEND_ADDRESS_SIZE]; 120 uint8_t address[TOX_FRIEND_ADDRESS_SIZE];
119 tox_get_address(tox2, address); 121 tox_get_address(tox2, address);
120 int test = tox_add_friend(tox3, address, (uint8_t *)"Gentoo", 7); 122 int test = tox_add_friend(tox3, address, (uint8_t *)"Gentoo", 7);
@@ -140,7 +142,7 @@ START_TEST(test_few_clients)
140 } 142 }
141 143
142 printf("tox clients connected\n"); 144 printf("tox clients connected\n");
143 uint32_t to_compare = 974536; 145 to_compare = 974536;
144 tox_callback_friend_message(tox3, print_message, &to_compare); 146 tox_callback_friend_message(tox3, print_message, &to_compare);
145 tox_send_message(tox2, 0, (uint8_t *)"Install Gentoo", sizeof("Install Gentoo")); 147 tox_send_message(tox2, 0, (uint8_t *)"Install Gentoo", sizeof("Install Gentoo"));
146 148
@@ -267,7 +269,8 @@ START_TEST(test_many_clients)
267 for (i = 0; i < NUM_TOXES; ++i) { 269 for (i = 0; i < NUM_TOXES; ++i) {
268 toxes[i] = tox_new(TOX_ENABLE_IPV6_DEFAULT); 270 toxes[i] = tox_new(TOX_ENABLE_IPV6_DEFAULT);
269 ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); 271 ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i);
270 tox_callback_friend_request(toxes[i], accept_friend_request, toxes[i]); 272 uint32_t to_comp = 974536;
273 tox_callback_friend_request(toxes[i], accept_friend_request, &to_comp);
271 } 274 }
272 275
273 struct { 276 struct {