예제 #1
0
        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);
        }
예제 #3
0
        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));
        }
예제 #4
0
 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));
 }
예제 #5
0
 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));
 }