Skip to content

Commit

Permalink
Fix some DualMode connect test issues (#56226)
Browse files Browse the repository at this point in the history
Fixes #55053, fixes #54677
  • Loading branch information
antonfirsov committed Jul 26, 2021
1 parent a2235e7 commit a85d36f
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions src/libraries/System.Net.Sockets/tests/FunctionalTests/Connect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public async Task Connect_MultipleIPAddresses_Success(IPAddress listenAt)
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/55053", TestPlatforms.Linux)]
public async Task Connect_DualMode_MultiAddressFamilyConnect_RetrievedEndPoints_Success()
{
if (!SupportsMultiConnect)
Expand All @@ -96,21 +95,14 @@ public async Task Connect_DualMode_MultiAddressFamilyConnect_RetrievedEndPoints_
{
Assert.True(client.DualMode);

Task connectTask = MultiConnectAsync(client, new IPAddress[] { IPAddress.IPv6Loopback, IPAddress.Loopback }, port);
await connectTask;

var localEndPoint = client.LocalEndPoint as IPEndPoint;
Assert.NotNull(localEndPoint);
Assert.Equal(IPAddress.Loopback.MapToIPv6(), localEndPoint.Address);
await MultiConnectAsync(client, new IPAddress[] { IPAddress.IPv6Loopback, IPAddress.Loopback }, port);

var remoteEndPoint = client.RemoteEndPoint as IPEndPoint;
Assert.NotNull(remoteEndPoint);
Assert.Equal(IPAddress.Loopback.MapToIPv6(), remoteEndPoint.Address);
CheckIsIpv6LoopbackEndPoint(client.LocalEndPoint);
CheckIsIpv6LoopbackEndPoint(client.RemoteEndPoint);
}
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/54677", TestPlatforms.Linux)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/55709", TestPlatforms.Linux)]
public async Task Connect_DualMode_DnsConnect_RetrievedEndPoints_Success()
{
Expand All @@ -127,19 +119,20 @@ public async Task Connect_DualMode_DnsConnect_RetrievedEndPoints_Success()
{
Assert.True(client.DualMode);

Task connectTask = ConnectAsync(client, new DnsEndPoint("localhost", port));
await connectTask;

var localEndPoint = client.LocalEndPoint as IPEndPoint;
Assert.NotNull(localEndPoint);
Assert.True(localEndPoint.Address.Equals(IPAddress.IPv6Loopback) || localEndPoint.Address.Equals(IPAddress.Loopback.MapToIPv6()));
await ConnectAsync(client, new DnsEndPoint("localhost", port));

var remoteEndPoint = client.RemoteEndPoint as IPEndPoint;
Assert.NotNull(remoteEndPoint);
Assert.Equal(IPAddress.Loopback.MapToIPv6(), remoteEndPoint.Address);
CheckIsIpv6LoopbackEndPoint(client.LocalEndPoint);
CheckIsIpv6LoopbackEndPoint(client.RemoteEndPoint);
}
}

private static void CheckIsIpv6LoopbackEndPoint(EndPoint endPoint)
{
IPEndPoint ep = endPoint as IPEndPoint;
Assert.NotNull(ep);
Assert.True(ep.Address.Equals(IPAddress.IPv6Loopback) || ep.Address.Equals(IPAddress.Loopback.MapToIPv6()));
}

[Fact]
public async Task Connect_OnConnectedSocket_Fails()
{
Expand Down

0 comments on commit a85d36f

Please sign in to comment.