-
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from lizzypy/fix-tcp-socket-with-connect-timeout
Fix tcp socket with connect timeout
- Loading branch information
Showing
2 changed files
with
41 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative 'test_helper' | ||
|
||
class TCPSocketTest < Minitest::Test | ||
include HelperMethods | ||
|
||
if RUBY_VERSION.to_f >= 3.0 | ||
def test_tcp_socket_direct_connection_with_connection_timeout | ||
disable_socks | ||
|
||
socket = TCPSocket.new('127.0.0.1', 9050, connect_timeout: 0.1) | ||
|
||
assert !socket.closed? | ||
end | ||
|
||
def test_tcp_socket_socks_connection_with_connection_timeout | ||
enable_socks | ||
|
||
# leave off the host because we don't need to worry about connecting to socks | ||
socket = TCPSocket.new(connect_timeout: 0.1) | ||
|
||
assert !socket.closed? | ||
end | ||
end | ||
|
||
def test_tcp_socket_direct_connection_with_connection_timeout_no_kwargs | ||
disable_socks | ||
|
||
socket = TCPSocket.new('127.0.0.1', 9050) | ||
|
||
assert !socket.closed? | ||
end | ||
end |