Exemple #1
0
        public void Setup()
        {
            int pieceCount  = 40;
            int pieceLength = 256 * 1024;
            var torrentData = new TestTorrentData {
                Files       = TorrentFileInfo.Create(pieceLength, ("File", pieceLength * pieceCount, "full/path/File")),
                PieceLength = pieceLength,
                Size        = pieceLength * pieceCount
            };

            peers = new List <PeerId> ();

            torrentManager = TestRig.CreateSingleFileManager(torrentData.Size, torrentData.PieceLength);
            torrentManager.LoadFastResume(new FastResume(torrentManager.InfoHash, new BitField(pieceCount).SetAll(true), new BitField(pieceCount).SetAll(false)));

            manager = new PieceManager(torrentManager);
            manager.Initialise();

            peer = PeerId.CreateNull(pieceCount);
            for (int i = 0; i < 20; i++)
            {
                PeerId p = PeerId.CreateNull(pieceCount);
                p.SupportsFastPeer = true;
                peers.Add(p);
            }
        }
        public void Setup()
        {
            int pieceLength = 16 * Constants.BlockSize;
            int pieces      = 40;
            int size        = pieces * pieceLength;

            bitfield    = new MutableBitField(pieces);
            torrentData = new TestTorrentData {
                Files       = TorrentFileInfo.Create(pieceLength, ("Test", size, "Full/Path/Test")),
                PieceLength = pieceLength,
                Size        = size
            };

            checker = new PiecePickerFilterChecker();
            picker  = new RarestFirstPicker(checker);
            picker.Initialise(torrentData);

            peer = PeerId.CreateNull(pieces);
            peer.BitField.SetAll(true);

            peers = new List <PeerId> ();
            for (int i = 0; i < 5; i++)
            {
                peers.Add(PeerId.CreateNull(pieces));
            }
        }
Exemple #3
0
        public async Task Setup()
        {
            int pieceCount  = 40;
            int pieceLength = 256 * 1024;
            var torrentData = TestTorrentManagerInfo.Create(
                files: TorrentFileInfo.Create(pieceLength, ("File", pieceLength * pieceCount, "full/path/File")),
                pieceLength: pieceLength,
                size: pieceLength * pieceCount
                );

            peers = new List <PeerId> ();

            torrentManager = TestRig.CreateSingleFileManager(torrentData.TorrentInfo.Size, torrentData.TorrentInfo.PieceLength);
            await torrentManager.LoadFastResumeAsync(new FastResume (torrentManager.InfoHashes, new BitField(pieceCount).SetAll(true), new BitField(pieceCount).SetAll(false)));

            manager = new PieceManager(torrentManager);
            manager.Initialise();

            peer = PeerId.CreateNull(pieceCount);
            for (int i = 0; i < 20; i++)
            {
                PeerId p = PeerId.CreateNull(pieceCount);
                p.SupportsFastPeer = true;
                peers.Add(p);
            }
        }
Exemple #4
0
 TestTorrentManagerInfo CreateTestTorrentData()
 {
     return(TestTorrentManagerInfo.Create(
                size: 64 * 1024 * 40,
                pieceLength: 64 * 1024,
                files: TorrentFileInfo.Create(64 * 1024, 64 * 1024 * 40)
                ));
 }
        public void Setup()
        {
            var pieceLength = Constants.BlockSize * 8;
            var files       = TorrentFileInfo.Create(pieceLength, ("Relative/Path.txt", Constants.BlockSize * 5, "Full/Path/Relative/Path.txt"));

            torrent = TestTorrentManagerInfo.Create(pieceLength: pieceLength, size: files.Single().Length, files: files);

            writer = new MemoryWriter();
            cache  = new MemoryCache(new MemoryPool(), Constants.BlockSize * 4, writer);
        }
        ITorrentManagerInfo CreateTorrentInfo()
        {
            var files = TorrentFileInfo.Create(Constants.BlockSize * 8, 1024 * 1024 * 8);

            return(TestTorrentManagerInfo.Create(
                       size: files.Single().Length,
                       pieceLength: Constants.BlockSize * 8,
                       files: files
                       ));
        }
