2014-01-19 01:09:44 +00:00
|
|
|
/*
|
|
|
|
* This file Copyright (C) 2013-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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-12-02 17:10:54 +00:00
|
|
|
#include "transmission.h"
|
|
|
|
#include "peer-msgs.h"
|
|
|
|
#include "utils.h"
|
|
|
|
|
2020-08-11 18:11:55 +00:00
|
|
|
#include "gtest/gtest.h"
|
2008-12-02 17:10:54 +00:00
|
|
|
|
2020-08-11 18:11:55 +00:00
|
|
|
TEST(PeerMsgs, placeholder)
|
2008-12-02 17:10:54 +00:00
|
|
|
{
|
2011-03-07 14:33:45 +00:00
|
|
|
#if 0
|
2017-04-19 12:04:45 +00:00
|
|
|
|
|
|
|
uint8_t infohash[SHA_DIGEST_LENGTH];
|
|
|
|
struct tr_address addr;
|
|
|
|
tr_piece_index_t pieceCount = 1313;
|
|
|
|
size_t numwant;
|
|
|
|
size_t numgot;
|
2008-12-02 17:10:54 +00:00
|
|
|
tr_piece_index_t pieces[] = { 1059, 431, 808, 1217, 287, 376, 1188, 353, 508 };
|
|
|
|
tr_piece_index_t buf[16];
|
|
|
|
|
2017-05-30 17:56:12 +00:00
|
|
|
memset(infohash, 0xaa, SHA_DIGEST_LENGTH);
|
2017-04-19 12:04:45 +00:00
|
|
|
|
|
|
|
tr_address_from_string(&addr, "80.4.4.200");
|
2008-12-02 17:10:54 +00:00
|
|
|
|
|
|
|
numwant = 7;
|
2017-04-19 12:04:45 +00:00
|
|
|
numgot = tr_generateAllowedSet(buf, numwant, pieceCount, infohash, &addr);
|
2017-05-30 17:56:12 +00:00
|
|
|
check_uint(numgot, ==, numwant);
|
|
|
|
check_mem(buf, ==, pieces, numgot);
|
2008-12-02 17:10:54 +00:00
|
|
|
|
|
|
|
numwant = 9;
|
2017-04-19 12:04:45 +00:00
|
|
|
numgot = tr_generateAllowedSet(buf, numwant, pieceCount, infohash, &addr);
|
2017-05-30 17:56:12 +00:00
|
|
|
check_uint(numgot, ==, numwant);
|
|
|
|
check_mem(buf, ==, pieces, numgot);
|
2017-04-19 12:04:45 +00:00
|
|
|
|
2011-03-07 14:33:45 +00:00
|
|
|
#endif
|
2008-12-02 17:10:54 +00:00
|
|
|
}
|