Skip to content

Commit

Permalink
Add timeout to SwarmTest
Browse files Browse the repository at this point in the history
  • Loading branch information
longfin committed Apr 30, 2019
1 parent 6276892 commit 2800642
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions Libplanet.Tests/Net/SwarmTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace Libplanet.Tests.Net
{
public class SwarmTest : IDisposable
{
private const int TestTimeout = 30 * 1000;
private readonly FileStoreFixture _fx1;
private readonly FileStoreFixture _fx2;
private readonly FileStoreFixture _fx3;
Expand Down Expand Up @@ -81,7 +82,7 @@ public void Dispose()
}
}

[Fact]
[Fact(Timeout = TestTimeout)]
public async Task CanNotStartTwice()
{
Swarm swarm = _swarms[0];
Expand All @@ -98,7 +99,7 @@ public async Task CanNotStartTwice()
await swarm.StopAsync();
}

[Fact]
[Fact(Timeout = TestTimeout)]
public async Task CanStop()
{
Swarm swarm = _swarms[0];
Expand All @@ -114,7 +115,7 @@ public async Task CanStop()
await task;
}

[Fact]
[Fact(Timeout = TestTimeout)]
public async Task CanWaitForRunning()
{
Swarm swarm = _swarms[0];
Expand Down Expand Up @@ -142,7 +143,7 @@ public async Task CanWaitForRunning()
Assert.False(swarm.Running);
}

[Fact]
[Fact(Timeout = TestTimeout)]
public async Task BroadcastWhileMining()
{
Swarm a = _swarms[0];
Expand Down Expand Up @@ -208,7 +209,7 @@ CancellationToken cancellationToken
chainB.AsEnumerable().ToHashSet());
}

[Fact]
[Fact(Timeout = TestTimeout)]
public async Task CanExchangePeer()
{
Swarm a = _swarms[0];
Expand Down Expand Up @@ -265,7 +266,7 @@ public async Task CanExchangePeer()
}
}

[Fact]
[Fact(Timeout = TestTimeout)]
public async Task WorksAsCollection()
{
Swarm a = _swarms[0];
Expand Down Expand Up @@ -310,7 +311,7 @@ await Task.WhenAll(
peers.ToHashSet());
}

[Fact]
[Fact(Timeout = TestTimeout)]
public async Task DetectAppProtocolVersion()
{
var a = new Swarm(
Expand Down Expand Up @@ -360,7 +361,7 @@ public async Task DetectAppProtocolVersion()
}
}

[Fact]
[Fact(Timeout = TestTimeout)]
public async Task HandleDifferentAppProtocolVersion()
{
var isCalled = false;
Expand Down Expand Up @@ -398,7 +399,7 @@ void GameHandler(object sender, DifferentProtocolVersionEventArgs e)
}
}

[Fact]
[Fact(Timeout = TestTimeout)]
public async Task CanBeCancelled()
{
Swarm swarm = _swarms[0];
Expand All @@ -416,7 +417,7 @@ public async Task CanBeCancelled()
Assert.False(swarm.Running);
}

[Fact]
[Fact(Timeout = TestTimeout)]
public async Task CanGetBlock()
{
Swarm swarmA = _swarms[0];
Expand Down Expand Up @@ -478,7 +479,7 @@ await Task.WhenAll(
}
}

[Fact]
[Fact(Timeout = TestTimeout)]
public async Task GetTx()
{
Swarm swarmA = _swarms[0];
Expand Down Expand Up @@ -520,7 +521,7 @@ await Task.WhenAll(
}
}

[Fact]
[Fact(Timeout = TestTimeout)]
public async Task BroadcastTx()
{
Swarm swarmA = _swarms[0];
Expand Down Expand Up @@ -569,7 +570,7 @@ await Task.WhenAll(
}
}

[Fact]
[Fact(Timeout = TestTimeout)]
public async Task CanBroadcastBlock()
{
Swarm swarmA = _swarms[0];
Expand Down Expand Up @@ -638,7 +639,7 @@ await Task.WhenAll(
}
}

[Fact]
[Fact(Timeout = TestTimeout)]
public void ThrowArgumentExceptionInConstructor()
{
Assert.Throws<ArgumentNullException>(() =>
Expand All @@ -662,7 +663,7 @@ public void ThrowArgumentExceptionInConstructor()
});
}

[Fact]
[Fact(Timeout = TestTimeout)]
public void CanResolveEndPoint()
{
var expected = new DnsEndPoint("1.2.3.4", 5678);
Expand All @@ -676,7 +677,7 @@ public void CanResolveEndPoint()
Assert.Equal(expected, s.AsPeer.EndPoint);
}

[Fact]
[Fact(Timeout = TestTimeout)]
public async Task CanStopGracefullyWhileStarting()
{
Swarm a = _swarms[0];
Expand All @@ -689,7 +690,7 @@ public async Task CanStopGracefullyWhileStarting()
await Task.WhenAll(a.StopAsync(), t);
}

[Fact]
[Fact(Timeout = TestTimeout)]
public async Task AsPeerThrowSwarmExceptionWhenUnbound()
{
Swarm swarm = new Swarm(
Expand Down Expand Up @@ -746,7 +747,7 @@ await Task.WhenAll(
}
}

[Fact]
[Fact(Timeout = TestTimeout)]
public async Task InitialBlockDownload()
{
Swarm minerSwarm = _swarms[0];
Expand Down Expand Up @@ -779,7 +780,7 @@ await Task.WhenAll(
}
}

[Fact]
[Fact(Timeout = TestTimeout)]
public async Task Preload()
{
Swarm minerSwarm = _swarms[0];
Expand Down

0 comments on commit 2800642

Please sign in to comment.