Exemplo n.º 1
0
 public void Setup()
 {
     pair = new ConnectionPair(55432);
     rig = TestRig.CreateMultiFile();
     rig.Manager.HashChecked = true;
     rig.Manager.Start();
 }
Exemplo n.º 2
0
        public void Setup()
        {
            requestedUrl.Clear();
            partialData = false;
            int i;
            for (i = 0; i < 1000; i++)
            {
                try
                {
                    listener = new HttpListener();
                    listener.Prefixes.Add(string.Format(listenerURL, i));
                    listener.Start();
                    break;
                }
                catch
                {

                }
            }
            listener.BeginGetContext(GotContext, null);
            rig = TestRig.CreateMultiFile();
            connection = new HttpConnection(new Uri(string.Format(listenerURL, i)));
            connection.Manager = rig.Manager;

            id = new PeerId(new Peer("this is my id", connection.Uri), rig.Manager);
            id.Connection = connection;
            id.IsChoking = false;
            id.AmInterested = true;
            id.BitField.SetAll(true);
            id.MaxPendingRequests = numberOfPieces;
            
            requests = rig.Manager.PieceManager.Picker.PickPiece(id, new List<PeerId>(), numberOfPieces);
        }
Exemplo n.º 3
0
 public void FixtureSetup()
 {
     rig = TestRig.CreateMultiFile();
     id = new PeerId(new Peer(new string('a', 20), new Uri("tcp://BLAH")), rig.Manager);
     for (int i = 0; i < id.BitField.Length; i += 2)
         id.BitField[i] = true;
 }
Exemplo n.º 4
0
 public virtual void Setup()
 {
     // Yes, this is horrible. Deal with it.
     rig = TestRig.CreateMultiFile();
     peers = new List<PeerId>();
     picker = new IgnoringPicker(rig.Manager.Bitfield, new StandardPicker());
     picker.Initialise(rig.Manager.Bitfield, rig.Manager.Torrent.Files, new List<Piece>());
     peer = new PeerId(new Peer(new string('a', 20), new Uri("tcp://BLAH")), rig.Manager);
     for (int i = 0; i < 20; i++)
     {
         PeerId p = new PeerId(new Peer(new string(i.ToString()[0], 20), new Uri("tcp://" + i)), rig.Manager);
         p.SupportsFastPeer = true;
         peers.Add(p);
     }
 }
Exemplo n.º 5
0
        public void FixtureSetup()
        {
            string[][] trackers = new string[][] {
                new string [] {
                    "custom://tracker1.com/announce",
                    "custom://tracker2.com/announce",
                    "custom://tracker3.com/announce",
                    "custom://tracker4.com/announce"
                },
                new string[] {
                    "custom://tracker5.com/announce",
                    "custom://tracker6.com/announce",
                    "custom://tracker7.com/announce",
                    "custom://tracker8.com/announce"
                }
            };

            rig = TestRig.CreateTrackers(trackers);
        }
Exemplo n.º 6
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;
        }
Exemplo n.º 7
0
 public void FixtureSetup()
 {
     buffer  = new byte[100000];
     testRig = TestRig.CreateMultiFile();
 }
Exemplo n.º 8
0
        public void ReregisterManager()
        {
            ManualResetEvent handle = new ManualResetEvent(false);
            rig.Manager.TorrentStateChanged += delegate(object sender, TorrentStateChangedEventArgs e)
            {
                if (e.OldState == TorrentState.Hashing)
                    handle.Set();
            };
            rig.Manager.HashCheck(false);

            handle.WaitOne();
            handle.Reset();

            rig.Engine.Unregister(rig.Manager);
            TestRig rig2 = new TestRig("", new TestWriter());
            rig2.Engine.Unregister(rig2.Manager);
            rig.Engine.Register(rig2.Manager);
            rig2.Manager.TorrentStateChanged += delegate(object sender, TorrentStateChangedEventArgs e)
            {
                if (e.OldState == TorrentState.Hashing)
                    handle.Set();
            };
            rig2.Manager.HashCheck(true);
            handle.WaitOne();
            rig2.Dispose();
        }
