Skip to content

Commit

Permalink
Merge pull request #578 from alexppxela/test/acceptance-random-discon…
Browse files Browse the repository at this point in the history
…nected-peer

Acceptance test result must be predictable
  • Loading branch information
ackleymi authored Oct 24, 2023
2 parents bc6d66a + 216c3e3 commit e4cffe0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
14 changes: 9 additions & 5 deletions _test/ReflectorClient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,15 @@ def @reflector.waitConnectAction(cid)
end

def @reflector.waitDisconnectAction(cid)
socket = @sockets[cid]
if IO.select([socket], nil, nil, 10) == nil then
raise "Connection hangs after ten seconds."
elsif !socket.eof? then
raise "Expected disconnection, got data"
begin
socket = @sockets[cid]
if IO.select([socket], nil, nil, 10) == nil then
raise "Connection hangs after ten seconds."
elsif !socket.eof? then
raise "Expected disconnection, got data"
end
rescue Errno::ECONNRESET
# Ignore, server has already disconnected the socket
end
end

Expand Down
12 changes: 8 additions & 4 deletions _test/ReflectorServer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,14 @@ def @reflector.waitConnectAction(cid)
end

def @reflector.waitDisconnectAction(cid)
if IO.select([@socket], nil, nil, 10) == nil then
raise "Connection hangs after five seconds."
elsif !@socket.eof? then
raise "Expected disconnection, got data"
begin
if IO.select([@socket], nil, nil, 10) == nil then
raise "Connection hangs after five seconds."
elsif !@socket.eof? then
raise "Expected disconnection, got data"
end
rescue Errno::ECONNRESET
# Ignore, client has already disconnected the socket
end
end

Expand Down

0 comments on commit e4cffe0

Please sign in to comment.