2015-04-03 22:15:48 +02:00
|
|
|
/*
|
|
|
|
|
|
|
|
Copyright (c) 2015, Arvid Norberg
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
* Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in
|
|
|
|
the documentation and/or other materials provided with the distribution.
|
|
|
|
* Neither the name of the author nor the names of its
|
|
|
|
contributors may be used to endorse or promote products derived
|
|
|
|
from this software without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "test.hpp"
|
|
|
|
#include "libtorrent/alert_manager.hpp"
|
|
|
|
#include "libtorrent/torrent_handle.hpp"
|
|
|
|
#include "libtorrent/alert_types.hpp"
|
2015-04-11 20:44:43 +02:00
|
|
|
#include "libtorrent/extensions.hpp"
|
2015-04-12 02:14:07 +02:00
|
|
|
#include "setup_transfer.hpp"
|
2015-04-03 22:15:48 +02:00
|
|
|
|
2016-05-25 06:31:52 +02:00
|
|
|
#include <functional>
|
2016-05-01 00:54:23 +02:00
|
|
|
#include <thread>
|
|
|
|
|
2017-04-12 20:05:53 +02:00
|
|
|
using namespace lt;
|
2015-04-03 22:15:48 +02:00
|
|
|
|
2015-05-31 14:21:16 +02:00
|
|
|
TORRENT_TEST(limit)
|
2015-04-03 22:15:48 +02:00
|
|
|
{
|
2017-07-26 06:33:10 +02:00
|
|
|
alert_manager mgr(500, alert::all_categories);
|
2015-04-03 22:15:48 +02:00
|
|
|
|
|
|
|
TEST_EQUAL(mgr.alert_queue_size_limit(), 500);
|
|
|
|
TEST_EQUAL(mgr.pending(), false);
|
|
|
|
|
|
|
|
// try add 600 torrent_add_alert to make sure we honor the limit of 500
|
|
|
|
// alerts.
|
2018-05-01 19:55:38 +02:00
|
|
|
for (piece_index_t i{0}; i < piece_index_t{600}; ++i)
|
2018-05-01 12:26:37 +02:00
|
|
|
mgr.emplace_alert<piece_finished_alert>(torrent_handle(), i);
|
2015-04-03 22:15:48 +02:00
|
|
|
|
|
|
|
TEST_EQUAL(mgr.pending(), true);
|
|
|
|
|
|
|
|
std::vector<alert*> alerts;
|
2015-12-06 18:45:20 +01:00
|
|
|
mgr.get_all(alerts);
|
2015-04-03 22:15:48 +02:00
|
|
|
|
|
|
|
// even though we posted 600, the limit was 500
|
2018-05-26 13:40:49 +02:00
|
|
|
// +1 for the alerts_dropped_alert
|
|
|
|
TEST_EQUAL(alerts.size(), 501);
|
2015-04-03 22:15:48 +02:00
|
|
|
|
|
|
|
TEST_EQUAL(mgr.pending(), false);
|
2015-04-11 20:44:43 +02:00
|
|
|
|
|
|
|
// now, try lowering the limit and do the same thing again
|
|
|
|
mgr.set_alert_queue_size_limit(200);
|
|
|
|
|
2018-05-01 19:55:38 +02:00
|
|
|
for (piece_index_t i{0}; i < piece_index_t{600}; ++i)
|
2018-05-01 12:26:37 +02:00
|
|
|
mgr.emplace_alert<piece_finished_alert>(torrent_handle(), i);
|
2015-04-11 20:44:43 +02:00
|
|
|
|
|
|
|
TEST_EQUAL(mgr.pending(), true);
|
|
|
|
|
2015-12-06 18:45:20 +01:00
|
|
|
mgr.get_all(alerts);
|
2015-04-11 20:44:43 +02:00
|
|
|
|
|
|
|
// even though we posted 600, the limit was 200
|
2018-05-26 13:40:49 +02:00
|
|
|
// +1 for the alerts_dropped_alert
|
|
|
|
TEST_EQUAL(alerts.size(), 201);
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
2018-05-30 14:48:50 +02:00
|
|
|
TORRENT_TEST(limit_int_max)
|
|
|
|
{
|
|
|
|
int const inf = std::numeric_limits<int>::max();
|
2018-06-06 13:44:02 +02:00
|
|
|
alert_manager mgr(inf, alert::all_categories);
|
2018-05-30 14:48:50 +02:00
|
|
|
|
|
|
|
TEST_EQUAL(mgr.alert_queue_size_limit(), inf);
|
|
|
|
|
2018-06-06 13:44:02 +02:00
|
|
|
for (piece_index_t i{0}; i < piece_index_t{600}; ++i)
|
2018-05-30 14:48:50 +02:00
|
|
|
mgr.emplace_alert<piece_finished_alert>(torrent_handle(), i);
|
|
|
|
|
2018-06-06 13:44:02 +02:00
|
|
|
for (piece_index_t i{0}; i < piece_index_t{600}; ++i)
|
2018-05-30 14:48:50 +02:00
|
|
|
mgr.emplace_alert<torrent_removed_alert>(torrent_handle(), sha1_hash());
|
|
|
|
|
|
|
|
std::vector<alert*> alerts;
|
2018-06-06 13:44:02 +02:00
|
|
|
mgr.get_all(alerts);
|
2018-05-30 14:48:50 +02:00
|
|
|
|
|
|
|
TEST_EQUAL(alerts.size(), 1200);
|
|
|
|
}
|
|
|
|
|
2015-05-31 14:21:16 +02:00
|
|
|
TORRENT_TEST(priority_limit)
|
2015-04-03 22:15:48 +02:00
|
|
|
{
|
2017-07-26 06:33:10 +02:00
|
|
|
alert_manager mgr(100, alert::all_categories);
|
2015-04-03 22:15:48 +02:00
|
|
|
|
|
|
|
TEST_EQUAL(mgr.alert_queue_size_limit(), 100);
|
|
|
|
|
|
|
|
// this should only add 100 because of the limit
|
2018-05-01 19:55:38 +02:00
|
|
|
for (piece_index_t i{0}; i < piece_index_t{200}; ++i)
|
2018-05-01 12:26:37 +02:00
|
|
|
mgr.emplace_alert<piece_finished_alert>(torrent_handle(), i);
|
2015-04-03 22:15:48 +02:00
|
|
|
|
|
|
|
// the limit is twice as high for priority alerts
|
2018-05-01 19:55:38 +02:00
|
|
|
for (file_index_t i(0); i < file_index_t(300); ++i)
|
2015-04-03 22:15:48 +02:00
|
|
|
mgr.emplace_alert<file_rename_failed_alert>(torrent_handle(), i, error_code());
|
|
|
|
|
|
|
|
std::vector<alert*> alerts;
|
2015-12-06 18:45:20 +01:00
|
|
|
mgr.get_all(alerts);
|
2015-04-03 22:15:48 +02:00
|
|
|
|
2018-05-01 12:26:37 +02:00
|
|
|
// even though we posted 500, the limit was 100 for half of them and
|
|
|
|
// 100 + 200 for the other half, meaning we should have 300 alerts now
|
2018-05-26 13:40:49 +02:00
|
|
|
// +1 for the alerts_dropped_alert
|
|
|
|
TEST_EQUAL(alerts.size(), 301);
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
2018-01-25 15:34:39 +01:00
|
|
|
namespace {
|
2015-04-03 22:15:48 +02:00
|
|
|
void test_notify_fun(int& cnt)
|
|
|
|
{
|
|
|
|
++cnt;
|
|
|
|
}
|
2018-01-25 15:34:39 +01:00
|
|
|
} // anonymous namespace
|
2015-04-03 22:15:48 +02:00
|
|
|
|
2015-05-31 14:21:16 +02:00
|
|
|
TORRENT_TEST(notify_function)
|
2015-04-03 22:15:48 +02:00
|
|
|
{
|
|
|
|
int cnt = 0;
|
2017-07-26 06:33:10 +02:00
|
|
|
alert_manager mgr(100, alert::all_categories);
|
2015-04-03 22:15:48 +02:00
|
|
|
|
|
|
|
TEST_EQUAL(mgr.alert_queue_size_limit(), 100);
|
|
|
|
TEST_EQUAL(mgr.pending(), false);
|
|
|
|
|
|
|
|
for (int i = 0; i < 20; ++i)
|
2017-03-27 01:19:20 +02:00
|
|
|
mgr.emplace_alert<add_torrent_alert>(torrent_handle(), add_torrent_params(), error_code());
|
2015-04-03 22:15:48 +02:00
|
|
|
|
|
|
|
TEST_EQUAL(mgr.pending(), true);
|
|
|
|
|
|
|
|
// if there are queued alerts when we set the notify function,
|
|
|
|
// that counts as an edge and it's called
|
2016-08-13 03:31:55 +02:00
|
|
|
mgr.set_notify_function(std::bind(&test_notify_fun, std::ref(cnt)));
|
2015-04-03 22:15:48 +02:00
|
|
|
|
|
|
|
TEST_EQUAL(mgr.pending(), true);
|
|
|
|
TEST_EQUAL(cnt, 1);
|
|
|
|
|
|
|
|
// subsequent posted alerts will not cause an edge (because there are
|
|
|
|
// already alerts queued)
|
|
|
|
for (int i = 0; i < 20; ++i)
|
2017-03-27 01:19:20 +02:00
|
|
|
mgr.emplace_alert<add_torrent_alert>(torrent_handle(), add_torrent_params(), error_code());
|
2015-04-03 22:15:48 +02:00
|
|
|
|
|
|
|
TEST_EQUAL(mgr.pending(), true);
|
|
|
|
TEST_EQUAL(cnt, 1);
|
|
|
|
|
|
|
|
// however, if we pop all the alerts and post new ones, there will be
|
|
|
|
// and edge triggering the notify call
|
|
|
|
std::vector<alert*> alerts;
|
2015-12-06 18:45:20 +01:00
|
|
|
mgr.get_all(alerts);
|
2015-04-03 22:15:48 +02:00
|
|
|
|
|
|
|
TEST_EQUAL(mgr.pending(), false);
|
|
|
|
|
|
|
|
for (int i = 0; i < 20; ++i)
|
2017-03-27 01:19:20 +02:00
|
|
|
mgr.emplace_alert<add_torrent_alert>(torrent_handle(), add_torrent_params(), error_code());
|
2015-04-03 22:15:48 +02:00
|
|
|
|
|
|
|
TEST_EQUAL(mgr.pending(), true);
|
|
|
|
TEST_EQUAL(cnt, 2);
|
|
|
|
}
|
|
|
|
|
2015-04-11 20:44:43 +02:00
|
|
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
2018-01-25 15:34:39 +01:00
|
|
|
namespace {
|
2015-04-11 20:44:43 +02:00
|
|
|
int plugin_alerts[3] = { 0, 0, 0 };
|
|
|
|
|
2017-04-12 20:05:53 +02:00
|
|
|
struct test_plugin : lt::plugin
|
2015-04-11 20:44:43 +02:00
|
|
|
{
|
2016-07-10 20:27:42 +02:00
|
|
|
explicit test_plugin(int index) : m_index(index) {}
|
2018-01-23 20:56:03 +01:00
|
|
|
void on_alert(alert const*) override
|
2015-04-11 20:44:43 +02:00
|
|
|
{
|
|
|
|
++plugin_alerts[m_index];
|
|
|
|
}
|
|
|
|
int m_index;
|
|
|
|
};
|
2018-01-25 15:34:39 +01:00
|
|
|
} // anonymous namespace
|
2015-04-11 20:44:43 +02:00
|
|
|
#endif
|
|
|
|
|
2015-05-31 14:21:16 +02:00
|
|
|
TORRENT_TEST(extensions)
|
2015-04-11 20:44:43 +02:00
|
|
|
{
|
|
|
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
2015-05-31 19:28:37 +02:00
|
|
|
memset(plugin_alerts, 0, sizeof(plugin_alerts));
|
2017-07-26 06:33:10 +02:00
|
|
|
alert_manager mgr(100, alert::all_categories);
|
2015-04-11 20:44:43 +02:00
|
|
|
|
2016-08-17 20:30:24 +02:00
|
|
|
mgr.add_extension(std::make_shared<test_plugin>(0));
|
|
|
|
mgr.add_extension(std::make_shared<test_plugin>(1));
|
|
|
|
mgr.add_extension(std::make_shared<test_plugin>(2));
|
2015-04-11 20:44:43 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < 53; ++i)
|
2017-03-27 01:19:20 +02:00
|
|
|
mgr.emplace_alert<add_torrent_alert>(torrent_handle(), add_torrent_params(), error_code());
|
2015-04-11 20:44:43 +02:00
|
|
|
|
|
|
|
TEST_EQUAL(plugin_alerts[0], 53);
|
|
|
|
TEST_EQUAL(plugin_alerts[1], 53);
|
|
|
|
TEST_EQUAL(plugin_alerts[2], 53);
|
|
|
|
|
|
|
|
for (int i = 0; i < 17; ++i)
|
2017-03-27 01:19:20 +02:00
|
|
|
mgr.emplace_alert<add_torrent_alert>(torrent_handle(), add_torrent_params(), error_code());
|
2015-04-11 20:44:43 +02:00
|
|
|
|
|
|
|
TEST_EQUAL(plugin_alerts[0], 70);
|
|
|
|
TEST_EQUAL(plugin_alerts[1], 70);
|
|
|
|
TEST_EQUAL(plugin_alerts[2], 70);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-11-03 10:36:33 +01:00
|
|
|
/*
|
2018-01-23 20:56:03 +01:00
|
|
|
namespace {
|
|
|
|
|
2015-04-12 02:14:07 +02:00
|
|
|
void post_torrent_added(alert_manager* mgr)
|
|
|
|
{
|
2016-06-26 15:24:06 +02:00
|
|
|
std::this_thread::sleep_for(lt::milliseconds(10));
|
2017-03-27 01:19:20 +02:00
|
|
|
mgr->emplace_alert<add_torrent_alert>(torrent_handle(), add_torrent_params(), error_code());
|
2015-04-12 02:14:07 +02:00
|
|
|
}
|
|
|
|
|
2018-01-23 20:56:03 +01:00
|
|
|
} // anonymous namespace
|
|
|
|
|
2019-11-03 10:36:33 +01:00
|
|
|
// this test is too flaky
|
|
|
|
|
2015-05-31 14:21:16 +02:00
|
|
|
TORRENT_TEST(wait_for_alert)
|
2015-04-11 20:44:43 +02:00
|
|
|
{
|
2017-07-26 06:33:10 +02:00
|
|
|
alert_manager mgr(100, alert::all_categories);
|
2015-04-11 20:44:43 +02:00
|
|
|
|
|
|
|
time_point start = clock_type::now();
|
2015-05-31 19:28:37 +02:00
|
|
|
|
2015-04-11 20:44:43 +02:00
|
|
|
alert* a = mgr.wait_for_alert(seconds(1));
|
|
|
|
|
|
|
|
time_point end = clock_type::now();
|
2016-07-09 22:26:26 +02:00
|
|
|
TEST_EQUAL(a, static_cast<alert*>(nullptr));
|
2016-10-10 02:23:45 +02:00
|
|
|
std::printf("delay: %d ms (expected 1 second)\n"
|
2015-09-06 04:07:02 +02:00
|
|
|
, int(total_milliseconds(end - start)));
|
2015-04-11 20:44:43 +02:00
|
|
|
TEST_CHECK(end - start > milliseconds(900));
|
|
|
|
TEST_CHECK(end - start < milliseconds(1100));
|
|
|
|
|
2017-03-27 01:19:20 +02:00
|
|
|
mgr.emplace_alert<add_torrent_alert>(torrent_handle(), add_torrent_params(), error_code());
|
2015-04-11 20:44:43 +02:00
|
|
|
|
|
|
|
start = clock_type::now();
|
|
|
|
a = mgr.wait_for_alert(seconds(1));
|
|
|
|
end = clock_type::now();
|
2015-09-06 04:07:02 +02:00
|
|
|
|
2016-10-10 02:23:45 +02:00
|
|
|
std::printf("delay: %d ms\n", int(total_milliseconds(end - start)));
|
2015-04-11 20:44:43 +02:00
|
|
|
TEST_CHECK(end - start < milliseconds(1));
|
2017-03-27 01:19:20 +02:00
|
|
|
TEST_CHECK(a->type() == add_torrent_alert::alert_type);
|
2015-04-12 02:14:07 +02:00
|
|
|
|
|
|
|
std::vector<alert*> alerts;
|
2015-12-06 18:45:20 +01:00
|
|
|
mgr.get_all(alerts);
|
2015-04-12 02:14:07 +02:00
|
|
|
|
|
|
|
start = clock_type::now();
|
2016-05-01 00:54:23 +02:00
|
|
|
std::thread posting_thread(&post_torrent_added, &mgr);
|
2015-04-12 02:14:07 +02:00
|
|
|
|
|
|
|
a = mgr.wait_for_alert(seconds(10));
|
|
|
|
end = clock_type::now();
|
2015-09-06 04:07:02 +02:00
|
|
|
|
2016-10-10 02:23:45 +02:00
|
|
|
std::printf("delay: %d ms\n", int(total_milliseconds(end - start)));
|
2015-04-12 02:14:07 +02:00
|
|
|
TEST_CHECK(end - start < milliseconds(500));
|
2017-03-27 01:19:20 +02:00
|
|
|
TEST_CHECK(a->type() == add_torrent_alert::alert_type);
|
2015-04-12 02:14:07 +02:00
|
|
|
|
|
|
|
posting_thread.join();
|
2015-04-11 20:44:43 +02:00
|
|
|
}
|
2019-11-03 10:36:33 +01:00
|
|
|
*/
|
2015-04-11 20:44:43 +02:00
|
|
|
|
2015-05-31 14:21:16 +02:00
|
|
|
TORRENT_TEST(alert_mask)
|
2015-04-11 20:44:43 +02:00
|
|
|
{
|
2017-07-26 06:33:10 +02:00
|
|
|
alert_manager mgr(100, alert::all_categories);
|
2015-04-11 20:44:43 +02:00
|
|
|
|
2017-03-27 01:19:20 +02:00
|
|
|
TEST_CHECK(mgr.should_post<add_torrent_alert>());
|
2015-04-11 20:44:43 +02:00
|
|
|
TEST_CHECK(mgr.should_post<torrent_paused_alert>());
|
|
|
|
|
2017-07-26 06:33:10 +02:00
|
|
|
mgr.set_alert_mask({});
|
2015-04-11 20:44:43 +02:00
|
|
|
|
2017-03-27 01:19:20 +02:00
|
|
|
TEST_CHECK(!mgr.should_post<add_torrent_alert>());
|
2015-04-11 20:44:43 +02:00
|
|
|
TEST_CHECK(!mgr.should_post<torrent_paused_alert>());
|
|
|
|
}
|
|
|
|
|
2017-11-10 22:50:31 +01:00
|
|
|
TORRENT_TEST(dropped_alerts)
|
|
|
|
{
|
|
|
|
alert_manager mgr(1, alert::all_categories);
|
|
|
|
|
|
|
|
// nothing has dropped yet
|
|
|
|
mgr.emplace_alert<torrent_finished_alert>(torrent_handle());
|
|
|
|
// still nothing, there's space for one alert
|
|
|
|
mgr.emplace_alert<torrent_finished_alert>(torrent_handle());
|
2018-05-01 19:55:38 +02:00
|
|
|
// still nothing, there's space for one alert
|
|
|
|
mgr.emplace_alert<torrent_finished_alert>(torrent_handle());
|
2017-11-10 22:50:31 +01:00
|
|
|
// that last alert got dropped though, since it would have brought the queue
|
2018-05-01 19:55:38 +02:00
|
|
|
// size to 3
|
2018-05-26 13:40:49 +02:00
|
|
|
std::vector<alert*> alerts;
|
|
|
|
mgr.get_all(alerts);
|
|
|
|
auto const d = alert_cast<alerts_dropped_alert>(alerts.back())->dropped_alerts;
|
2018-05-01 19:55:38 +02:00
|
|
|
TEST_EQUAL(d.count(), 1);
|
2017-11-10 22:50:31 +01:00
|
|
|
TEST_CHECK(d.test(torrent_finished_alert::alert_type));
|
2018-05-26 13:40:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TORRENT_TEST(alerts_dropped_alert)
|
|
|
|
{
|
|
|
|
alert_manager mgr(1, alert::all_categories);
|
|
|
|
|
|
|
|
mgr.emplace_alert<torrent_finished_alert>(torrent_handle());
|
|
|
|
mgr.emplace_alert<torrent_finished_alert>(torrent_handle());
|
|
|
|
mgr.emplace_alert<torrent_finished_alert>(torrent_handle());
|
|
|
|
// that last alert got dropped though, since it would have brought the queue
|
|
|
|
// size to 3
|
|
|
|
std::vector<alert*> alerts;
|
|
|
|
mgr.get_all(alerts);
|
2017-11-10 22:50:31 +01:00
|
|
|
|
2018-05-26 13:40:49 +02:00
|
|
|
TEST_EQUAL(alerts.back()->message(), "dropped alerts: torrent_finished ");
|
2017-11-10 22:50:31 +01:00
|
|
|
}
|
2018-05-02 00:32:09 +02:00
|
|
|
|
2018-04-30 00:34:41 +02:00
|
|
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
|
|
|
struct post_plugin : lt::plugin
|
|
|
|
{
|
2018-05-02 00:32:09 +02:00
|
|
|
explicit post_plugin(alert_manager& m) : mgr(m) {}
|
|
|
|
void on_alert(alert const*)
|
2018-04-30 00:34:41 +02:00
|
|
|
{
|
|
|
|
if (++depth > 10) return;
|
2018-05-02 00:32:09 +02:00
|
|
|
mgr.emplace_alert<piece_finished_alert>(torrent_handle(), piece_index_t{0});
|
2018-04-30 00:34:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
alert_manager& mgr;
|
2018-05-02 00:32:09 +02:00
|
|
|
int depth = 0;
|
2018-04-30 00:34:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// make sure the alert manager supports alerts being posted while executing a
|
|
|
|
// plugin handler
|
|
|
|
TORRENT_TEST(recursive_alerts)
|
|
|
|
{
|
2018-05-02 00:32:09 +02:00
|
|
|
alert_manager mgr(100, alert::all_categories);
|
|
|
|
auto pl = std::make_shared<post_plugin>(mgr);
|
2018-04-30 00:34:41 +02:00
|
|
|
mgr.add_extension(pl);
|
|
|
|
|
2018-05-02 00:32:09 +02:00
|
|
|
mgr.emplace_alert<piece_finished_alert>(torrent_handle(), piece_index_t{0});
|
2018-04-30 00:34:41 +02:00
|
|
|
|
|
|
|
TEST_EQUAL(pl->depth, 11);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // TORRENT_DISABLE_EXTENSIONS
|
|
|
|
|