fix test build

This commit is contained in:
Arvid Norberg 2015-05-10 05:25:31 +00:00
parent 0358badb82
commit ca577796d3
2 changed files with 20 additions and 6 deletions

View File

@ -433,6 +433,7 @@ struct obs : dht::dht_observer
virtual void outgoing_get_peers(sha1_hash const& target
, sha1_hash const& sent_target, udp::endpoint const& ep) TORRENT_OVERRIDE {}
virtual void announce(sha1_hash const& ih, address const& addr, int port) TORRENT_OVERRIDE {}
virtual void log(dht_logger::dht_module_t l, char const* fmt, ...) TORRENT_OVERRIDE {}
};
// TODO: test obfuscated_get_peers
@ -1052,7 +1053,7 @@ int test_main()
node_id id = to_hash("1234876923549721020394873245098347598635");
node_id diff = to_hash("15764f7459456a9453f8719b09547c11d5f34061");
routing_table tbl(id, 8, sett);
routing_table tbl(id, 8, sett, &observer);
// insert 256 nodes evenly distributed across the ID space.
// we expect to fill the top 5 buckets
@ -1076,7 +1077,7 @@ int test_main()
node_id id = to_hash("1234876923549721020394873245098347598635");
node_id diff = to_hash("15764f7459456a9453f8719b09547c11d5f34061");
routing_table tbl(id, 8, sett);
routing_table tbl(id, 8, sett, &observer);
for (int i = 0; i < 256; ++i)
{
add_and_replace(id, diff);
@ -1234,7 +1235,7 @@ int test_main()
// s.restrict_routing_ips = false;
node_id id = to_hash("3123456789abcdef01232456789abcdef0123456");
const int bucket_size = 10;
dht::routing_table table(id, bucket_size, s);
dht::routing_table table(id, bucket_size, s, &observer);
std::vector<node_entry> nodes;
TEST_EQUAL(table.size().get<0>(), 0);

View File

@ -35,6 +35,18 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/address.hpp"
#include "libtorrent/time.hpp"
#include "libtorrent/kademlia/dos_blocker.hpp"
#include "libtorrent/kademlia/dht_observer.hpp"
struct log_t : libtorrent::dht::dht_logger
{
virtual void log(dht_logger::dht_module_t m, char const* fmt, ...)
{
va_list v;
va_start(v, fmt);
vfprintf(stderr, fmt, v);
va_end(v);
}
};
int test_main()
{
@ -42,6 +54,7 @@ int test_main()
using namespace libtorrent;
using namespace libtorrent::dht;
log_t l;
dos_blocker b;
address spammer = address_v4::from_string("10.10.10.10");
@ -49,15 +62,15 @@ int test_main()
time_point now = clock_type::now();
for (int i = 0; i < 1000; ++i)
{
b.incoming(spammer, now);
b.incoming(spammer, now, &l);
now += milliseconds(1);
TEST_EQUAL(b.incoming(rand_v4(), now), true);
TEST_EQUAL(b.incoming(rand_v4(), now, &l), true);
now += milliseconds(1);
}
now += milliseconds(1);
TEST_EQUAL(b.incoming(spammer, now), false);
TEST_EQUAL(b.incoming(spammer, now, &l), false);
#endif
return 0;