Esempio n. 1
0
        public void Setup(bool metadataMode, string metadataPath)
        {
            pair             = new ConnectionPair(55432);
            rig              = TestRig.CreateSingleFile(1024 * 1024 * 1024, 32768, metadataMode);
            rig.MetadataPath = metadataPath;
            rig.RecreateManager();

            rig.Manager.HashChecked = true;
            rig.Manager.Start();
            rig.AddConnection(pair.Outgoing);

            var    connection = pair.Incoming;
            PeerId id         = new PeerId(new Peer("", connection.Uri), rig.Manager);

            id.Connection = connection;
            byte[] data;

            EncryptorFactory.EndCheckEncryption(EncryptorFactory.BeginCheckEncryption(id, 68, null, null, new InfoHash[] { id.TorrentManager.InfoHash }), out data);
            decryptor = id.Decryptor;
            encryptor = id.Encryptor;
        }
Esempio n. 2
0
        public void SingleFileTorrent()
        {
            rig.Dispose();
            rig = TestRig.CreateSingleFile();
            var url = rig.Torrent.GetRightHttpSeeds[0];

            connection = new HttpConnection(new Uri(url))
            {
                Manager = rig.Manager
            };

            id = new PeerId(new Peer("this is my id", connection.Uri), rig.Manager)
            {
                Connection   = connection,
                IsChoking    = false,
                AmInterested = true
            };
            id.BitField.SetAll(true);
            id.MaxPendingRequests = numberOfPieces;

            requests = rig.Manager.PieceManager.Picker.PickPiece(id, new List <PeerId>(), numberOfPieces);
            RecieveFirst();
            Assert.AreEqual(url, _requestedUrl[0]);
        }
 public void Setup()
 {
     Rig = TestRig.CreateSingleFile(Piece.BlockSize * 20, Piece.BlockSize * 2);
     Rig.Manager.Bitfield.Not();
     Rig.Manager.Mode = new InitialSeedingMode(Rig.Manager);
 }