Exemple #7
0
        static ITorrentManagerInfo CreateSingleFile()
        {
            int pieceLength = 1024 * 16 * 16;
            var size        = pieceLength * 32 + 123;

            return(TestTorrentManagerInfo.Create(
                       pieceLength: pieceLength,
                       size: size,
                       files: TorrentFileInfo.Create(pieceLength, ("Single", size, "full/path/Single"))
                       ));
        }
Exemple #8
0
        static TestTorrentData CreateSingleFile()
        {
            int pieceLength = 1024 * 16 * 16;
            var size        = pieceLength * 32 + 123;
            var files       = TorrentFileInfo.Create(pieceLength, ("Single", size, "full/path/Single"));

            return(new TestTorrentData {
                Files = files,
                PieceLength = pieceLength,
                Size = files.Single().Length
            });
        }
        public void Setup()
        {
            var pieceLength = Constants.BlockSize * 8;
            var files       = TorrentFileInfo.Create(pieceLength, ("Relative/Path.txt", Constants.BlockSize * 5, "Full/Path/Relative/Path.txt"));

            torrent = new TorrentData {
                Files       = files,
                PieceLength = pieceLength,
                Size        = files.Single().Length,
            };

            writer = new MemoryWriter();
            cache  = new MemoryCache(new MemoryPool(), Constants.BlockSize * 4, writer);
        }
        public void Setup()
        {
            var pieceLength = Constants.BlockSize * 2;

            Temp = Path.GetTempPath() + "monotorrent_tests";

            var files = TorrentFileInfo.Create(pieceLength,
                                               ("test1.file", 12345, Path.Combine(Temp, "test1.file")),
                                               ("test2.file", 12345, Path.Combine(Temp, "test2.file")),
                                               ("test3.file", 12345, Path.Combine(Temp, "test3.file")),
                                               ("test4.file", 12345, Path.Combine(Temp, "test4.file"))
                                               );

            TorrentFile = files.First();
            Others      = files.Skip(1).ToArray();
        }
Exemple #11
0
        static ITorrentManagerInfo CreateMultiFile()
        {
            int pieceLength = 1024 * 16 * 16;

            long[] sizes =
            {
                pieceLength * 10,
                   pieceLength * 7 + 123,
                   pieceLength * 32 + 123,
                   pieceLength * 16 + 543,
                   pieceLength * 19 + 591,
                   pieceLength * 22 + 591,
                   pieceLength * 0 + 12, // 12 byte file!
                   pieceLength * 7,
            };

            var files = TorrentFileInfo.Create(pieceLength, sizes);

            return(TestTorrentManagerInfo.Create(
                       files: files,
                       pieceLength: pieceLength,
                       size: files.Sum(t => t.Length)
                       ));
        }
Exemple #12
0
        static TestTorrentData CreateMultiFile()
        {
            int pieceLength = 1024 * 16 * 16;

            long[] sizes =
            {
                pieceLength * 10,
                   pieceLength * 7 + 123,
                   pieceLength * 32 + 123,
                   pieceLength * 16 + 543,
                   pieceLength * 19 + 591,
                   pieceLength * 22 + 591,
                   pieceLength * 0 + 12, // 12 byte file!
                   pieceLength * 7,
            };

            var files = TorrentFileInfo.Create(pieceLength, sizes);

            return(new TestTorrentData {
                Files = files,
                PieceLength = pieceLength,
                Size = files.Sum(t => t.Length)
            });
        }
        public void Setup()
        {
            int pieceCount  = 40;
            int pieceLength = 256 * 1024;

            bitfield    = new BitField(pieceCount);
            torrentData = new TestTorrentData {
                Files       = TorrentFileInfo.Create(pieceLength, ("File", pieceLength * pieceCount, "Full/Path/File")),
                PieceLength = pieceLength,
                Size        = pieceLength * pieceCount
            };
            peers = new List <PeerId> ();

            picker = new StandardPicker();
            picker.Initialise(torrentData);

            peer = PeerId.CreateNull(pieceCount);
            for (int i = 0; i < 20; i++)
            {
                PeerId p = PeerId.CreateNull(pieceCount);
                p.SupportsFastPeer = true;
                peers.Add(p);
            }
        }