merge tracker exchange patch from RC_0_16

This commit is contained in:
Arvid Norberg
2013-04-27 22:54:58 +00:00
parent 246826ecb4
commit 0a8f81cfed
3 changed files with 60 additions and 5 deletions

View File

@@ -40,6 +40,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/extensions/metadata_transfer.hpp"
#include "libtorrent/extensions/ut_metadata.hpp"
#include "libtorrent/extensions/lt_trackers.hpp"
#include "libtorrent/bencode.hpp"
using boost::tuples::ignore;
@@ -61,7 +62,48 @@ int test_main()
torrent_handle tor2 = ses2.add_torrent(atp, ec);
tor2.connect_peer(tcp::endpoint(address_v4::from_string("127.0.0.1"), ses1.listen_port()));
for (int i = 0; i < 130; ++i)
// trackers are NOT supposed to be exchanged for torrents that we
// don't have metadata for, since they might be private
for (int i = 0; i < 10; ++i)
{
// make sure this function can be called on
// torrents without metadata
print_alerts(ses1, "ses1", false, true);
print_alerts(ses2, "ses2", false, true);
if (tor1.trackers().size() != 0) break;
test_sleep(1000);
}
TEST_CHECK(tor1.trackers().size() == 0);
entry info;
info["pieces"] = "aaaaaaaaaaaaaaaaaaaa";
info["name"] = "slightly shorter name, it's kind of sad that people started the trend of incorrectly encoding the regular name field and then adding another one with correct encoding";
info["name.utf-8"] = "this is a long ass name in order to try to make make_magnet_uri overflow and hopefully crash. Although, by the time you read this that particular bug should have been fixed";
info["piece length"] = 16 * 1024;
info["length"] = 3245;
entry torrent;
torrent["info"] = info;
std::vector<char> buf;
bencode(std::back_inserter(buf), torrent);
boost::intrusive_ptr<torrent_info> ti(new torrent_info(&buf[0], buf.size(), ec));
TEST_CHECK(!ec);
atp.ti = ti;
atp.info_hash.clear();
atp.save_path = "./";
atp.trackers.clear();
tor1 = ses1.add_torrent(atp, ec);
atp.trackers.push_back("http://test.non-existent.com/announce");
tor2 = ses2.add_torrent(atp, ec);
tor2.connect_peer(tcp::endpoint(address_v4::from_string("127.0.0.1"), ses1.listen_port()));
TEST_CHECK(tor1.trackers().size() == 0);
for (int i = 0; i < 60; ++i)
{
// make sure this function can be called on
// torrents without metadata
@@ -73,6 +115,7 @@ int test_main()
}
TEST_CHECK(tor1.trackers().size() == 1);
return 0;
}