From 28041accc1fbea9db1b1c587a98ac417694be057 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Thu, 10 Oct 2013 07:50:34 +0000 Subject: [PATCH] unit test cleanup (test_metadata_transfer) --- test/setup_transfer.cpp | 4 ++-- test/test_metadata_extension.cpp | 13 ++----------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/test/setup_transfer.cpp b/test/setup_transfer.cpp index a702d894f..f04035883 100644 --- a/test/setup_transfer.cpp +++ b/test/setup_transfer.cpp @@ -215,7 +215,7 @@ bool print_alerts(libtorrent::session& ses, char const* name if (predicate && predicate(*i)) ret = true; if (peer_disconnected_alert* p = alert_cast(*i)) { - fprintf(stderr, "%s: %s [%s] (%s): %s\n", time_now_string(), name, (*i)->what(), print_endpoint(p->ip).c_str(), p->message().c_str()); + fprintf(stderr, "%s: %s: [%s] (%s): %s\n", time_now_string(), name, (*i)->what(), print_endpoint(p->ip).c_str(), p->message().c_str()); } else if ((*i)->message() != "block downloading" && (*i)->message() != "block finished" @@ -624,7 +624,7 @@ setup_transfer(session* ses1, session* ses2, session* ses3 error_code ec; create_directory("tmp1" + suffix, ec); std::ofstream file(combine_path("tmp1" + suffix, "temporary").c_str()); - t = ::create_torrent(&file, piece_size, 9, true); + t = ::create_torrent(&file, piece_size, 9, false); file.close(); if (clear_files) { diff --git a/test/test_metadata_extension.cpp b/test/test_metadata_extension.cpp index 3a858a689..6b1904dad 100644 --- a/test/test_metadata_extension.cpp +++ b/test/test_metadata_extension.cpp @@ -53,27 +53,22 @@ void test_transfer(bool clear_files, bool disconnect // the sessions to destruct in parallel session_proxy p1; session_proxy p2; - session_proxy p3; session ses1(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48100, 49000), "0.0.0.0", 0); session ses2(fingerprint("LT", 0, 1, 0, 0), std::make_pair(49100, 50000), "0.0.0.0", 0); - session ses3(fingerprint("LT", 0, 1, 0, 0), std::make_pair(50100, 51000), "0.0.0.0", 0); ses1.add_extension(constructor); ses2.add_extension(constructor); - ses3.add_extension(constructor); torrent_handle tor1; torrent_handle tor2; - torrent_handle tor3; #ifndef TORRENT_DISABLE_ENCRYPTION pe_settings pes; pes.out_enc_policy = pe_settings::forced; pes.in_enc_policy = pe_settings::forced; ses1.set_pe_settings(pes); ses2.set_pe_settings(pes); - ses3.set_pe_settings(pes); #endif - boost::tie(tor1, tor2, tor3) = setup_transfer(&ses1, &ses2, &ses3, clear_files, true, true, "_meta"); + boost::tie(tor1, tor2, ignore) = setup_transfer(&ses1, &ses2, NULL, clear_files, true, true, "_meta"); for (int i = 0; i < 80; ++i) { @@ -85,15 +80,13 @@ void test_transfer(bool clear_files, bool disconnect if (disconnect && tor2.is_valid()) ses2.remove_torrent(tor2); if (!disconnect - && tor2.status().has_metadata - && tor3.status().has_metadata) break; + && tor2.status().has_metadata) break; test_sleep(100); } if (disconnect) goto done; TEST_CHECK(tor2.status().has_metadata); - TEST_CHECK(tor3.status().has_metadata); std::cerr << "waiting for transfer to complete\n"; for (int i = 0; i < 30; ++i) @@ -114,12 +107,10 @@ done: // this allows shutting down the sessions in parallel p1 = ses1.abort(); p2 = ses2.abort(); - p3 = ses3.abort(); error_code ec; remove_all("tmp1_meta", ec); remove_all("tmp2_meta", ec); - remove_all("tmp3_meta", ec); } int test_main()