public void Setup()
        {
            int pieceLength = 16 * Piece.BlockSize;
            int pieces      = 40;
            int size        = pieces * pieceLength;

            bitfield    = new BitField(pieces);
            torrentData = new TestTorrentData {
                Files       = new[] { new TorrentFileInfo(new TorrentFile("Test", size)) },
                PieceLength = pieceLength,
                Size        = size
            };

            checker = new TestPicker();
            picker  = new RarestFirstPicker(checker);
            picker.Initialise(bitfield, torrentData, new List <Piece> ());

            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 #2
0
        public void Setup()
        {
            checker = new TestPicker();
            picker  = new RandomisedPicker(checker);

            pieceCount = 40;
            peer       = PeerId.CreateNull(pieceCount);
            peer.BitField.SetAll(true);
        }
 public void Setup()
 {
     id.BitField.SetAll(true);
     tester = new TestPicker();
     picker = new PriorityPicker(tester);
     picker.Initialise(rig.Manager.Bitfield, rig.Torrent.Files, new List <Piece>());
     foreach (TorrentFile file in rig.Torrent.Files)
     {
         file.Priority = Priority.Normal;
     }
 }
        public void Setup()
        {
            singleFile     = CreateSingleFile();
            singleBitfield = new BitField(singleFile.Files.Single().EndPieceIndex + 1).SetAll(true);
            singlePeer     = PeerId.CreateNull(singleBitfield.Length);

            multiFile     = CreateMultiFile();
            multiBitfield = new BitField(multiFile.Files.Last().EndPieceIndex + 1).SetAll(true);
            multiPeer     = PeerId.CreateNull(multiBitfield.Length);

            tester = new TestPicker();
            picker = new PriorityPicker(tester);
            peers  = new List <PeerId>();
        }
Exemple #5
0
        public void Setup()
        {
            tester = new TestPicker();
            rarest = new RarestFirstPicker(tester);
            rarest.Initialise(rig.Manager.Bitfield, rig.Torrent.Files, new List <Piece>());
            peers = new List <PeerId>();
            for (int i = 0; i < 5; i++)
            {
                peers.Add(new PeerId(new Peer(new string((char)(i + 'a'), 20), new Uri("ipv4://aaa")), rig.Manager, NullConnection.Incoming));
            }

            for (int i = 0; i < rig.Manager.Bitfield.Length; i++)
            {
                for (int j = 0; j < peers.Count; j++)
                {
                    peers[j].BitField[i] = i % (j + 1) == 0;
                }
            }
            peers[0].BitField.SetAll(true);
        }