public void DoesntHaveSuggestedPiece() { peer.IsChoking = false; peer.SupportsFastPeer = true; peer.SuggestedPieces.AddRange(new int[] { 1, 2, 3, 4 }); peer.BitField.SetAll(true); picker = new StandardPicker(); picker.Initialise(rig.Manager.Bitfield, rig.Torrent.Files, new List <Piece>()); var bundle = picker.PickPiece(peer, new BitField(peer.BitField.Length), peers, 1, 0, peer.BitField.Length); Assert.IsNull(bundle); }
public void DoesntHaveFastPiece() { peer.IsChoking = true; peer.SupportsFastPeer = true; peer.IsAllowedFastPieces.AddRange(new[] { 1, 2, 3, 4 }); peer.BitField.SetAll(true); picker = new StandardPicker(); picker.Initialise(bitfield, torrentData, new List <Piece> ()); var bundle = picker.PickPiece(peer, new BitField(peer.BitField.Length), peers, 1, 0, peer.BitField.Length); Assert.IsNull(bundle); }
public void RequestFastSeeder() { int[] allowedFast = new int[] { 1, 2, 3, 5, 8, 13, 21 }; peers[0].SupportsFastPeer = true; peers[0].IsAllowedFastPieces.AddRange((int[])allowedFast.Clone()); peers[0].BitField.SetAll(true); // Lets pretend he has everything for (int i = 0; i < 7; i++) { for (int j = 0; j < 16; j++) { var msg = picker.PickPiece(peers[0], peers); Assert.IsNotNull(msg, "#1." + j); Assert.IsTrue(Array.IndexOf(allowedFast, msg.PieceIndex) > -1, "#2." + j); } } Assert.IsNull(picker.PickPiece(peers[0], peers)); }
public virtual IList <PieceRequest> PickPiece(PeerId id, BitField peerBitfield, List <PeerId> otherPeers, int count, int startIndex, int endIndex) { CheckOverriden(); return(picker.PickPiece(id, peerBitfield, otherPeers, count, startIndex, endIndex)); }
public virtual IList <PieceRequest> PickPiece(IPieceRequester peer, BitField available, IReadOnlyList <IPieceRequester> otherPeers, int count, int startIndex, int endIndex) { CheckOverriden(); return(picker.PickPiece(peer, available, otherPeers, count, startIndex, endIndex)); }