2022-01-20 18:27:56 +00:00
|
|
|
// This file Copyright (C) 2013-2022 Mnemosyne LLC.
|
|
|
|
// It may be used under GPLv2 (SPDX: GPL-2.0), GPLv3 (SPDX: GPL-3.0),
|
|
|
|
// or any future license endorsed by Mnemosyne LLC.
|
|
|
|
// License text can be found in the licenses/ folder.
|
2014-01-19 01:09:44 +00:00
|
|
|
|
2008-12-02 17:10:54 +00:00
|
|
|
#include "transmission.h"
|
|
|
|
#include "peer-msgs.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
|
|
|
|
2021-12-21 22:14:15 +00:00
|
|
|
auto infohash = tr_sha1_digest_t{};
|
2017-04-19 12:04:45 +00:00
|
|
|
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];
|
|
|
|
|
2021-12-21 22:14:15 +00:00
|
|
|
memset(std::data(infohash), 0xaa, std::size(infohash));
|
2017-04-19 12:04:45 +00:00
|
|
|
|
2022-07-25 22:25:55 +00:00
|
|
|
auto const addr = tr_address::fromString("80.4.4.200");
|
2008-12-02 17:10:54 +00:00
|
|
|
|
|
|
|
numwant = 7;
|
2022-07-09 23:44:20 +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;
|
2022-07-09 23:44:20 +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
|
|
|
}
|