Skip to content

Commit

Permalink
Fix minor bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
limebell committed Jun 24, 2021
1 parent 64996fb commit d438b1e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Libplanet.Tests/Net/Messages/MessageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public void UseInvalidSignature()
validAppProtocolVersion,
ImmutableHashSet<PublicKey>.Empty,
null,
TimeSpan.FromSeconds(1));
TimeSpan.FromSeconds(5));
});
}

Expand Down
8 changes: 7 additions & 1 deletion Libplanet.Tests/Net/Transports/TransportTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Immutable;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Threading.Tasks;
using Libplanet.Crypto;
Expand Down Expand Up @@ -343,11 +344,16 @@ public async Task SendMessageToInvalidPeerAsync()
try
{
await InitializeAsync(transport);
// Make sure the tcp port is invalid.
var l = new TcpListener(IPAddress.Loopback, 0);
l.Start();
int port = ((IPEndPoint)l.LocalEndpoint).Port;
l.Stop();
var peer = new BoundPeer(
new PrivateKey().PublicKey,
new DnsEndPoint(
"0.0.0.0",
((BoundPeer)transport.AsPeer).EndPoint.Port + 1));
port));
Task task = transport.SendMessageWithReplyAsync(
peer,
new Ping(),
Expand Down
3 changes: 2 additions & 1 deletion Libplanet/Net/Swarm.BlockSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ CancellationToken cancellationToken
logSessionIds: (logSessionId, subSessionId),
cancellationToken: cancellationToken
);
IEnumerable<Tuple<long, BlockHash>> hashes = await hashesAsync.ToArrayAsync();
IEnumerable<Tuple<long, BlockHash>> hashes =
await hashesAsync.ToArrayAsync(cancellationToken);

if (!hashes.Any())
{
Expand Down

0 comments on commit d438b1e

Please sign in to comment.