From c0157865fe0d80c3acbac963e44be01a956bfaad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Sun, 20 Mar 2022 10:28:41 +0100 Subject: [PATCH] Fix optional test for `ENETUNREACH` error condition --- tests/TcpConnectorTest.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/tests/TcpConnectorTest.php b/tests/TcpConnectorTest.php index 0a9da7ca..8850646c 100644 --- a/tests/TcpConnectorTest.php +++ b/tests/TcpConnectorTest.php @@ -132,7 +132,7 @@ public function connectionToInvalidNetworkShouldFailWithUnreachableError() $errstr = ''; for ($i = 0; $i < 20 && $errno !== $enetunreach; ++$i) { $address = 'tcp://192.168.' . mt_rand(0, 255) . '.' . mt_rand(1, 254) . ':8123'; - $client = @stream_socket_client($address, $errno, $errstr, 0.1 * $i); + $client = @stream_socket_client($address, $errno, $errstr, 0.1); } if ($client || $errno !== $enetunreach) { $this->markTestSkipped('Expected error ' . $enetunreach . ' but got ' . $errno . ' (' . $errstr . ') for ' . $address); @@ -147,14 +147,7 @@ public function connectionToInvalidNetworkShouldFailWithUnreachableError() 'Connection to ' . $address . ' failed: ' . (function_exists('socket_strerror') ? socket_strerror($enetunreach) . ' (ENETUNREACH)' : 'Network is unreachable'), $enetunreach ); - - try { - Block\await($promise, null, self::TIMEOUT); - } catch (\Exception $e) { - fclose($client); - - throw $e; - } + Block\await($promise, null, self::TIMEOUT); } /** @test */