Skip to content

Commit

Permalink
Fix optional test for ENETUNREACH error condition
Browse files Browse the repository at this point in the history
  • Loading branch information
clue committed Mar 22, 2022
1 parent f9bc429 commit c015786
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions tests/TcpConnectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 */
Expand Down

0 comments on commit c015786

Please sign in to comment.