Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some DualMode connect test issues #56226

Merged
merged 3 commits into from
Jul 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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