2014-01-19 01:09:44 +00:00
|
|
|
/*
|
|
|
|
* This file Copyright (C) 2010-2014 Mnemosyne LLC
|
|
|
|
*
|
2014-01-21 03:10:30 +00:00
|
|
|
* It may be used under the GNU GPL versions 2 or 3
|
2014-01-19 01:09:44 +00:00
|
|
|
* or any future license endorsed by Mnemosyne LLC.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-11-20 04:38:19 +00:00
|
|
|
#include "transmission.h"
|
|
|
|
#include "magnet.h"
|
|
|
|
#include "utils.h"
|
|
|
|
|
2012-08-18 16:07:05 +00:00
|
|
|
#include "libtransmission-test.h"
|
2009-11-20 04:38:19 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
static int test1(void)
|
2009-11-20 04:38:19 +00:00
|
|
|
{
|
2017-04-20 16:02:19 +00:00
|
|
|
char const* uri;
|
2017-04-19 12:04:45 +00:00
|
|
|
tr_magnet_info* info;
|
2017-05-30 17:56:12 +00:00
|
|
|
uint8_t const dec[] =
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
|
|
|
210, 53, 64, 16, 163, 202, 74, 222, 91, 116,
|
|
|
|
39, 187, 9, 58, 98, 163, 137, 159, 243, 129
|
|
|
|
};
|
2009-11-20 04:38:19 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
uri =
|
|
|
|
"magnet:?xt=urn:btih:"
|
|
|
|
"d2354010a3ca4ade5b7427bb093a62a3899ff381"
|
|
|
|
"&dn=Display%20Name"
|
|
|
|
"&tr=http%3A%2F%2Ftracker.openbittorrent.com%2Fannounce"
|
|
|
|
"&tr=http%3A%2F%2Ftracker.opentracker.org%2Fannounce"
|
|
|
|
"&ws=http%3A%2F%2Fserver.webseed.org%2Fpath%2Fto%2Ffile";
|
|
|
|
info = tr_magnetParse(uri);
|
2017-05-30 17:56:12 +00:00
|
|
|
check_ptr(info, !=, NULL);
|
2017-05-29 20:22:36 +00:00
|
|
|
check_int(info->trackerCount, ==, 2);
|
2017-05-29 19:48:02 +00:00
|
|
|
check_str(info->trackers[0], ==, "http://tracker.openbittorrent.com/announce");
|
|
|
|
check_str(info->trackers[1], ==, "http://tracker.opentracker.org/announce");
|
2017-05-29 20:22:36 +00:00
|
|
|
check_int(info->webseedCount, ==, 1);
|
2017-05-29 19:48:02 +00:00
|
|
|
check_str(info->webseeds[0], ==, "http://server.webseed.org/path/to/file");
|
|
|
|
check_str(info->displayName, ==, "Display Name");
|
2017-05-30 17:56:12 +00:00
|
|
|
check_mem(info->hash, ==, dec, 20);
|
2017-04-19 12:04:45 +00:00
|
|
|
|
|
|
|
tr_magnetFree(info);
|
2009-11-20 04:38:19 +00:00
|
|
|
info = NULL;
|
|
|
|
|
|
|
|
/* same thing but in base32 encoding */
|
2017-04-19 12:04:45 +00:00
|
|
|
uri =
|
|
|
|
"magnet:?xt=urn:btih:"
|
|
|
|
"2I2UAEFDZJFN4W3UE65QSOTCUOEZ744B"
|
|
|
|
"&dn=Display%20Name"
|
|
|
|
"&tr=http%3A%2F%2Ftracker.openbittorrent.com%2Fannounce"
|
|
|
|
"&ws=http%3A%2F%2Fserver.webseed.org%2Fpath%2Fto%2Ffile"
|
|
|
|
"&tr=http%3A%2F%2Ftracker.opentracker.org%2Fannounce";
|
|
|
|
info = tr_magnetParse(uri);
|
|
|
|
check(info != NULL);
|
2017-05-29 20:22:36 +00:00
|
|
|
check_int(info->trackerCount, ==, 2);
|
2017-05-29 19:48:02 +00:00
|
|
|
check_str(info->trackers[0], ==, "http://tracker.openbittorrent.com/announce");
|
|
|
|
check_str(info->trackers[1], ==, "http://tracker.opentracker.org/announce");
|
2017-05-29 20:22:36 +00:00
|
|
|
check_int(info->webseedCount, ==, 1);
|
2017-05-29 19:48:02 +00:00
|
|
|
check_str(info->webseeds[0], ==, "http://server.webseed.org/path/to/file");
|
|
|
|
check_str(info->displayName, ==, "Display Name");
|
2017-05-30 17:56:12 +00:00
|
|
|
check_mem(info->hash, ==, dec, 20);
|
2017-04-19 12:04:45 +00:00
|
|
|
|
|
|
|
tr_magnetFree(info);
|
2009-11-20 04:38:19 +00:00
|
|
|
info = NULL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
MAIN_SINGLE_TEST(test1)
|