~ubuntu-branches/ubuntu/maverick/libtorrent-rasterbar/maverick

« back to all changes in this revision

Viewing changes to test/test_lsd.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Sauthier
  • Date: 2010-08-10 12:59:37 UTC
  • mfrom: (1.3.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100810125937-jbcmmf17y8yo9hgz
Tags: 0.15.0-0ubuntu1
* New upstream version.
* debian/patches/100_fix_html_docs.patch: refreshed.
* debian/control: bump up standards-version to 3.9.1 (no changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
{
47
47
        using namespace libtorrent;
48
48
 
49
 
        session ses1(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48100, 49000));
50
 
        session ses2(fingerprint("LT", 0, 1, 0, 0), std::make_pair(49100, 50000));
51
 
        session ses3(fingerprint("LT", 0, 1, 0, 0), std::make_pair(50100, 51000));
52
 
 
53
 
        // this is to avoid everything finish from a single peer
54
 
        // immediately. To make the swarm actually connect all
55
 
        // three peers before finishing.
56
 
        float rate_limit = 180000;
57
 
        ses1.set_upload_rate_limit(int(rate_limit));
58
 
        ses2.set_download_rate_limit(int(rate_limit));
59
 
        ses3.set_download_rate_limit(int(rate_limit));
60
 
        ses2.set_upload_rate_limit(int(rate_limit / 2));
61
 
        ses3.set_upload_rate_limit(int(rate_limit / 2));
 
49
        session ses1(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48100, 49000), "0.0.0.0", 0);
 
50
        session ses2(fingerprint("LT", 0, 1, 0, 0), std::make_pair(49100, 50000), "0.0.0.0", 0);
62
51
 
63
52
        session_settings settings;
64
53
        settings.allow_multiple_connections_per_ip = true;
65
 
        settings.ignore_limits_on_local_network = false;
66
54
        ses1.set_settings(settings);
67
55
        ses2.set_settings(settings);
68
 
        ses3.set_settings(settings);
69
56
 
70
57
        ses1.start_lsd();
71
58
        ses2.start_lsd();
72
 
        ses3.start_lsd();
73
 
 
74
 
#ifndef TORRENT_DISABLE_ENCRYPTION
75
 
        pe_settings pes;
76
 
        pes.out_enc_policy = pe_settings::forced;
77
 
        pes.in_enc_policy = pe_settings::forced;
78
 
        ses1.set_pe_settings(pes);
79
 
        ses2.set_pe_settings(pes);
80
 
        ses3.set_pe_settings(pes);
81
 
#endif
82
 
 
83
59
        torrent_handle tor1;
84
60
        torrent_handle tor2;
85
 
        torrent_handle tor3;
86
61
 
87
 
        boost::tie(tor1, tor2, tor3) = setup_transfer(&ses1, &ses2, &ses3, true, false, false, "_lsd");
 
62
        using boost::tuples::ignore;
 
63
        boost::tie(tor1, tor2, ignore) = setup_transfer(&ses1, &ses2, 0, true, false, false, "_lsd");
88
64
 
89
65
        for (int i = 0; i < 30; ++i)
90
66
        {
91
67
                print_alerts(ses1, "ses1", true);
92
68
                print_alerts(ses2, "ses2", true);
93
 
                print_alerts(ses3, "ses3", true);
94
69
 
95
70
                torrent_status st1 = tor1.status();
96
71
                torrent_status st2 = tor2.status();
97
 
                torrent_status st3 = tor3.status();
98
72
 
99
73
                std::cerr
100
74
                        << "\033[33m" << int(st1.upload_payload_rate / 1000.f) << "kB/s "
101
 
                        << st1.num_peers << ": "
102
75
                        << "\033[32m" << int(st2.download_payload_rate / 1000.f) << "kB/s "
103
76
                        << "\033[31m" << int(st2.upload_payload_rate / 1000.f) << "kB/s "
104
77
                        << "\033[0m" << int(st2.progress * 100) << "% "
105
 
                        << st2.num_peers << " - "
106
 
                        << "\033[32m" << int(st3.download_payload_rate / 1000.f) << "kB/s "
107
 
                        << "\033[31m" << int(st3.upload_payload_rate / 1000.f) << "kB/s "
108
 
                        << "\033[0m" << int(st3.progress * 100) << "% "
109
 
                        << st3.num_peers
110
78
                        << std::endl;
111
79
 
112
 
                if (tor2.is_seed() && tor3.is_seed()) break;
 
80
                if (tor2.is_seed() /*&& tor3.is_seed()*/) break;
113
81
                test_sleep(1000);
114
82
        }
115
83
 
116
84
        TEST_CHECK(tor2.is_seed());
117
 
        TEST_CHECK(tor3.is_seed());
118
85
 
119
 
        if (tor2.is_seed() && tor3.is_seed()) std::cerr << "done\n";
 
86
        if (tor2.is_seed()) std::cerr << "done\n";
120
87
}
121
88
 
122
89
int test_main()