Skip to content

Commit

Permalink
Add regression test for depth [skip changelog]
Browse files Browse the repository at this point in the history
  • Loading branch information
limebell committed Sep 8, 2020
1 parent 5b673f2 commit 30535f1
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Libplanet.Tests/Net/SwarmTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1992,6 +1992,50 @@ public async Task FindSpecificPeerAsyncFail()
}
}

[Fact(Timeout = Timeout)]
public async Task FindSpecificPeerAsyncDepthFail()
{
Swarm<DumbAction> swarmA = _swarms[0];
Swarm<DumbAction> swarmB = _swarms[1];
Swarm<DumbAction> swarmC = _swarms[2];
Swarm<DumbAction> swarmD = _swarms[3];
try
{
await StartAsync(swarmA);
await StartAsync(swarmB);
await StartAsync(swarmC);
await StartAsync(swarmD);

await swarmA.AddPeersAsync(new Peer[] { swarmB.AsPeer }, null);
await swarmB.AddPeersAsync(new Peer[] { swarmC.AsPeer }, null);
await swarmC.AddPeersAsync(new Peer[] { swarmD.AsPeer }, null);

BoundPeer foundPeer = await swarmA.FindSpecificPeerAsync(
swarmC.AsPeer.Address,
1,
TimeSpan.FromMilliseconds(3000));

Assert.Equal(swarmC.AsPeer.Address, foundPeer.Address);
((KademliaProtocol)swarmA.Protocol).ClearTable();
Assert.Empty(swarmA.Peers);
await swarmA.AddPeersAsync(new Peer[] { swarmB.AsPeer }, null);

foundPeer = await swarmA.FindSpecificPeerAsync(
swarmD.AsPeer.Address,
1,
TimeSpan.FromMilliseconds(3000));

Assert.Null(foundPeer);
}
finally
{
await StopAsync(swarmA);
await StopAsync(swarmB);
await StopAsync(swarmC);
await StopAsync(swarmD);
}
}

[Fact(Timeout = Timeout)]
public async Task DoNotFillMultipleTimes()
{
Expand Down

0 comments on commit 30535f1

Please sign in to comment.