Skip to content

Commit

Permalink
Revert "working on akkadotnet#3786 - made RemoteConnection_should_sen…
Browse files Browse the repository at this point in the history
…d_and_decode_messages async"

This reverts commit 72fce5c.
  • Loading branch information
Aaronontheweb committed May 21, 2019
1 parent 72fce5c commit ec73639
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
14 changes: 9 additions & 5 deletions src/core/Akka.Remote.TestKit.Tests/RemoteConnectionSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public RemoteConnectionSpecs() : base(Config)
}

[Fact]
public async Task RemoteConnection_should_send_and_decode_messages()
public void RemoteConnection_should_send_and_decode_messages()
{
var serverProbe = CreateTestProbe("server");
var clientProbe = CreateTestProbe("client");
Expand All @@ -50,13 +50,17 @@ public async Task RemoteConnection_should_send_and_decode_messages()

try
{
server = await RemoteConnection.CreateConnection(Role.Server, serverEndpoint, 3,
var t1 = RemoteConnection.CreateConnection(Role.Server, serverEndpoint, 3,
new TestConductorHandler(serverProbe.Ref));
t1.Wait(TimeSpan.FromSeconds(3)).Should().BeTrue();
server = t1.Result; // task will already be complete or cancelled

var reachableEndpoint = (IPEndPoint)server.LocalAddress;

client = await RemoteConnection.CreateConnection(Role.Client, reachableEndpoint, 3,
var t2 = RemoteConnection.CreateConnection(Role.Client, reachableEndpoint, 3,
new PlayerHandler(serverEndpoint, 2, TimeSpan.FromSeconds(1), 3, clientProbe.Ref, Log, Sys.Scheduler));
t2.Wait(TimeSpan.FromSeconds(3)).Should().BeTrue();
client = t2.Result; // task will already be completed or cancelled

serverProbe.ExpectMsg("active");
var serverClientChannel = serverProbe.ExpectMsg<IChannel>();
Expand All @@ -65,13 +69,13 @@ public async Task RemoteConnection_should_send_and_decode_messages()
var address = RARP.For(Sys).Provider.DefaultAddress;

// have the client send a message to the server
await client.WriteAndFlushAsync(new Hello("test", address));
client.WriteAndFlushAsync(new Hello("test", address));
var hello = serverProbe.ExpectMsg<Hello>();
hello.Name.Should().Be("test");
hello.Address.Should().Be(address);

// have the server send a message back to the client
await serverClientChannel.WriteAndFlushAsync(new Hello("test2", address));
serverClientChannel.WriteAndFlushAsync(new Hello("test2", address));
var hello2 = clientProbe.ExpectMsg<Hello>();
hello2.Name.Should().Be("test2");
hello2.Address.Should().Be(address);
Expand Down
6 changes: 3 additions & 3 deletions src/core/Akka.Remote.TestKit/RemoteConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private static IEventLoopGroup GetServerWorkerPool(int poolSize)
return _serverWorkerPool;
}

public static async Task<IChannel> CreateConnection(Role role, IPEndPoint socketAddress, int poolSize, IChannelHandler upstreamHandler)
public static Task<IChannel> CreateConnection(Role role, IPEndPoint socketAddress, int poolSize, IChannelHandler upstreamHandler)
{
if (role == Role.Client)
{
Expand All @@ -106,7 +106,7 @@ public static async Task<IChannel> CreateConnection(Role role, IPEndPoint socket
ApplyChannelPipeline(channel, upstreamHandler);
}));

return await connection.ConnectAsync(socketAddress).ConfigureAwait(false);
return connection.ConnectAsync(socketAddress);
}
else //server
{
Expand All @@ -118,7 +118,7 @@ public static async Task<IChannel> CreateConnection(Role role, IPEndPoint socket
{
ApplyChannelPipeline(channel, upstreamHandler);
}));
return await connection.BindAsync(socketAddress).ConfigureAwait(false);
return connection.BindAsync(socketAddress);
}
}

Expand Down

0 comments on commit ec73639

Please sign in to comment.