Exemplo n.º 9
0
 public void Setup()
 {
     Rig = TestRig.CreateSingleFile(Piece.BlockSize * 20, Piece.BlockSize * 2);
     Rig.Manager.Bitfield.Not ();
     Rig.Manager.Mode = new InitialSeedingMode(Rig.Manager);
 }
Exemplo n.º 10
0
 public void FixtureSetup()
 {
     rig = new TestRig("");
 }
Exemplo n.º 11
0
 public void FixtureSetup()
 {
     buffer = new byte[100000];
     testRig = TestRig.CreateMultiFile();
 }
Exemplo n.º 12
0
 public void Setup()
 {
     rig = new TestRig("", new TestWriter());
     conn = new ConnectionPair(51515);
 }
Exemplo n.º 13
0
 public void FixtureSetup()
 {
     rig = TestRig.CreateMultiFile();
     id = new PeerId(new Peer(new string('a', 20), new Uri("tcp://BLAH")), rig.Manager);
     id.BitField.SetAll(true);
 }
Exemplo n.º 14
0
 public void FixtureSetup()
 {
     rig = TestRig.CreateMultiFile();
     diskManager = rig.Engine.DiskManager;
 }
Exemplo n.º 15
0
 public void FixtureSetup()
 {
     buffer = new byte[100000];
     testRig = new TestRig("Downloads");
 }
Exemplo n.º 16
0
 public void FixtureSetup()
 {
     rig         = TestRig.CreateMultiFile();
     diskManager = rig.Engine.DiskManager;
 }
Exemplo n.º 17
0
 public void GlobalSetup()
 {
     rig = TestRig.CreateMultiFile();
 }
Exemplo n.º 18
0
 public void GlobalSetup()
 {
     rig = new TestRig("Downloads", PieceSize, null);
 }
Exemplo n.º 19
0
 public void Setup()
 {
     rig  = TestRig.CreateMultiFile(new TestWriter());
     conn = new ConnectionPair().WithTimeout();
 }
Exemplo n.º 20
0
 public void Setup()
 {
     rig = TestRig.CreateMultiFile (new TestWriter());
     conn = new ConnectionPair(51515);
 }
Exemplo n.º 21
0
 public void FixtureSetup()
 {
     rig = TestRig.CreateMultiFile();
     id  = new PeerId(new Peer(new string('a', 20), new Uri("tcp://BLAH")), rig.Manager);
     id.BitField.SetAll(true);
 }
Exemplo n.º 22
0
 public void FixtureSetup()
 {
     rig = TestRig.CreateMultiFile();
 }
Exemplo n.º 23
0
 public void GlobalSetup()
 {
     rig = TestRig.CreateMultiFile();
 }
Exemplo n.º 24
0
        public void SingleFileTorrent()
        {
            rig.Dispose();
            rig = TestRig.CreateSingleFile();
            string url = rig.Torrent.GetRightHttpSeeds[0];
            connection = new HttpConnection(new Uri (url));
            connection.Manager = rig.Manager;

            id = new PeerId(new Peer("this is my id", connection.Uri), rig.Manager);
            id.Connection = connection;
            id.IsChoking = false;
            id.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]);
        }
Exemplo n.º 25
0
 public void Setup()
 {
     rig  = TestRig.CreateMultiFile(new TestWriter());
     conn = new ConnectionPair(51515);
 }
Exemplo n.º 26
0
 public void FixtureSetup()
 {
     rig = TestRig.CreateMultiFile();
     id = new PeerId(new Peer("peerid", new Uri("tcp://weburl.com")), rig.Manager);
     other = new PeerId(new Peer("other", new Uri("tcp://other.com")), rig.Manager);
 }
Exemplo n.º 27
0
 public void FixtureSetup()
 {
     rig = TestRig.CreateMultiFile();
 }
Exemplo n.º 28
0
 public void Setup()
 {
     pair = new ConnectionPair(55432);
     rig = new TestRig("");
     rig.Manager.Start();
 }
Exemplo n.º 29
0
 public void Setup()
 {
     Rig = TestRig.CreateSingleFile(Piece.BlockSize * 20, Piece.BlockSize * 2);
     Rig.Manager.Bitfield.Not();
     Rig.Manager.Mode = new InitialSeedingMode(Rig.Manager);
 }