From c1913a97f3ff744be14990da5a624636d6b89e9f Mon Sep 17 00:00:00 2001 From: arvidn Date: Mon, 15 Jun 2015 22:00:02 -0400 Subject: [PATCH] attempt to make setup_transfer more reliable by waiting for torrents to transition to downloading state before connecting peers --- test/setup_transfer.cpp | 12 ++++-------- test/test_remap_files.cpp | 36 ++++++++++++++++++++---------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/test/setup_transfer.cpp b/test/setup_transfer.cpp index 84151ea1a..2ff5f8efa 100644 --- a/test/setup_transfer.cpp +++ b/test/setup_transfer.cpp @@ -321,7 +321,7 @@ bool downloading_done = false; bool downloading_alert(libtorrent::alert const* a) { state_changed_alert const* sc = alert_cast(a); - if (sc && sc->state == torrent_status::downloading) + if (sc && sc->state == torrent_status::downloading) downloading_done = true; return true; } @@ -795,13 +795,7 @@ setup_transfer(lt::session* ses1, lt::session* ses2, lt::session* ses3 if (connect_peers) { - std::auto_ptr a; -/* do - { - a = wait_for_alert(*ses2, state_changed_alert::alert_type, "ses2"); - } while (static_cast(a.get())->state != torrent_status::downloading); -*/ -// wait_for_alert(*ses1, torrent_finished_alert::alert_type, "ses1"); + wait_for_downloading(*ses2, "ses2"); error_code ec; int port = 0; @@ -821,6 +815,8 @@ setup_transfer(lt::session* ses1, lt::session* ses2, lt::session* ses3 // give the other peers some time to get an initial // set of pieces before they start sharing with each-other + wait_for_downloading(*ses3, "ses3"); + port = 0; int port2 = 0; if (use_ssl_ports) diff --git a/test/test_remap_files.cpp b/test/test_remap_files.cpp index 6e79727d4..4a9c2a32a 100644 --- a/test/test_remap_files.cpp +++ b/test/test_remap_files.cpp @@ -511,33 +511,37 @@ void test_remap_files_prio(storage_mode_t storage_mode = storage_mode_sparse) p2 = ses2.abort(); } +using namespace libtorrent; + TORRENT_TEST(remap_files) { - using namespace libtorrent; - - error_code ec; - - remove_all("tmp1_remap", ec); - remove_all("tmp2_remap", ec); - test_remap_files_gather(); + error_code ec; remove_all("tmp1_remap", ec); remove_all("tmp2_remap", ec); remove_all("tmp1_remap2", ec); remove_all("tmp2_remap2", ec); +} +TORRENT_TEST(scatter) +{ test_remap_files_scatter(); - remove_all("tmp1_remap", ec); - remove_all("tmp2_remap", ec); - remove_all("tmp1_remap2", ec); - remove_all("tmp2_remap2", ec); - remove_all("tmp1_remap3", ec); - remove_all("tmp2_remap3", ec); - - test_remap_files_prio(); - + error_code ec; + remove_all("tmp1_remap", ec); + remove_all("tmp2_remap", ec); + remove_all("tmp1_remap2", ec); + remove_all("tmp2_remap2", ec); + remove_all("tmp1_remap3", ec); + remove_all("tmp2_remap3", ec); +} + +TORRENT_TEST(prio) +{ + test_remap_files_prio(); + + error_code ec; remove_all("tmp1_remap", ec); remove_all("tmp2_remap", ec); remove_all("tmp1_remap2", ec);