summaryrefslogtreecommitdiff
path: root/auto_tests
diff options
context:
space:
mode:
authorGregory Mullen (grayhatter) <greg@grayhatter.com>2016-08-22 14:44:58 -0700
committerGregory Mullen (grayhatter) <greg@grayhatter.com>2016-09-06 02:22:04 -0700
commitaad1e0ad3f96786e0fb10d8dd144e5e6ebe93258 (patch)
tree963477c57148626140286ac278369ef3af60811f /auto_tests
parente7d3a1a665d1204d15b00fdbe6716b43d8ef3b4a (diff)
Make friend requests stateless
Messenger is slightly twisty when it comes to sending connection status callbacks It will very likely need at the very least a partial refactor to clean it up a bit. Toxcore shouldn't need void *userdata as deep as is currently does. (amend 1) Because of the nature of toxcore connection callbacks, I decided to change this commit from statelessness for connections changes to statelessness for friend requests. It's simpler this was and doesn't include doing anything foolish in the time between commits. group fixup because grayhatter doesn't want to do it "arguably correct" is not how you write security sensitive code Clear a compiler warning about types within a function.
Diffstat (limited to 'auto_tests')
-rw-r--r--auto_tests/TCP_test.c2
-rw-r--r--auto_tests/encryptsave_test.c2
-rw-r--r--auto_tests/onion_test.c2
-rw-r--r--auto_tests/tox_test.c18
-rw-r--r--auto_tests/toxav_basic_test.c2
-rw-r--r--auto_tests/toxav_many_test.c2
6 files changed, 14 insertions, 14 deletions
diff --git a/auto_tests/TCP_test.c b/auto_tests/TCP_test.c
index 4c26926f..8e6adf2e 100644
--- a/auto_tests/TCP_test.c
+++ b/auto_tests/TCP_test.c
@@ -633,7 +633,7 @@ END_TEST
633 633
634_Bool tcp_oobdata_callback_called; 634_Bool tcp_oobdata_callback_called;
635static int tcp_oobdata_callback(void *object, const uint8_t *public_key, unsigned int id, const uint8_t *data, 635static int tcp_oobdata_callback(void *object, const uint8_t *public_key, unsigned int id, const uint8_t *data,
636 uint16_t length) 636 uint16_t length, void *userdata)
637{ 637{
638 if (length != 6) { 638 if (length != 6) {
639 return -1; 639 return -1;
diff --git a/auto_tests/encryptsave_test.c b/auto_tests/encryptsave_test.c
index 99a5792e..02a29016 100644
--- a/auto_tests/encryptsave_test.c
+++ b/auto_tests/encryptsave_test.c
@@ -60,7 +60,7 @@ START_TEST(test_save_friend)
60 Tox *tox2 = tox_new(0, 0); 60 Tox *tox2 = tox_new(0, 0);
61 ck_assert_msg(tox1 || tox2, "Failed to create 2 tox instances"); 61 ck_assert_msg(tox1 || tox2, "Failed to create 2 tox instances");
62 uint32_t to_compare = 974536; 62 uint32_t to_compare = 974536;
63 tox_callback_friend_request(tox2, accept_friend_request, &to_compare); 63 tox_callback_friend_request(tox2, accept_friend_request);
64 uint8_t address[TOX_ADDRESS_SIZE]; 64 uint8_t address[TOX_ADDRESS_SIZE];
65 tox_self_get_address(tox2, address); 65 tox_self_get_address(tox2, address);
66 uint32_t test = tox_friend_add(tox1, address, (uint8_t *)"Gentoo", 7, 0); 66 uint32_t test = tox_friend_add(tox1, address, (uint8_t *)"Gentoo", 7, 0);
diff --git a/auto_tests/onion_test.c b/auto_tests/onion_test.c
index b12c6a3f..58fde2d6 100644
--- a/auto_tests/onion_test.c
+++ b/auto_tests/onion_test.c
@@ -342,7 +342,7 @@ _Bool first, last;
342uint8_t first_dht_pk[crypto_box_PUBLICKEYBYTES]; 342uint8_t first_dht_pk[crypto_box_PUBLICKEYBYTES];
343uint8_t last_dht_pk[crypto_box_PUBLICKEYBYTES]; 343uint8_t last_dht_pk[crypto_box_PUBLICKEYBYTES];
344 344
345static void dht_pk_callback(void *object, int32_t number, const uint8_t *dht_public_key) 345static void dht_pk_callback(void *object, int32_t number, const uint8_t *dht_public_key, void *userdata)
346{ 346{
347 if ((NUM_FIRST == number && !first) || (NUM_LAST == number && !last)) { 347 if ((NUM_FIRST == number && !first) || (NUM_LAST == number && !last)) {
348 Onions *on = object; 348 Onions *on = object;
diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c
index db36e2b1..c7ba45cd 100644
--- a/auto_tests/tox_test.c
+++ b/auto_tests/tox_test.c
@@ -462,7 +462,7 @@ START_TEST(test_few_clients)
462 uint32_t to_compare = 974536; 462 uint32_t to_compare = 974536;
463 connected_t1 = 0; 463 connected_t1 = 0;
464 tox_callback_self_connection_status(tox1, tox_connection_status); 464 tox_callback_self_connection_status(tox1, tox_connection_status);
465 tox_callback_friend_request(tox2, accept_friend_request, &to_compare); 465 tox_callback_friend_request(tox2, accept_friend_request);
466 uint8_t address[TOX_ADDRESS_SIZE]; 466 uint8_t address[TOX_ADDRESS_SIZE];
467 tox_self_get_address(tox2, address); 467 tox_self_get_address(tox2, address);
468 uint32_t test = tox_friend_add(tox3, address, (uint8_t *)"Gentoo", 7, 0); 468 uint32_t test = tox_friend_add(tox3, address, (uint8_t *)"Gentoo", 7, 0);
@@ -849,7 +849,7 @@ START_TEST(test_many_clients)
849 for (i = 0; i < NUM_TOXES; ++i) { 849 for (i = 0; i < NUM_TOXES; ++i) {
850 toxes[i] = tox_new(0, 0); 850 toxes[i] = tox_new(0, 0);
851 ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); 851 ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i);
852 tox_callback_friend_request(toxes[i], accept_friend_request, &to_comp); 852 tox_callback_friend_request(toxes[i], accept_friend_request);
853 } 853 }
854 854
855 { 855 {
@@ -918,7 +918,7 @@ loop_top:
918 } 918 }
919 919
920 for (i = 0; i < NUM_TOXES; ++i) { 920 for (i = 0; i < NUM_TOXES; ++i) {
921 tox_iterate(toxes[i], NULL); 921 tox_iterate(toxes[i], &to_comp);
922 } 922 }
923 923
924 c_sleep(50); 924 c_sleep(50);
@@ -954,7 +954,7 @@ START_TEST(test_many_clients_tcp)
954 954
955 toxes[i] = tox_new(&opts, 0); 955 toxes[i] = tox_new(&opts, 0);
956 ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); 956 ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i);
957 tox_callback_friend_request(toxes[i], accept_friend_request, &to_comp); 957 tox_callback_friend_request(toxes[i], accept_friend_request);
958 uint8_t dpk[TOX_PUBLIC_KEY_SIZE]; 958 uint8_t dpk[TOX_PUBLIC_KEY_SIZE];
959 tox_self_get_dht_id(toxes[0], dpk); 959 tox_self_get_dht_id(toxes[0], dpk);
960 TOX_ERR_BOOTSTRAP error = 0; 960 TOX_ERR_BOOTSTRAP error = 0;
@@ -1018,7 +1018,7 @@ loop_top:
1018 } 1018 }
1019 1019
1020 for (i = 0; i < NUM_TOXES_TCP; ++i) { 1020 for (i = 0; i < NUM_TOXES_TCP; ++i) {
1021 tox_iterate(toxes[i], NULL); 1021 tox_iterate(toxes[i], &to_comp);
1022 } 1022 }
1023 1023
1024 c_sleep(50); 1024 c_sleep(50);
@@ -1053,7 +1053,7 @@ START_TEST(test_many_clients_tcp_b)
1053 1053
1054 toxes[i] = tox_new(&opts, 0); 1054 toxes[i] = tox_new(&opts, 0);
1055 ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); 1055 ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i);
1056 tox_callback_friend_request(toxes[i], accept_friend_request, &to_comp); 1056 tox_callback_friend_request(toxes[i], accept_friend_request);
1057 uint8_t dpk[TOX_PUBLIC_KEY_SIZE]; 1057 uint8_t dpk[TOX_PUBLIC_KEY_SIZE];
1058 tox_self_get_dht_id(toxes[(i % NUM_TCP_RELAYS)], dpk); 1058 tox_self_get_dht_id(toxes[(i % NUM_TCP_RELAYS)], dpk);
1059 ck_assert_msg(tox_add_tcp_relay(toxes[i], TOX_LOCALHOST, TCP_RELAY_PORT + (i % NUM_TCP_RELAYS), dpk, 0), 1059 ck_assert_msg(tox_add_tcp_relay(toxes[i], TOX_LOCALHOST, TCP_RELAY_PORT + (i % NUM_TCP_RELAYS), dpk, 0),
@@ -1117,7 +1117,7 @@ loop_top:
1117 } 1117 }
1118 1118
1119 for (i = 0; i < NUM_TOXES_TCP; ++i) { 1119 for (i = 0; i < NUM_TOXES_TCP; ++i) {
1120 tox_iterate(toxes[i], NULL); 1120 tox_iterate(toxes[i], &to_comp);
1121 } 1121 }
1122 1122
1123 c_sleep(30); 1123 c_sleep(30);
@@ -1200,7 +1200,7 @@ group_test_restart:
1200 for (i = 0; i < NUM_GROUP_TOX; ++i) { 1200 for (i = 0; i < NUM_GROUP_TOX; ++i) {
1201 toxes[i] = tox_new(0, 0); 1201 toxes[i] = tox_new(0, 0);
1202 ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); 1202 ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i);
1203 tox_callback_friend_request(toxes[i], &g_accept_friend_request, &to_comp); 1203 tox_callback_friend_request(toxes[i], &g_accept_friend_request);
1204 tox_callback_group_invite(toxes[i], &print_group_invite_callback, &to_comp); 1204 tox_callback_group_invite(toxes[i], &print_group_invite_callback, &to_comp);
1205 } 1205 }
1206 1206
@@ -1231,7 +1231,7 @@ group_test_restart:
1231 } 1231 }
1232 1232
1233 for (i = 0; i < NUM_GROUP_TOX; ++i) { 1233 for (i = 0; i < NUM_GROUP_TOX; ++i) {
1234 tox_iterate(toxes[i], NULL); 1234 tox_iterate(toxes[i], &to_comp);
1235 } 1235 }
1236 1236
1237 c_sleep(25); 1237 c_sleep(25);
diff --git a/auto_tests/toxav_basic_test.c b/auto_tests/toxav_basic_test.c
index 2540f592..e3c4447e 100644
--- a/auto_tests/toxav_basic_test.c
+++ b/auto_tests/toxav_basic_test.c
@@ -171,7 +171,7 @@ START_TEST(test_AV_flows)
171 uint32_t to_compare = 974536; 171 uint32_t to_compare = 974536;
172 uint8_t address[TOX_ADDRESS_SIZE]; 172 uint8_t address[TOX_ADDRESS_SIZE];
173 173
174 tox_callback_friend_request(Alice, t_accept_friend_request_cb, &to_compare); 174 tox_callback_friend_request(Alice, t_accept_friend_request_cb);
175 tox_self_get_address(Alice, address); 175 tox_self_get_address(Alice, address);
176 176
177 177
diff --git a/auto_tests/toxav_many_test.c b/auto_tests/toxav_many_test.c
index e3476512..9a58e648 100644
--- a/auto_tests/toxav_many_test.c
+++ b/auto_tests/toxav_many_test.c
@@ -237,7 +237,7 @@ START_TEST(test_AV_three_calls)
237 uint32_t to_compare = 974536; 237 uint32_t to_compare = 974536;
238 uint8_t address[TOX_ADDRESS_SIZE]; 238 uint8_t address[TOX_ADDRESS_SIZE];
239 239
240 tox_callback_friend_request(Alice, t_accept_friend_request_cb, &to_compare); 240 tox_callback_friend_request(Alice, t_accept_friend_request_cb);
241 tox_self_get_address(Alice, address); 241 tox_self_get_address(Alice, address);
242 242
243 243