add urlseed timeout test (#1340)

updates m_last_sent in peer_connection::setup_send() instead of peer_connection::keep_alive()
This commit is contained in:
tnextday 2016-11-20 23:32:20 +08:00 committed by Arvid Norberg
parent 4df1ecbe25
commit c1224f72c3
2 changed files with 36 additions and 1 deletions

@ -1 +1 @@
Subproject commit 3eae1da7de7d13ab26472c4a44ee4477ce24fa26
Subproject commit e450864958668f8c2ecf8b9839fa278c9c797571

View File

@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/settings_pack.hpp"
#include "libtorrent/deadline_timer.hpp"
#include "libtorrent/torrent_info.hpp"
#include "libtorrent/alert_types.hpp"
#include "simulator/http_server.hpp"
#include "settings.hpp"
#include "libtorrent/create_torrent.hpp"
@ -161,3 +162,37 @@ TORRENT_TEST(single_file_torrent)
TEST_CHECK(expected);
}
TORRENT_TEST(urlseed_timeout)
{
bool timeout = false;
run_test(
[](lt::session& ses)
{
file_storage fs;
fs.add_file("timeout_test", 0x8000);
lt::add_torrent_params params;
params.ti = ::create_torrent(fs);
params.url_seeds.push_back("http://2.2.2.2:8080/");
params.flags &= ~lt::add_torrent_params::flag_auto_managed;
params.flags &= ~lt::add_torrent_params::flag_paused;
params.save_path = ".";
ses.async_add_torrent(params);
},
[&timeout](lt::session& ses, lt::alert const* alert) {
const lt::peer_disconnected_alert *pda = lt::alert_cast<lt::peer_disconnected_alert>(alert);
if (pda && pda->error == errors::timed_out_inactivity){
timeout = true;
}
},
[](sim::simulation& sim, lt::session& ses)
{
sim::asio::io_service web_server(sim, address_v4::from_string("2.2.2.2"));
// listen on port 8080
sim::http_server http(web_server, 8080);
http.register_stall_handler("/timeout_test");
sim.run();
}
);
TEST_EQUAL(timeout, true);
}