fast extension fix, added some logging for fast extension messages, improved test to catch the problem
This commit is contained in:
@@ -11,9 +11,32 @@
|
||||
|
||||
#include "test.hpp"
|
||||
#include "libtorrent/assert.hpp"
|
||||
#include "libtorrent/alert_types.hpp"
|
||||
|
||||
using boost::filesystem::remove_all;
|
||||
using boost::filesystem::create_directory;
|
||||
using namespace libtorrent;
|
||||
|
||||
void print_alerts(libtorrent::session& ses, char const* name, bool allow_disconnects, bool allow_no_torrents)
|
||||
{
|
||||
std::vector<torrent_handle> handles = ses.get_torrents();
|
||||
TEST_CHECK(!handles.empty() || allow_no_torrents);
|
||||
torrent_handle h;
|
||||
if (!handles.empty()) h = handles[0];
|
||||
std::auto_ptr<alert> a;
|
||||
a = ses.pop_alert();
|
||||
while (a.get())
|
||||
{
|
||||
std::cerr << name << ": " << a->msg() << "\n";
|
||||
TEST_CHECK(dynamic_cast<peer_error_alert*>(a.get()) == 0
|
||||
|| (!handles.empty() && h.is_seed())
|
||||
|| a->msg() == "connecting to peer"
|
||||
|| a->msg() == "closing connection to ourself"
|
||||
|| a->msg() == "duplicate connection"
|
||||
|| (allow_disconnects && a->msg() == "End of file."));
|
||||
a = ses.pop_alert();
|
||||
}
|
||||
}
|
||||
|
||||
void test_sleep(int millisec)
|
||||
{
|
||||
@@ -167,15 +190,21 @@ setup_transfer(session* ses1, session* ses2, session* ses3
|
||||
// use the same files
|
||||
sha1_hash info_hash = t->info_hash();
|
||||
torrent_handle tor1 = ses1->add_torrent(clone_ptr(t), "./tmp1" + suffix);
|
||||
TEST_CHECK(!ses1->get_torrents().empty());
|
||||
torrent_handle tor2;
|
||||
torrent_handle tor3;
|
||||
if (ses3) tor3 = ses3->add_torrent(clone_ptr(t), "./tmp3" + suffix);
|
||||
if (ses3)
|
||||
{
|
||||
tor3 = ses3->add_torrent(clone_ptr(t), "./tmp3" + suffix);
|
||||
TEST_CHECK(!ses3->get_torrents().empty());
|
||||
}
|
||||
|
||||
if (use_metadata_transfer)
|
||||
tor2 = ses2->add_torrent("http://non-existent-name.com/announce"
|
||||
, t->info_hash(), 0, "./tmp2" + suffix);
|
||||
else
|
||||
tor2 = ses2->add_torrent(clone_ptr(t), "./tmp2" + suffix);
|
||||
TEST_CHECK(!ses2->get_torrents().empty());
|
||||
|
||||
assert(ses1->get_torrents().size() == 1);
|
||||
assert(ses2->get_torrents().size() == 1);
|
||||
|
@@ -5,6 +5,9 @@
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
|
||||
|
||||
void print_alerts(libtorrent::session& ses, char const* name
|
||||
, bool allow_disconnects = false
|
||||
, bool allow_no_torrents = false);
|
||||
void test_sleep(int millisec);
|
||||
|
||||
boost::intrusive_ptr<libtorrent::torrent_info> create_torrent(std::ostream* file = 0);
|
||||
|
@@ -56,27 +56,9 @@ void test_lsd()
|
||||
|
||||
for (int i = 0; i < 30; ++i)
|
||||
{
|
||||
std::auto_ptr<alert> a;
|
||||
a = ses1.pop_alert();
|
||||
while(a.get())
|
||||
{
|
||||
std::cerr << "ses1: " << a->msg() << "\n";
|
||||
a = ses1.pop_alert();
|
||||
}
|
||||
|
||||
a = ses2.pop_alert();
|
||||
while (a.get())
|
||||
{
|
||||
std::cerr << "ses2: " << a->msg() << "\n";
|
||||
a = ses2.pop_alert();
|
||||
}
|
||||
|
||||
a = ses3.pop_alert();
|
||||
while (a.get())
|
||||
{
|
||||
std::cerr << "ses3: " << a->msg() << "\n";
|
||||
a = ses3.pop_alert();
|
||||
}
|
||||
print_alerts(ses1, "ses1", true);
|
||||
print_alerts(ses2, "ses2", true);
|
||||
print_alerts(ses3, "ses3", true);
|
||||
|
||||
torrent_status st1 = tor1.status();
|
||||
torrent_status st2 = tor2.status();
|
||||
|
@@ -39,20 +39,8 @@ void test_transfer(bool clear_files, bool disconnect
|
||||
// make sure this function can be called on
|
||||
// torrents without metadata
|
||||
if (!disconnect) tor2.status();
|
||||
std::auto_ptr<alert> a;
|
||||
a = ses1.pop_alert();
|
||||
while(a.get())
|
||||
{
|
||||
std::cerr << "ses1: " << a->msg() << "\n";
|
||||
a = ses1.pop_alert();
|
||||
}
|
||||
|
||||
a = ses2.pop_alert();
|
||||
while (a.get())
|
||||
{
|
||||
std::cerr << "ses2: " << a->msg() << "\n";
|
||||
a = ses2.pop_alert();
|
||||
}
|
||||
print_alerts(ses1, "ses1", false, true);
|
||||
print_alerts(ses2, "ses2", false, true);
|
||||
|
||||
if (disconnect && tor2.is_valid()) ses2.remove_torrent(tor2);
|
||||
if (!disconnect && tor2.has_metadata()) break;
|
||||
|
@@ -114,20 +114,8 @@ void test_transfer(libtorrent::pe_settings::enc_policy policy,
|
||||
for (int i = 0; i < 50; ++i)
|
||||
{
|
||||
tor2.status();
|
||||
std::auto_ptr<alert> a;
|
||||
a = ses1.pop_alert();
|
||||
while(a.get())
|
||||
{
|
||||
std::cerr << "ses1: " << a->msg() << "\n";
|
||||
a = ses1.pop_alert();
|
||||
}
|
||||
|
||||
a = ses2.pop_alert();
|
||||
while (a.get())
|
||||
{
|
||||
std::cerr << "ses2: " << a->msg() << "\n";
|
||||
a = ses2.pop_alert();
|
||||
}
|
||||
print_alerts(ses1, "ses1");
|
||||
print_alerts(ses2, "ses2");
|
||||
|
||||
if (tor2.is_seed()) break;
|
||||
test_sleep(100);
|
||||
|
@@ -63,27 +63,9 @@ void test_pex()
|
||||
|
||||
for (int i = 0; i < 40; ++i)
|
||||
{
|
||||
std::auto_ptr<alert> a;
|
||||
a = ses1.pop_alert();
|
||||
while(a.get())
|
||||
{
|
||||
std::cerr << "ses1: " << a->msg() << "\n";
|
||||
a = ses1.pop_alert();
|
||||
}
|
||||
|
||||
a = ses2.pop_alert();
|
||||
while (a.get())
|
||||
{
|
||||
std::cerr << "ses2: " << a->msg() << "\n";
|
||||
a = ses2.pop_alert();
|
||||
}
|
||||
|
||||
a = ses3.pop_alert();
|
||||
while (a.get())
|
||||
{
|
||||
std::cerr << "ses3: " << a->msg() << "\n";
|
||||
a = ses3.pop_alert();
|
||||
}
|
||||
print_alerts(ses1, "ses1");
|
||||
print_alerts(ses2, "ses2");
|
||||
print_alerts(ses3, "ses3");
|
||||
|
||||
torrent_status st1 = tor1.status();
|
||||
torrent_status st2 = tor2.status();
|
||||
|
@@ -63,27 +63,9 @@ void test_swarm()
|
||||
|
||||
for (int i = 0; i < 26; ++i)
|
||||
{
|
||||
std::auto_ptr<alert> a;
|
||||
a = ses1.pop_alert();
|
||||
while(a.get())
|
||||
{
|
||||
std::cerr << "ses1: " << a->msg() << "\n";
|
||||
a = ses1.pop_alert();
|
||||
}
|
||||
|
||||
a = ses2.pop_alert();
|
||||
while (a.get())
|
||||
{
|
||||
std::cerr << "ses2: " << a->msg() << "\n";
|
||||
a = ses2.pop_alert();
|
||||
}
|
||||
|
||||
a = ses3.pop_alert();
|
||||
while (a.get())
|
||||
{
|
||||
std::cerr << "ses3: " << a->msg() << "\n";
|
||||
a = ses3.pop_alert();
|
||||
}
|
||||
print_alerts(ses1, "ses1");
|
||||
print_alerts(ses2, "ses2");
|
||||
print_alerts(ses3, "ses3");
|
||||
|
||||
torrent_status st1 = tor1.status();
|
||||
torrent_status st2 = tor2.status();
|
||||
|
Reference in New Issue
Block a user