From: Christian Heller Date: Thu, 2 Oct 2025 21:02:55 +0000 (+0200) Subject: Add exponential-wait-timed auto-retries test; remove any wait times from ping timeout... X-Git-Url: https://plomlompom.com/repos/?a=commitdiff_plain;h=d0fdceb995de5806462af3dd93d1fbb2db6ec797;p=ircplom Add exponential-wait-timed auto-retries test; remove any wait times from ping timeouts test. --- diff --git a/src/tests/_pingpong.test b/src/tests/_pingpong.test deleted file mode 100644 index a468f57..0000000 --- a/src/tests/_pingpong.test +++ /dev/null @@ -1,66 +0,0 @@ -> /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 -, .$ DISCONNECTED -1 .$ hostname set to: [foo.bar.baz] -1 .$ port set to: [-1] -1 .$ nick_wanted set to: [foo] -1 .$ user_wanted set to: [foobarbazquux] -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 -| 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] -repeat isupport-clear-in isupport-clear-out -1 .$ connection_state set to: [] -2 .$ DISCONNECTED -| full-timeout-out - -# on (automatic!) re-connect, ensure timer cleared, so won't trigger already on 1st timeout -| conn2-in -1 .!$ will retry connecting in 1 seconds -repeat conn0-in conn0-out -2 .$ CONNECTED -repeat conn1-in conn1-out -| conn2-out -repeat full-timeout-in full-timeout-out - -# after proof that a full double-timeout was necessary, we again automatically re-connect before our /quit gets processed … -repeat conn2-in conn2-out - -> /quit -0 .< diff --git a/src/tests/_timeout_retries.test b/src/tests/_timeout_retries.test new file mode 100644 index 0000000..ef26217 --- /dev/null +++ b/src/tests/_timeout_retries.test @@ -0,0 +1,88 @@ +# NB: FakeIrcConnection on any port > 10000 will fail connecting with a timeout +# the TestingClient meanwhile will decrement any port of that range by 1 after +# each started connection attempt +> /connect foo.bar.baz:10003 foo:bar baz:foobarbazquux + +| clientwin-init-in +| 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 +| clientwin-init-out +, .$ DISCONNECTED +1 .$ hostname set to: [foo.bar.baz] +| conn-init-retries-in +1 .$ port set to: [10003] +1 .$ nick_wanted set to: [foo] +1 .$ user_wanted set to: [foobarbazquux] +1 .$ realname set to: [baz] +1 .$ password set to: [bar] + +1 .$ connection_state set to: [connecting] +1 .$ port set to: [10002] +1 .$ connection_state set to: [failed to connect: FAKE TESTING TIMEOUT] +1 .!$ will retry connecting in 1 seconds + +1 .$ connection_state set to: [connecting] +1 .$ port set to: [10001] +1 .$ connection_state set to: [failed to connect: FAKE TESTING TIMEOUT] +1 .!$ will retry connecting in 2 seconds + +1 .$ connection_state set to: [connecting] +1 .$ port set to: [10000] +1 .$ connection_state set to: [failed to connect: FAKE TESTING TIMEOUT] +1 .!$ will retry connecting in 4 seconds +| conn-init-retries-out + +# with TestingClient finally having reduced port to 10000, connecting works now +| conn-full-in +| 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 +| conn1-out +| conn-full-out + +# test retry chain also started by in-connection timeout +<0 FAKE_IRC_CONN_TIMEOUT_EXCEPTION +1 .> PING :what's up? +<0 FAKE_IRC_CONN_TIMEOUT_EXCEPTION +1 .$ connection_state set to: [broken: no timely PONG from server] +repeat isupport-clear-in isupport-clear-out +1 .$ connection_state set to: [] +, .$ DISCONNECTED +1 .!$ will retry connecting in 1 seconds +repeat conn-full-in conn-full-out + +> /window 1 +> /disconnect +1 .> QUIT :ircplom says bye + +> /connect baz.bar.foo:10003 foo:bar baz:foobarbazquux +repeat clientwin-init-in clientwin-init-out 2 +, .$ DISCONNECTED +2 .$ hostname set to: [baz.bar.foo] +repeat conn-init-retries-in conn-init-retries-out 2 + +> /window 2 +> /reconnect +repeat conn0-in conn0-out 2 +, .$ CONNECTED +repeat conn1-in conn1-out 2 +wait 4 +> /disconnect +2 .> QUIT :ircplom says bye +wait 4 + +> /quit +0 .< diff --git a/src/tests/pingpong.test b/src/tests/pingpong.test new file mode 100644 index 0000000..8af1576 --- /dev/null +++ b/src/tests/pingpong.test @@ -0,0 +1,63 @@ +> /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 +, .$ DISCONNECTED +1 .$ hostname set to: [foo.bar.baz] +1 .$ port set to: [-1] +1 .$ nick_wanted set to: [foo] +1 .$ user_wanted set to: [foobarbazquux] +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 +| conn1-out + +# ensure we PONG properly +:0:1 .< PING :? +1 .> PONG :? + +# ping on timeout, go on as normal if PONG received +| full-timeout-in +| 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 +repeat trigger-ping-in trigger-ping-out +<0 FAKE_IRC_CONN_TIMEOUT_EXCEPTION +1 .$ connection_state set to: [broken: no timely PONG from server] +repeat isupport-clear-in isupport-clear-out +1 .$ connection_state set to: [] +2 .$ DISCONNECTED +1 .!$ will retry connecting in 1 seconds +| full-timeout-out + +# on re-connect, ensure timer cleared, i.e. only 2nd time-out will disconnect +> /window 1 +> /reconnect +repeat conn0-in conn0-out +2 .$ CONNECTED +repeat conn1-in conn1-out +repeat full-timeout-in full-timeout-out + +> /quit +0 .<