From d0fdceb995de5806462af3dd93d1fbb2db6ec797 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Thu, 2 Oct 2025 23:02:55 +0200 Subject: [PATCH] Add exponential-wait-timed auto-retries test; remove any wait times from ping timeouts test. --- src/tests/_timeout_retries.test | 88 +++++++++++++++++++++ src/tests/{_pingpong.test => pingpong.test} | 15 ++-- 2 files changed, 94 insertions(+), 9 deletions(-) create mode 100644 src/tests/_timeout_retries.test rename src/tests/{_pingpong.test => pingpong.test} (85%) 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 similarity index 85% rename from src/tests/_pingpong.test rename to src/tests/pingpong.test index a468f57..8af1576 100644 --- a/src/tests/_pingpong.test +++ b/src/tests/pingpong.test @@ -25,13 +25,14 @@ 1 .> CAP LS :302 1 .> USER foobarbazquux 0 * :baz 1 .> NICK :foo +| conn1-out # ensure we PONG properly :0:1 .< PING :? 1 .> PONG :? -| conn1-out # 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? @@ -41,26 +42,22 @@ 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 +1 .!$ will retry connecting in 1 seconds | 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 +# 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 -| 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 .< -- 2.30.2