use of com.turn.ttorrent.tracker.TrackedPeer in project teamcity-torrent-plugin by JetBrains.
the class TorrentTrackerManagerTest method testThatOnePeerWithManyTorrentsCalculatedAsOnePeer.
@Test
public void testThatOnePeerWithManyTorrentsCalculatedAsOnePeer() {
TrackedTorrent firstTorrent = new TrackedTorrent(new byte[] { 1 });
TrackedTorrent secondTorrent = new TrackedTorrent(new byte[] { 2 });
myTorrentTrackerManager.startTracker();
final String ip = "127.0.0.1";
final int port = 6881;
firstTorrent.getPeers().put(new PeerUID(new InetSocketAddress(ip, port), "1"), new TrackedPeer(firstTorrent, ip, port, ByteBuffer.allocate(10)));
firstTorrent.getPeers().put(new PeerUID(new InetSocketAddress(ip, port), "2"), new TrackedPeer(secondTorrent, ip, port, ByteBuffer.allocate(10)));
myTorrentTrackerManager.getTorrentsRepository().putIfAbsent("1", firstTorrent);
myTorrentTrackerManager.getTorrentsRepository().putIfAbsent("2", secondTorrent);
assertEquals(2, myTorrentTrackerManager.getTorrents().size());
assertEquals(1, myTorrentTrackerManager.getConnectedClientsNum());
firstTorrent.getPeers().put(new PeerUID(new InetSocketAddress(ip, port + 1), "1"), new TrackedPeer(firstTorrent, ip, port + 1, ByteBuffer.allocate(10)));
assertEquals(2, myTorrentTrackerManager.getTorrents().size());
assertEquals(2, myTorrentTrackerManager.getConnectedClientsNum());
}
Aggregations