home · contact · privacy
Reset ping-timeout timer on each connection start.
authorChristian Heller <c.heller@plomlompom.de>
Wed, 1 Oct 2025 03:52:09 +0000 (05:52 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 1 Oct 2025 03:52:09 +0000 (05:52 +0200)
src/ircplom/client.py
src/ircplom/testing.py
src/tests/pingpong.txt

index d8e59b7a71e247b8a201463a75aadd5c6427c09d..ed522194d96865fbfa797efeb5322ae4971d6e62 100644 (file)
@@ -817,7 +817,7 @@ class Client(ABC, ClientQueueMixin):
     'Abstracts socket connection, loop over it, and handling messages from it.'
     conn: Optional[IrcConnection] = None
     _cls_conn: type[IrcConnection] = IrcConnection
-    _expected_pong = ''
+    _expected_pong: str
 
     def __init__(self, conn_setup: IrcConnSetup, channels: set[str], **kwargs
                  ) -> None:
@@ -849,6 +849,7 @@ class Client(ABC, ClientQueueMixin):
             except Exception as e:  # pylint: disable=broad-exception-caught
                 self._put(ExceptionEvent(CrashingException(e)))
             else:
+                self._expected_pong = ''
                 self.db.connection_state = 'connected'
                 self.caps.start_negotation()
                 self.send('USER', self.db.user_wanted,
index f7db844b7edefe9432b2fcc56ac7a821cb16097a..c8bfdd6cc2de48b06e1d9cd2db012127155827fb 100644 (file)
@@ -194,7 +194,7 @@ class _Playbook:
                 self.put_keypress('KEY_ENTER')
             elif context.startswith(_CHAR_SERVER_MSG):
                 client = self._get_client(int(context[1:]))
-                assert isinstance(client.conn, _FakeIrcConnection)
+                assert isinstance(client.conn, _FakeIrcConnection), client.conn
                 client.conn.put_server_msg(msg)
             else:
                 break
index f0e27fac32fc71c062ae6d537b0fb048b660bd3f..6f554688904549385f9bb414f46922141d4f5252 100644 (file)
@@ -1,8 +1,10 @@
 > /connect foo.bar.baz foo:bar baz:foobarbazquux
+| isupport-clear-in
 1 .$ isupport cleared
 1 .$ isupport:CHANTYPES set to: [#&]
 1 .$ isupport:PREFIX set to: [(ov)@+]
 1 .$ isupport:USERLEN set to: [10]
+| isupport-clear-out
 1 .$ caps cleared
 1 .$ users cleared
 1 .$ channels cleared
 1 .$ realname set to: [baz]
 1 .$ password set to: [bar]
 1 .$ port set to: [6697]
+| conn0-in
 1 .$ connection_state set to: [connecting]
 1 .$ connection_state set to: [connected]
+| conn0-out
 , .$ CONNECTED
+| conn1-in
 1 .> CAP LS :302
 1 .> USER foobarbazquux 0 * :baz
 1 .> NICK :foo
 # ensure we PONG properly
 :0:1 .< PING :?
 1 .> PONG :?
+| conn1-out
 
 # ping on timeout, go on as normal if PONG received 
+| trigger-ping-in
 <0 FAKE_IRC_CONN_TIMEOUT_EXCEPTION
 1 .> PING :what's up?
+| trigger-ping-out
 :0:1 .< :*.?.net PONG *.?.net :what's up?
 :0:1 .< :*.?.net NOTICE * :*** Looking up your ident...
 2 .< *** [ server] *** Looking up your ident...
 
 # another timeout instead of pong? disconnect
-<0 FAKE_IRC_CONN_TIMEOUT_EXCEPTION
-1 .> PING :what's up?
+| full-timeout-in
+repeat trigger-ping-in trigger-ping-out
 <0 FAKE_IRC_CONN_TIMEOUT_EXCEPTION
 1 .$ connection_state set to: [broken: no timely PONG from server]
-1 .$ isupport cleared
-1 .$ isupport:CHANTYPES set to: [#&]
-1 .$ isupport:PREFIX set to: [(ov)@+]
-1 .$ isupport:USERLEN set to: [10]
+repeat isupport-clear-in isupport-clear-out
 1 .$ connection_state set to: []
 2 .$ DISCONNECTED
+| full-timeout-out
+
+# on re-connect, ensure timer cleared, so won't trigger already on 1st timeout
+> /window 1
+> /reconnect
+repeat conn0-in conn0-out
+2 .$ CONNECTED
+repeat conn1-in conn1-out
+repeat full-timeout-in full-timeout-out
 
 > /quit
 0 .<