Example #1
0
        public void RejectRequests()
        {
            var messages = new List <PieceRequest>();

            peer.IsChoking = false;
            peer.BitField.SetAll(true);

            PieceRequest m;

            while ((m = picker.PickPiece(peer, peers)) != null)
            {
                messages.Add(m);
            }

            foreach (PieceRequest message in messages)
            {
                picker.CancelRequest(peer, message.PieceIndex, message.StartOffset, message.RequestLength);
            }

            var messages2 = new List <PieceRequest>();

            while ((m = picker.PickPiece(peer, peers)) != null)
            {
                messages2.Add(m);
            }

            Assert.AreEqual(messages.Count, messages2.Count, "#1");
            for (int i = 0; i < messages.Count; i++)
            {
                Assert.IsTrue(messages2.Contains(messages[i]), "#2." + i);
            }
        }
Example #2
0
 public virtual void CancelRequest(PeerId peer, int piece, int startOffset, int length)
 {
     CheckOverriden();
     picker.CancelRequest(peer, piece, startOffset, length);
 }