summaryrefslogtreecommitdiff
path: root/auto_tests
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-07-19 22:05:43 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-07-21 15:09:39 +0000
commit7c2b95ef5e4ccdae01bd104aa7400294c9ea391b (patch)
tree78cf7c6136cc65622894e8ca316f3796bcd23a6f /auto_tests
parentadb12d5340431d9de5995da37ea7aca01e675da3 (diff)
Remove redundant casts to the same type.
Also removed an unused identifier in messenger_test.c.
Diffstat (limited to 'auto_tests')
-rw-r--r--auto_tests/messenger_test.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/auto_tests/messenger_test.c b/auto_tests/messenger_test.c
index cf42de49..d7f2b9e7 100644
--- a/auto_tests/messenger_test.c
+++ b/auto_tests/messenger_test.c
@@ -36,17 +36,12 @@
36static bool enable_broken_tests = false; 36static bool enable_broken_tests = false;
37 37
38static const char *friend_id_str = "e4b3d5030bc99494605aecc33ceec8875640c1d74aa32790e821b17e98771c4a00000000f1db"; 38static const char *friend_id_str = "e4b3d5030bc99494605aecc33ceec8875640c1d74aa32790e821b17e98771c4a00000000f1db";
39static const char *good_id_str = "d3f14b6d384d8f5f2a66cff637e69f28f539c5de61bc29744785291fa4ef4d64";
40static const char *bad_id_str = "9B569D14ff637e69f2";
39 41
40/* in case we need more than one ID for a test */ 42static uint8_t *friend_id = nullptr;
41static const char *good_id_a_str = "DB9B569D14850ED8364C3744CAC2C8FF78985D213E980C7C508D0E91E8E45441"; 43static uint8_t *good_id = nullptr;
42static const char *good_id_b_str = "d3f14b6d384d8f5f2a66cff637e69f28f539c5de61bc29744785291fa4ef4d64"; 44static uint8_t *bad_id = nullptr;
43
44static const char *bad_id_str = "9B569D14ff637e69f2";
45
46static unsigned char *friend_id = nullptr;
47static unsigned char *good_id_a = nullptr;
48static unsigned char *good_id_b = nullptr;
49static unsigned char *bad_id = nullptr;
50 45
51static int friend_id_num = 0; 46static int friend_id_num = 0;
52 47
@@ -146,24 +141,24 @@ START_TEST(test_m_addfriend)
146 + crypto_box_ZEROBYTES + 100); 141 + crypto_box_ZEROBYTES + 100);
147 142
148 /* TODO(irungentoo): Update this properly to latest master */ 143 /* TODO(irungentoo): Update this properly to latest master */
149 if (m_addfriend(m, (const uint8_t *)friend_id, (const uint8_t *)good_data, really_bad_len) != FAERR_TOOLONG) { 144 if (m_addfriend(m, friend_id, (const uint8_t *)good_data, really_bad_len) != FAERR_TOOLONG) {
150 ck_abort_msg("m_addfriend did NOT catch the following length: %d\n", really_bad_len); 145 ck_abort_msg("m_addfriend did NOT catch the following length: %d\n", really_bad_len);
151 } 146 }
152 147
153 /* this will return an error if the original m_addfriend_norequest() failed */ 148 /* this will return an error if the original m_addfriend_norequest() failed */
154 if (m_addfriend(m, (const uint8_t *)friend_id, (const uint8_t *)good_data, good_len) != FAERR_ALREADYSENT) { 149 if (m_addfriend(m, friend_id, (const uint8_t *)good_data, good_len) != FAERR_ALREADYSENT) {
155 ck_abort_msg("m_addfriend did NOT catch adding a friend we already have.\n" 150 ck_abort_msg("m_addfriend did NOT catch adding a friend we already have.\n"
156 "(this can be caused by the error of m_addfriend_norequest in" 151 "(this can be caused by the error of m_addfriend_norequest in"
157 " the beginning of the suite)\n"); 152 " the beginning of the suite)\n");
158 } 153 }
159 154
160 if (m_addfriend(m, (const uint8_t *)good_id_b, (const uint8_t *)bad_data, bad_len) != FAERR_NOMESSAGE) { 155 if (m_addfriend(m, good_id, (const uint8_t *)bad_data, bad_len) != FAERR_NOMESSAGE) {
161 ck_abort_msg("m_addfriend did NOT catch the following length: %d\n", bad_len); 156 ck_abort_msg("m_addfriend did NOT catch the following length: %d\n", bad_len);
162 } 157 }
163 158
164 /* this should REALLY return an error */ 159 /* this should REALLY return an error */
165 /* TODO(irungentoo): validate client_id in m_addfriend? */ 160 /* TODO(irungentoo): validate client_id in m_addfriend? */
166 if (m_addfriend(m, (const uint8_t *)bad_id, (const uint8_t *)good_data, good_len) >= 0) { 161 if (m_addfriend(m, bad_id, (const uint8_t *)good_data, good_len) >= 0) {
167 ck_abort_msg("The following ID passed through " 162 ck_abort_msg("The following ID passed through "
168 "m_addfriend without an error:\n'%s'\n", bad_id_str); 163 "m_addfriend without an error:\n'%s'\n", bad_id_str);
169 } 164 }
@@ -348,8 +343,7 @@ int main(void)
348 setvbuf(stdout, nullptr, _IONBF, 0); 343 setvbuf(stdout, nullptr, _IONBF, 0);
349 344
350 friend_id = hex_string_to_bin(friend_id_str); 345 friend_id = hex_string_to_bin(friend_id_str);
351 good_id_a = hex_string_to_bin(good_id_a_str); 346 good_id = hex_string_to_bin(good_id_str);
352 good_id_b = hex_string_to_bin(good_id_b_str);
353 bad_id = hex_string_to_bin(bad_id_str); 347 bad_id = hex_string_to_bin(bad_id_str);
354 348
355 /* IPv6 status from global define */ 349 /* IPv6 status from global define */
@@ -361,13 +355,13 @@ int main(void)
361 m = new_messenger(&options, nullptr); 355 m = new_messenger(&options, nullptr);
362 356
363 /* setup a default friend and friendnum */ 357 /* setup a default friend and friendnum */
364 if (m_addfriend_norequest(m, (uint8_t *)friend_id) < 0) { 358 if (m_addfriend_norequest(m, friend_id) < 0) {
365 fputs("m_addfriend_norequest() failed on a valid ID!\n" 359 fputs("m_addfriend_norequest() failed on a valid ID!\n"
366 "this was CRITICAL to the test, and the build WILL fail.\n" 360 "this was CRITICAL to the test, and the build WILL fail.\n"
367 "the tests will continue now...\n\n", stderr); 361 "the tests will continue now...\n\n", stderr);
368 } 362 }
369 363
370 if ((friend_id_num = getfriend_id(m, (uint8_t *)friend_id)) < 0) { 364 if ((friend_id_num = getfriend_id(m, friend_id)) < 0) {
371 fputs("getfriend_id() failed on a valid ID!\n" 365 fputs("getfriend_id() failed on a valid ID!\n"
372 "this was CRITICAL to the test, and the build WILL fail.\n" 366 "this was CRITICAL to the test, and the build WILL fail.\n"
373 "the tests will continue now...\n\n", stderr); 367 "the tests will continue now...\n\n", stderr);
@@ -382,8 +376,7 @@ int main(void)
382 376
383 srunner_free(test_runner); 377 srunner_free(test_runner);
384 free(friend_id); 378 free(friend_id);
385 free(good_id_a); 379 free(good_id);
386 free(good_id_b);
387 free(bad_id); 380 free(bad_id);
388 381
389 kill_messenger(m); 382 kill_messenger(m);