Skip to content

Commit

Permalink
Fix a bug in TestTransport.ReceivedTestMessageOfData
Browse files Browse the repository at this point in the history
  • Loading branch information
limebell committed Jan 21, 2020
1 parent 7b4c9b8 commit 82bb570
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Libplanet.Tests/Net/Protocols/TestTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Immutable;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Libplanet.Crypto;
Expand Down Expand Up @@ -251,10 +252,14 @@ public void BroadcastTestMessage(Address? except, string data)
public void BroadcastMessage(Address? except, Message message)
{
var peers = Protocol.PeersToBroadcast(except).ToList();
var peersString = peers.Aggregate(
new StringBuilder(),
(builder, peer) => builder.Append($"{peer.Address.ToHex()}, ")).ToString();
_logger.Debug(
"Broadcasting test message {Data} to {Count} peers.",
"Broadcasting test message {Data} to {Count} peers which are: {Peers}.",
((TestMessage)message).Data,
peers.Count);
peers.Count,
peersString);
foreach (var peer in peers)
{
_requests.Add(new Request()
Expand Down Expand Up @@ -394,7 +399,7 @@ public bool ReceivedTestMessageOfData(string data)
throw new SwarmException("Start swarm before use.");
}

return ReceivedMessages.OfType<TestMessage>().Select(msg => msg.Data == data).Any();
return ReceivedMessages.OfType<TestMessage>().Any(msg => msg.Data == data);
}

private void ReceiveMessage(Message message)
Expand Down

0 comments on commit 82bb570

Please sign in to comment.