mirror of
https://github.com/3proxy/3proxy.git
synced 2026-10-28 22:05:48 +08:00
Tests: udploop's silence counted from the last answer
The last datagram's time was taken after the sleep following it, half a second and a slow runner's overshoot late, so a session ending on time looked early. The test resolver no longer raises when its socket is closed under it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e619a105b4
commit
83d8138818
@ -81,7 +81,11 @@ def fake_name_server(answer, tcp=False, wrongid=False):
|
||||
reply = dns_reply(data, answer)
|
||||
if wrongid:
|
||||
reply = bytes([reply[0] ^ 0x55, reply[1]]) + reply[2:]
|
||||
sock.sendto(reply, peer)
|
||||
try:
|
||||
sock.sendto(reply, peer)
|
||||
except OSError:
|
||||
# closed once the case is done with it
|
||||
return
|
||||
|
||||
if tcp:
|
||||
sock.listen(8)
|
||||
@ -177,11 +181,13 @@ def run(t):
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
answered = 0
|
||||
for i in range(10):
|
||||
if i:
|
||||
time.sleep(0.5)
|
||||
if exchange(s, idle, f"k{i}".encode()) == f"echo:k{i}".encode():
|
||||
answered += 1
|
||||
time.sleep(0.5)
|
||||
# the silence counts from the last answer, not a sleep after it
|
||||
last = time.time()
|
||||
cport = s.getsockname()[1]
|
||||
last = time.time()
|
||||
t.eq(10, answered, "a datagram every half second for five seconds is answered")
|
||||
t.ok("and the session lives on through them") if not idle_ended() else \
|
||||
t.fail("and the session lives on through them", "no 00092 line", "ended")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user