public void Setup() { int pieceCount = 40; int pieceLength = 256 * 1024; bitfield = new BitField(pieceCount); torrentData = new TestTorrentData { Files = new [] { new TorrentFile("File", pieceLength * pieceCount) }, PieceLength = pieceLength, Size = pieceLength * pieceCount }; peers = new List <PeerId>(); magnetLink = new MagnetLink(new InfoHash(new byte[20])); torrentManager = new TorrentManager(magnetLink, "", new TorrentSettings(), ""); manager = new PieceManager(torrentManager); manager.ChangePicker(new StandardPicker(), bitfield, torrentData); 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 pieceCount = 40; int pieceLength = 256 * 1024; bitfield = new BitField(pieceCount); torrentData = new TestTorrentData { Files = new[] { new TorrentFileInfo(new TorrentFile("File", pieceLength * pieceCount)) }, 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.ChangePicker(new StandardPicker(), bitfield); manager.Picker.Initialise(bitfield, torrentData, Enumerable.Empty <Piece> ()); peer = PeerId.CreateNull(pieceCount); for (int i = 0; i < 20; i++) { PeerId p = PeerId.CreateNull(pieceCount); p.SupportsFastPeer = true; peers.Add(p); } }
public void RequestInEndgame_AllDoNotDownload() { manager.ChangePicker(torrentManager.CreateStandardPicker(), bitfield, torrentData); foreach (var file in torrentData.Files) { file.Priority = Priority.DoNotDownload; } bitfield.SetAll(true).Set(0, false); peers[0].BitField.SetAll(true); peers[0].IsChoking = false; manager.AddPieceRequests(peers[0]); Assert.AreEqual(0, peers[0].AmRequestingPiecesCount, "#1"); Assert.AreEqual(0, peers[0].QueueLength, "#2"); }
public virtual void Setup() { // Yes, this is horrible. Deal with it. rig = TestRig.CreateMultiFile(); peers = new List <PeerId>(); manager = new PieceManager(); manager.ChangePicker((standardPicker = new StandardPicker()), rig.Manager.Bitfield, rig.Manager.Torrent.Files); this.picker = manager.Picker; peer = new PeerId(new Peer(new string('a', 20), new Uri("ipv4://BLAH")), rig.Manager, NullConnection.Incoming); for (int i = 0; i < 20; i++) { PeerId p = new PeerId(new Peer(new string(i.ToString()[0], 20), new Uri("ipv4://" + i)), rig.Manager, NullConnection.Incoming); p.SupportsFastPeer = true; peers.Add(p); } }