-
-
Notifications
You must be signed in to change notification settings - Fork 395
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* MonoTorrent.Tests/Client/TestRig.cs:
* MonoTorrent.Tests/MonoTorrent.Tests.csproj: * MonoTorrent.Tests/Client/InitialSeedingModeTest.cs: * MonoTorrent/MonoTorrent.Client/Modes/InitialSeedingMode.cs: When switching from InitialSeeding mode to any other mode, ensure that all connected peers get an updated bitfield message. svn path=/trunk/bitsharp/; revision=157404
- Loading branch information
1 parent
8a8c28c
commit 3ac5f77
Showing
4 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
using MonoTorrent.Client.Messages.FastPeer; | ||
using MonoTorrent.Client.Messages.Standard; | ||
using MonoTorrent.Common; | ||
using NUnit.Framework; | ||
|
||
namespace MonoTorrent.Client | ||
{ | ||
[TestFixture] | ||
public class InitialSeedingModeTest | ||
{ | ||
InitialSeedingMode Mode { | ||
get { return Rig.Manager.Mode as InitialSeedingMode; } | ||
} | ||
|
||
TestRig Rig { | ||
get; set; | ||
} | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
Rig = TestRig.CreateSingleFile(Piece.BlockSize * 20, Piece.BlockSize * 2); | ||
Rig.Manager.Mode = new InitialSeedingMode(Rig.Manager); | ||
} | ||
|
||
[TearDown] | ||
public void Teardown() | ||
{ | ||
Rig.Dispose(); | ||
} | ||
|
||
[Test] | ||
public void SwitchingModesSendsHaves() | ||
{ | ||
Rig.Manager.Peers.ConnectedPeers.Add(Rig.CreatePeer(true, true)); | ||
Rig.Manager.Peers.ConnectedPeers.Add(Rig.CreatePeer(true, false)); | ||
|
||
var peer = Rig.CreatePeer(true); | ||
peer.BitField.SetAll(true); | ||
Mode.HandlePeerConnected(peer, Direction.Incoming); | ||
Mode.Tick(0); | ||
|
||
Assert.IsTrue(Rig.Manager.Peers.ConnectedPeers[0].Dequeue() is HaveAllMessage, "#1"); | ||
BitfieldMessage m = (BitfieldMessage) Rig.Manager.Peers.ConnectedPeers[1].Dequeue(); | ||
Assert.IsTrue(m.BitField.AllTrue, "#2"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters