public void Setup() { Rig = TestRig.CreateSingleFile(Piece.BlockSize * 20, Piece.BlockSize * 2); Rig.Manager.Bitfield.Not(); Rig.Manager.UnhashedPieces.SetAll(false); Rig.Manager.Mode = new InitialSeedingMode(Rig.Manager, Rig.Engine.DiskManager, Rig.Engine.ConnectionManager, Rig.Engine.Settings); }
public async Task Setup(bool metadataMode, bool multiFile = false, bool metadataOnly = false) { pair = new ConnectionPair().WithTimeout(); rig = multiFile ? TestRig.CreateMultiFile(32768, metadataMode) : TestRig.CreateSingleFile(1024 * 1024 * 1024, 32768, metadataMode); rig.RecreateManager().Wait(); rig.Manager.HashChecked = true; await rig.Manager.StartAsync(metadataOnly); rig.AddConnection(pair.Outgoing); var connection = pair.Incoming; PeerId id = new PeerId(new Peer("", connection.Uri), connection, rig.Manager.Bitfield?.Clone().SetAll(false)); var result = await EncryptorFactory.CheckIncomingConnectionAsync(id.Connection, id.Peer.AllowedEncryption, new[] { rig.Manager.InfoHash }); decryptor = id.Decryptor = result.Decryptor; encryptor = id.Encryptor = result.Encryptor; }
public async Task Setup(bool metadataMode, bool multiFile = false, bool metadataOnly = false) { pair = new ConnectionPair().WithTimeout(); rig = multiFile ? TestRig.CreateMultiFile(32768, metadataMode) : TestRig.CreateSingleFile(Piece.BlockSize * 27, Piece.BlockSize * 2, metadataMode); rig.RecreateManager().Wait(); // Mark the torrent as hash check complete with no data downloaded if (rig.Manager.HasMetadata) { rig.Manager.LoadFastResume(new FastResume(rig.Manager.InfoHash, rig.Manager.Bitfield.Clone().SetAll(false), rig.Manager.Bitfield.Clone().SetAll(false))); } await rig.Manager.StartAsync(metadataOnly); rig.AddConnection(pair.Outgoing); var connection = pair.Incoming; PeerId id = new PeerId(new Peer("", connection.Uri), connection, rig.Manager.Bitfield?.Clone().SetAll(false)); var result = await EncryptorFactory.CheckIncomingConnectionAsync(id.Connection, id.Peer.AllowedEncryption, new[] { rig.Manager.InfoHash }); decryptor = id.Decryptor = result.Decryptor; encryptor = id.Encryptor = result.Encryptor; }