diff options
author | irungentoo <irungentoo@gmail.com> | 2015-03-17 13:44:48 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2015-03-17 13:44:48 -0400 |
commit | 24c70c9e8479a528e02afefa4afc5c3219f9afd7 (patch) | |
tree | 8cef607ff7afc7cad003665c4a3da0d7d85eb807 /auto_tests | |
parent | 2757b254fef9354feff7527d9209232654d58126 (diff) |
Added and implemented file_id parameter to file tranfers.
file_id is a 32byte identifier that can be used by users to identify
file tranfers across core/client restarts in order to resume broken
file tranfers.
In avatar tranfers it corresponds to the hash of the avatar.
Added tox_file_get_file_id() function to api to obtain the file_id
of an ongoing file transfer.
If not set, core will generate a random one.
Diffstat (limited to 'auto_tests')
-rw-r--r-- | auto_tests/tox_test.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c index dc23040d..942931a1 100644 --- a/auto_tests/tox_test.c +++ b/auto_tests/tox_test.c | |||
@@ -100,6 +100,7 @@ void handle_custom_packet(Tox *m, uint32_t friend_num, const uint8_t *data, size | |||
100 | return; | 100 | return; |
101 | } | 101 | } |
102 | 102 | ||
103 | uint8_t file_cmp_id[TOX_FILE_ID_LENGTH]; | ||
103 | uint8_t filenum; | 104 | uint8_t filenum; |
104 | uint32_t file_accepted; | 105 | uint32_t file_accepted; |
105 | uint64_t file_size; | 106 | uint64_t file_size; |
@@ -119,6 +120,22 @@ void tox_file_receive(Tox *tox, uint32_t friend_number, uint32_t file_number, ui | |||
119 | return; | 120 | return; |
120 | } | 121 | } |
121 | 122 | ||
123 | uint8_t file_id[TOX_FILE_ID_LENGTH]; | ||
124 | |||
125 | if (!tox_file_get_file_id(tox, friend_number, file_number, file_id, 0)) { | ||
126 | ck_abort_msg("tox_file_get_file_id error"); | ||
127 | } | ||
128 | |||
129 | if (memcmp(file_id, file_cmp_id, TOX_FILE_ID_LENGTH) != 0) { | ||
130 | ck_abort_msg("bad file_id"); | ||
131 | } | ||
132 | |||
133 | uint8_t empty[TOX_FILE_ID_LENGTH] = {0}; | ||
134 | |||
135 | if (memcmp(empty, file_cmp_id, TOX_FILE_ID_LENGTH) == 0) { | ||
136 | ck_abort_msg("empty file_id"); | ||
137 | } | ||
138 | |||
122 | file_size = filesize; | 139 | file_size = filesize; |
123 | 140 | ||
124 | TOX_ERR_FILE_CONTROL error; | 141 | TOX_ERR_FILE_CONTROL error; |
@@ -520,10 +537,18 @@ START_TEST(test_few_clients) | |||
520 | tox_callback_file_recv_control(tox3, file_print_control, &to_compare); | 537 | tox_callback_file_recv_control(tox3, file_print_control, &to_compare); |
521 | tox_callback_file_receive(tox3, tox_file_receive, &to_compare); | 538 | tox_callback_file_receive(tox3, tox_file_receive, &to_compare); |
522 | uint64_t totalf_size = 100 * 1024 * 1024; | 539 | uint64_t totalf_size = 100 * 1024 * 1024; |
523 | uint32_t fnum = tox_file_send(tox2, 0, TOX_FILE_KIND_DATA, totalf_size, (uint8_t *)"Gentoo.exe", sizeof("Gentoo.exe"), | 540 | uint32_t fnum = tox_file_send(tox2, 0, TOX_FILE_KIND_DATA, totalf_size, 0, (uint8_t *)"Gentoo.exe", |
524 | 0); | 541 | sizeof("Gentoo.exe"), 0); |
525 | ck_assert_msg(fnum != UINT32_MAX, "tox_new_file_sender fail"); | 542 | ck_assert_msg(fnum != UINT32_MAX, "tox_new_file_sender fail"); |
526 | 543 | ||
544 | TOX_ERR_FILE_GET gfierr; | ||
545 | ck_assert_msg(!tox_file_get_file_id(tox2, 1, fnum, file_cmp_id, &gfierr), "tox_file_get_file_id didn't fail"); | ||
546 | ck_assert_msg(gfierr == TOX_ERR_FILE_GET_FRIEND_NOT_FOUND, "wrong error"); | ||
547 | ck_assert_msg(!tox_file_get_file_id(tox2, 0, fnum + 1, file_cmp_id, &gfierr), "tox_file_get_file_id didn't fail"); | ||
548 | ck_assert_msg(gfierr == TOX_ERR_FILE_GET_NOT_FOUND, "wrong error"); | ||
549 | ck_assert_msg(tox_file_get_file_id(tox2, 0, fnum, file_cmp_id, &gfierr), "tox_file_get_file_id failed"); | ||
550 | ck_assert_msg(gfierr == TOX_ERR_FILE_GET_OK, "wrong error"); | ||
551 | |||
527 | 552 | ||
528 | while (1) { | 553 | while (1) { |
529 | tox_iterate(tox1); | 554 | tox_iterate(tox1); |