Fix some DualMode connect test issues (#56226)
authorAnton Firszov <Anton.Firszov@microsoft.com>
Mon, 26 Jul 2021 17:41:12 +0000 (19:41 +0200)
committerGitHub <noreply@github.com>
Mon, 26 Jul 2021 17:41:12 +0000 (19:41 +0200)
Fixes #55053, fixes #54677

src/libraries/System.Net.Sockets/tests/FunctionalTests/Connect.cs

index 01c6b48..69c8b9b 100644 (file)
@@ -84,7 +84,6 @@ namespace System.Net.Sockets.Tests
         }
 
         [Fact]
-        [ActiveIssue("https://github.com/dotnet/runtime/issues/55053", TestPlatforms.Linux)]
         public async Task Connect_DualMode_MultiAddressFamilyConnect_RetrievedEndPoints_Success()
         {
             if (!SupportsMultiConnect)
@@ -96,21 +95,14 @@ namespace System.Net.Sockets.Tests
             {
                 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()
         {
@@ -127,19 +119,20 @@ namespace System.Net.Sockets.Tests
             {
                 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()
         {