fix bug in setup_transfer (for unit tests). fix verbose logging build. make sure test_pex is reliable

This commit is contained in:
Arvid Norberg 2014-10-21 02:08:46 +00:00
parent 9b37efe6a8
commit 14c9bd90d3
3 changed files with 6 additions and 12 deletions

View File

@ -55,6 +55,10 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/resolver_interface.hpp" #include "libtorrent/resolver_interface.hpp"
#include "libtorrent/ip_filter.hpp" #include "libtorrent/ip_filter.hpp"
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
#include "libtorrent/socket_io.hpp"
#endif
namespace libtorrent namespace libtorrent
{ {

View File

@ -690,7 +690,7 @@ setup_transfer(lt::session* ses1, lt::session* ses2, lt::session* ses3
ip_filter f; ip_filter f;
f.add_rule(address_v4::from_string("0.0.0.0") f.add_rule(address_v4::from_string("0.0.0.0")
, address_v4::from_string("255.255.255.255") , address_v4::from_string("255.255.255.255")
, lt::session::global_peer_class_id); , 1 << lt::session::global_peer_class_id);
ses1->set_peer_class_filter(f); ses1->set_peer_class_filter(f);
ses2->set_peer_class_filter(f); ses2->set_peer_class_filter(f);
if (ses3) ses3->set_peer_class_filter(f); if (ses3) ses3->set_peer_class_filter(f);

View File

@ -80,24 +80,14 @@ void test_pex()
lt::session ses1(pack, fingerprint("LT", 0, 1, 0, 0)); lt::session ses1(pack, fingerprint("LT", 0, 1, 0, 0));
// treat all IPs the same, i.e. enable rate limiting for local peers
ip_filter f;
f.add_rule(address_v4::from_string("0.0.0.0"), address_v4::from_string("255.255.255.255"), 1 << lt::session::global_peer_class_id);
peer_class_info pc = ses1.get_peer_class(lt::session::global_peer_class_id);
TEST_EQUAL(pc.upload_limit, 2000);
TEST_EQUAL(pc.download_limit, 2000);
ses1.set_peer_class(lt::session::local_peer_class_id, pc);
pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:49200"); pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:49200");
lt::session ses3(pack, fingerprint("LT", 0, 1, 0, 0)); lt::session ses3(pack, fingerprint("LT", 0, 1, 0, 0));
ses3.set_peer_class(lt::session::local_peer_class_id, pc);
// make the peer connecting the two worthless to transfer // make the peer connecting the two worthless to transfer
// data, to force peer 3 to connect directly to peer 1 through pex // data, to force peer 3 to connect directly to peer 1 through pex
pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:50200"); pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:50200");
lt::session ses2(pack, fingerprint("LT", 0, 1, 0, 0)); lt::session ses2(pack, fingerprint("LT", 0, 1, 0, 0));
ses2.set_peer_class(lt::session::local_peer_class_id, pc);
ses1.add_extension(create_ut_pex_plugin); ses1.add_extension(create_ut_pex_plugin);
ses2.add_extension(create_ut_pex_plugin); ses2.add_extension(create_ut_pex_plugin);
@ -121,7 +111,7 @@ void test_pex()
torrent_status st1; torrent_status st1;
torrent_status st2; torrent_status st2;
torrent_status st3; torrent_status st3;
for (int i = 0; i < 80; ++i) for (int i = 0; i < 610; ++i)
{ {
print_alerts(ses1, "ses1"); print_alerts(ses1, "ses1");
print_alerts(ses2, "ses2"); print_alerts(ses2, "ses2");