Skip to content

Commit

Permalink
Merge pull request #288 from clue-labs/test-enetunreach
Browse files Browse the repository at this point in the history
Fix optional test for `ENETUNREACH` error condition
  • Loading branch information
WyriHaximus authored Apr 2, 2022
2 parents f9bc429 + c015786 commit dff5ac9
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 dff5ac9

Please sign in to comment.