diff --git a/simulation/swarm_suite.cpp b/simulation/swarm_suite.cpp index 6c4ef3163..1a7b0b527 100644 --- a/simulation/swarm_suite.cpp +++ b/simulation/swarm_suite.cpp @@ -62,7 +62,7 @@ struct test_swarm_config : swarm_config // more slack for completion if (m_flags & stop_start_seed) { - TEST_CHECK(lt::clock_type::now() < m_start_time + lt::milliseconds(3700)); + TEST_CHECK(lt::clock_type::now() < m_start_time + lt::milliseconds(4700)); } else if (m_flags & stop_start_download) { @@ -133,6 +133,20 @@ struct test_swarm_config : swarm_config return swarm_config::on_alert(alert, session_idx, torrents, ses); } + virtual void on_torrent_added(int session_index, torrent_handle h) override + { + if (m_flags & add_extra_peers) + { + for (int i = 0; i < 30; ++i) + { + char ep[30]; + snprintf(ep, sizeof(ep), "60.0.0.%d", i + 1); + h.connect_peer(lt::tcp::endpoint( + lt::address_v4::from_string(ep), 6881)); + } + } + } + // called for every torrent that's added (and every session that's started). // this is useful to give every session a unique save path and to make some // sessions seeds and others downloaders diff --git a/simulation/swarm_suite.hpp b/simulation/swarm_suite.hpp index 87eee58c1..0021c89ca 100644 --- a/simulation/swarm_suite.hpp +++ b/simulation/swarm_suite.hpp @@ -43,7 +43,8 @@ enum test_flags_t utp_only = 64, stop_start_download = 128, stop_start_seed = 256, - graceful_pause = 1024 + graceful_pause = 1024, + add_extra_peers = 2048 }; void EXPORT simulate_swarm(int flags = 0); diff --git a/simulation/test_swarm.cpp b/simulation/test_swarm.cpp index 509efa6d4..3548ab590 100644 --- a/simulation/test_swarm.cpp +++ b/simulation/test_swarm.cpp @@ -57,16 +57,21 @@ TORRENT_TEST(utp) TORRENT_TEST(stop_start_download) { - simulate_swarm(stop_start_download); + simulate_swarm(stop_start_download | add_extra_peers); } TORRENT_TEST(stop_start_download_graceful) { - simulate_swarm(stop_start_download | graceful_pause); + simulate_swarm(stop_start_download | graceful_pause | add_extra_peers); } TORRENT_TEST(stop_start_seed) { - simulate_swarm(stop_start_seed); + simulate_swarm(stop_start_seed | add_extra_peers); +} + +TORRENT_TEST(stop_start_seed_graceful) +{ + simulate_swarm(stop_start_seed | graceful_pause | add_extra_peers); } TORRENT_TEST(explicit_cache)