>From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Thu, 30 Sep 2021 03:28:54 -0700 Subject: [PATCH 18/28] SQUASH-ME: Add ERC test scenarios for session-aware autojoin XXX this commit should not stand alone. It should be squashed or fixup'd into "Favor session IDs and networks in erc-join.el" --- .../base/session-id/autojoin/barnet.lispdata | 43 +++++ .../session-id/autojoin/foonet-again.lispdata | 43 +++++ .../base/session-id/autojoin/foonet.lispdata | 39 ++++ test/lisp/erc/erc-scenarios.el | 170 ++++++++++++++++++ 4 files changed, 295 insertions(+) create mode 100644 test/lisp/erc/erc-scenarios-resources/base/session-id/autojoin/barnet.lispdata create mode 100644 test/lisp/erc/erc-scenarios-resources/base/session-id/autojoin/foonet-again.lispdata create mode 100644 test/lisp/erc/erc-scenarios-resources/base/session-id/autojoin/foonet.lispdata diff --git a/test/lisp/erc/erc-scenarios-resources/base/session-id/autojoin/barnet.lispdata b/test/lisp/erc/erc-scenarios-resources/base/session-id/autojoin/barnet.lispdata new file mode 100644 index 0000000000..1a13259383 --- /dev/null +++ b/test/lisp/erc/erc-scenarios-resources/base/session-id/autojoin/barnet.lispdata @@ -0,0 +1,43 @@ +;; -*- mode: lisp-data; -*- +((pass 2 "PASS :barnet:changeme")) +((nick 2 "NICK tester")) +((user 1 "USER user 0 * :tester") + (0 ":irc.barnet.org 001 tester :Welcome to the barnet IRC Network tester") + (0 ":irc.barnet.org 002 tester :Your host is irc.barnet.org, running version oragono-2.6.0-7481bf0385b95b16") + (0 ":irc.barnet.org 003 tester :This server was created Mon, 10 May 2021 00:58:22 UTC") + (0 ":irc.barnet.org 004 tester irc.barnet.org oragono-2.6.0-7481bf0385b95b16 BERTZios CEIMRUabefhiklmnoqstuv Iabefhkloqv") + (0 ":irc.barnet.org 005 tester AWAYLEN=390 BOT=B CASEMAPPING=ascii CHANLIMIT=#:100 CHANMODES=Ibe,k,fl,CEMRUimnstu CHANNELLEN=64 CHANTYPES=# ELIST=U EXCEPTS EXTBAN=,m FORWARD=f INVEX KICKLEN=390 :are supported by this server") + (0 ":irc.barnet.org 005 tester MAXLIST=beI:60 MAXTARGETS=4 MODES MONITOR=100 NETWORK=barnet NICKLEN=32 PREFIX=(qaohv)~&@%+ STATUSMSG=~&@%+ TARGMAX=NAMES:1,LIST:1,KICK:1,WHOIS:1,USERHOST:10,PRIVMSG:4,TAGMSG:4,NOTICE:4,MONITOR:100 TOPICLEN=390 UTF8MAPPING=rfc8265 UTF8ONLY WHOX :are supported by this server") + (0 ":irc.barnet.org 005 tester draft/CHATHISTORY=100 :are supported by this server") + (0 ":irc.barnet.org 251 tester :There are 0 users and 3 invisible on 1 server(s)") + (0 ":irc.barnet.org 252 tester 0 :IRC Operators online") + (0 ":irc.barnet.org 254 tester 1 :channels formed") + (0 ":irc.barnet.org 255 tester :I have 3 clients and 0 servers") + (0 ":irc.barnet.org 265 tester 3 3 :Current local users 3, max 3") + (0 ":irc.barnet.org 266 tester 3 3 :Current global users 3, max 3") + (0 ":irc.barnet.org 422 tester :MOTD File is missing")) + +((mode-user 1.2 "MODE tester +i")) +;; No mode answer + +((join 2 "JOIN #chan") + (0 ":tester!~u@6yximxrnkg65a.irc JOIN #chan") + (0 ":irc.barnet.org 353 tester = #chan :@joe mike tester") + (0 ":irc.barnet.org 366 tester #chan :End of NAMES list") + (0.1 ":joe!~u@6yximxrnkg65a.irc PRIVMSG #chan :tester, welcome!") + (0 ":mike!~u@6yximxrnkg65a.irc PRIVMSG #chan :tester, welcome!")) + +((mode 1 "MODE #chan") + (0 ":irc.barnet.org 324 tester #chan +nt") + (0 ":irc.barnet.org 329 tester #chan 1620608304") + ;; Wait for foonet's buffer playback + (0.1 ":mike!~u@6yximxrnkg65a.irc PRIVMSG #chan :joe: Go take her hence, and marry her instantly.") + (0.1 ":joe!~u@6yximxrnkg65a.irc PRIVMSG #chan :mike: Of all the four, or the three, or the two, or one of the four.") + (0.1 ":mike!~u@6yximxrnkg65a.irc PRIVMSG #chan :joe: And gives the crutch the cradle's infancy.") + (0.1 ":joe!~u@6yximxrnkg65a.irc PRIVMSG #chan :mike: Such is the simplicity of man to hearken after the flesh.") + (0.05 ":mike!~u@6yximxrnkg65a.irc PRIVMSG #chan :joe: The leaf to read them. Let us toward the king.") + (0.05 ":joe!~u@6yximxrnkg65a.irc PRIVMSG #chan :mike: Many can brook the weather that love not the wind.") + (0.05 ":mike!~u@6yximxrnkg65a.irc PRIVMSG #chan :joe: And now, dear maid, be you as free to us.") + (0.00 ":joe!~u@6yximxrnkg65a.irc PRIVMSG #chan :mike: He hath an uncle here in Messina will be very much glad of it.")) + +((linger 3.5 LINGER)) diff --git a/test/lisp/erc/erc-scenarios-resources/base/session-id/autojoin/foonet-again.lispdata b/test/lisp/erc/erc-scenarios-resources/base/session-id/autojoin/foonet-again.lispdata new file mode 100644 index 0000000000..2f1c656311 --- /dev/null +++ b/test/lisp/erc/erc-scenarios-resources/base/session-id/autojoin/foonet-again.lispdata @@ -0,0 +1,43 @@ +;; -*- mode: lisp-data; -*- +((pass-redux 10 "PASS :foonet:changeme")) +((nick-redux 1 "NICK tester")) + +((user-redux 1 "USER user 0 * :tester") + (0 ":irc.foonet.org 001 tester :Welcome to the foonet IRC Network tester") + (0 ":irc.foonet.org 002 tester :Your host is irc.foonet.org, running version oragono-2.6.0-7481bf0385b95b16") + (0 ":irc.foonet.org 003 tester :This server was created Mon, 10 May 2021 00:58:22 UTC") + (0 ":irc.foonet.org 004 tester irc.foonet.org oragono-2.6.0-7481bf0385b95b16 BERTZios CEIMRUabefhiklmnoqstuv Iabefhkloqv") + (0 ":irc.foonet.org 005 tester AWAYLEN=390 BOT=B CASEMAPPING=ascii CHANLIMIT=#:100 CHANMODES=Ibe,k,fl,CEMRUimnstu CHANNELLEN=64 CHANTYPES=# ELIST=U EXCEPTS EXTBAN=,m FORWARD=f INVEX KICKLEN=390 :are supported by this server") + (0 ":irc.foonet.org 005 tester MAXLIST=beI:60 MAXTARGETS=4 MODES MONITOR=100 NETWORK=foonet NICKLEN=32 PREFIX=(qaohv)~&@%+ STATUSMSG=~&@%+ TARGMAX=NAMES:1,LIST:1,KICK:1,WHOIS:1,USERHOST:10,PRIVMSG:4,TAGMSG:4,NOTICE:4,MONITOR:100 TOPICLEN=390 UTF8MAPPING=rfc8265 UTF8ONLY WHOX :are supported by this server") + (0 ":irc.foonet.org 005 tester draft/CHATHISTORY=100 :are supported by this server") + (0 ":irc.foonet.org 251 tester :There are 0 users and 3 invisible on 1 server(s)") + (0 ":irc.foonet.org 252 tester 0 :IRC Operators online") + (0 ":irc.foonet.org 254 tester 1 :channels formed") + (0 ":irc.foonet.org 255 tester :I have 3 clients and 0 servers") + (0 ":irc.foonet.org 265 tester 3 3 :Current local users 3, max 3") + (0 ":irc.foonet.org 266 tester 3 3 :Current global users 3, max 3") + (0 ":irc.foonet.org 422 tester :MOTD File is missing")) + +((mode-user 1.2 "MODE tester +i") + ;; No mode answer ^ + + ;; History + (0 ":tester!~u@q6ddatxcq6txy.irc JOIN #chan") + (0 ":irc.foonet.org 353 tester = #chan :@alice bob tester") + (0 ":irc.foonet.org 366 tester #chan :End of /NAMES list.") + (0 ":***!znc@znc.in PRIVMSG #chan :Buffer Playback...") + (0 ":bob!~u@q6ddatxcq6txy.irc PRIVMSG #chan :[02:43:23] alice: And soar with them above a common bound.") + (0 ":alice!~u@q6ddatxcq6txy.irc PRIVMSG #chan :[02:43:27] bob: And be aveng'd on cursed Tamora.") + (0 ":bob!~u@q6ddatxcq6txy.irc PRIVMSG #chan :[02:43:29] alice: He did love her, sir, as a gentleman loves a woman.") + (0 ":***!znc@znc.in PRIVMSG #chan :Playback Complete.")) + +((mode-redux 1 "MODE #chan") + (0 ":irc.foonet.org 324 tester #chan +nt") + (0 ":irc.foonet.org 329 tester #chan 1620608304") + (0.1 ":alice!~u@q6ddatxcq6txy.irc PRIVMSG #chan :bob: Ay, madam, with the swiftest wing of speed.") + (0.1 ":bob!~u@q6ddatxcq6txy.irc PRIVMSG #chan :alice: Five times in that ere once in our five wits.") + (0.1 ":alice!~u@q6ddatxcq6txy.irc PRIVMSG #chan :bob: And bid him come to take his last farewell.") + (0.1 ":bob!~u@q6ddatxcq6txy.irc PRIVMSG #chan :alice: But we are spirits of another sort.") + (0.1 ":alice!~u@q6ddatxcq6txy.irc PRIVMSG #chan :bob: It was not given me, nor I did not buy it.")) + +((linger 6 LINGER)) diff --git a/test/lisp/erc/erc-scenarios-resources/base/session-id/autojoin/foonet.lispdata b/test/lisp/erc/erc-scenarios-resources/base/session-id/autojoin/foonet.lispdata new file mode 100644 index 0000000000..1162cc3f24 --- /dev/null +++ b/test/lisp/erc/erc-scenarios-resources/base/session-id/autojoin/foonet.lispdata @@ -0,0 +1,39 @@ +;; -*- mode: lisp-data; -*- +((pass 1 "PASS :foonet:changeme")) +((nick 1 "NICK tester")) + +((user 1 "USER user 0 * :tester") + (0 ":irc.foonet.org 001 tester :Welcome to the foonet IRC Network tester") + (0 ":irc.foonet.org 002 tester :Your host is irc.foonet.org, running version oragono-2.6.0-7481bf0385b95b16") + (0 ":irc.foonet.org 003 tester :This server was created Mon, 10 May 2021 00:58:22 UTC") + (0 ":irc.foonet.org 004 tester irc.foonet.org oragono-2.6.0-7481bf0385b95b16 BERTZios CEIMRUabefhiklmnoqstuv Iabefhkloqv") + (0 ":irc.foonet.org 005 tester AWAYLEN=390 BOT=B CASEMAPPING=ascii CHANLIMIT=#:100 CHANMODES=Ibe,k,fl,CEMRUimnstu CHANNELLEN=64 CHANTYPES=# ELIST=U EXCEPTS EXTBAN=,m FORWARD=f INVEX KICKLEN=390 :are supported by this server") + (0 ":irc.foonet.org 005 tester MAXLIST=beI:60 MAXTARGETS=4 MODES MONITOR=100 NETWORK=foonet NICKLEN=32 PREFIX=(qaohv)~&@%+ STATUSMSG=~&@%+ TARGMAX=NAMES:1,LIST:1,KICK:1,WHOIS:1,USERHOST:10,PRIVMSG:4,TAGMSG:4,NOTICE:4,MONITOR:100 TOPICLEN=390 UTF8MAPPING=rfc8265 UTF8ONLY WHOX :are supported by this server") + (0 ":irc.foonet.org 005 tester draft/CHATHISTORY=100 :are supported by this server") + (0 ":irc.foonet.org 251 tester :There are 0 users and 3 invisible on 1 server(s)") + (0 ":irc.foonet.org 252 tester 0 :IRC Operators online") + (0 ":irc.foonet.org 254 tester 1 :channels formed") + (0 ":irc.foonet.org 255 tester :I have 3 clients and 0 servers") + (0 ":irc.foonet.org 265 tester 3 3 :Current local users 3, max 3") + (0 ":irc.foonet.org 266 tester 3 3 :Current global users 3, max 3") + (0 ":irc.foonet.org 422 tester :MOTD File is missing")) + +((mode-user 1.2 "MODE tester +i")) +;; No mode answer ^ + +((join 1 "JOIN #chan") + (0 ":tester!~u@q6ddatxcq6txy.irc JOIN #chan") + (0 ":irc.foonet.org 353 tester = #chan :@alice bob tester") + (0 ":irc.foonet.org 366 tester #chan :End of NAMES list") + (0.1 ":bob!~u@q6ddatxcq6txy.irc PRIVMSG #chan :tester, welcome!") + (0 ":alice!~u@q6ddatxcq6txy.irc PRIVMSG #chan :tester, welcome!")) + +((mode 1 "MODE #chan") + (0 ":irc.foonet.org 324 tester #chan +nt") + (0 ":irc.foonet.org 329 tester #chan 1620608304") + (0.1 ":bob!~u@q6ddatxcq6txy.irc PRIVMSG #chan :alice: Pray you, sir, deliver me this paper.") + (0.1 ":alice!~u@q6ddatxcq6txy.irc PRIVMSG #chan :bob: Wake when some vile thing is near.")) + +((quit 1 "QUIT :\2ERC\2")) + +((drop 0 DROP)) diff --git a/test/lisp/erc/erc-scenarios.el b/test/lisp/erc/erc-scenarios.el index 0e2928b9a1..1d2f988338 100644 --- a/test/lisp/erc/erc-scenarios.el +++ b/test/lisp/erc/erc-scenarios.el @@ -278,6 +278,176 @@ erc-scenarios-base-association-same-network--new-buffer (funcall expect 5 "welcome again") (erc-cmd-QUIT ""))))) +;; XXX this is okay, but we also need to check that target buffers are +;; already associated with a new process *before* a JOIN is sent by a +;; server's playback burst. This doesn't do that. + +(defun erc-scenarios-common--base-session-id-autojoin (foo-reconnector + foo-id bar-id) + "Ensure channels rejoined by erc-join.el DTRT. +Originally from scenario clash-of-chans/autojoin as described in +Bug#48598: 28.0.50; buffer-naming collisions involving bouncers in ERC." + (erc-scenarios-common-with-cleanup + ((chan-buf-foo (format "#chan@%s" (or foo-id "foonet"))) + (chan-buf-bar (format "#chan@%s" (or bar-id "barnet"))) + (erc-scenarios-common-dialog "base/session-id/autojoin") + (erc-d-t-cleanup-sleep-secs 1) + (erc-server-flood-penalty 0.5) + (dumb-server (erc-d-run "localhost" t 'foonet 'barnet 'foonet-again)) + (port (process-contact dumb-server :service)) + (dumb-server-buffer (get-buffer "*erc-d-server*")) + (expect (erc-d-t-make-expecter)) + erc-server-buffer-foo erc-server-process-foo + erc-server-buffer-bar erc-server-process-bar) + + (should (memq 'autojoin erc-modules)) + + (ert-info ("Connect to foonet") + (with-current-buffer + (setq erc-server-buffer-foo (erc :server "127.0.0.1" + :port port + :nick "tester" + :password "foonet:changeme" + :full-name "tester" + :id foo-id)) + (setq erc-server-process-foo erc-server-process) + (erc-scenarios-common-assert-initial-buf-name foo-id port) + (erc-d-t-wait-for 1 "Network set to foonet" (eq (erc-network) 'foonet)) + (funcall expect 5 "foonet"))) + + (ert-info ("Join #chan, find sentinel, quit") + (with-current-buffer erc-server-buffer-foo (erc-cmd-JOIN "#chan")) + (erc-d-t-wait-for 5 "Buffer #chan created" (get-buffer "#chan")) + (with-current-buffer "#chan" + (funcall expect 5 "vile thing") + (erc-cmd-QUIT ""))) + + (erc-d-t-wait-for 2 "Foonet connection deceased" + (not (erc-server-process-alive erc-server-buffer-foo))) + + (should (equal erc-autojoin-channels-alist + (if foo-id '((oofnet "#chan")) '((foonet "#chan"))))) + + (ert-info ("Connect to barnet") + (with-current-buffer + (setq erc-server-buffer-bar (erc :server "127.0.0.1" + :port port + :nick "tester" + :password "barnet:changeme" + :full-name "tester" + :id bar-id)) + (setq erc-server-process-bar erc-server-process) + (erc-d-t-wait-for 5 "Network set to barnet" (eq erc-network 'barnet)) + (should (string= (buffer-name) (if bar-id "rabnet" "barnet"))))) + + (ert-info ("Server buffers are unique, no stray IP-based names") + (should-not (eq erc-server-buffer-foo erc-server-buffer-bar)) + (should-not (erc-scenarios-common-buflist "127.0.0.1"))) + + (ert-info ("Only one #chan buffer exists") + (should (equal (list (get-buffer "#chan")) + (erc-scenarios-common-buflist "#chan")))) + + (ert-info ("#chan is not auto-joined") + (with-current-buffer "#chan" + (erc-d-t-search-for -0.1 "") + (should-not (process-live-p erc-server-process)) + (erc-d-t-wait-for -0.1 "server buffer remains foonet" + (not (eq erc-server-process erc-server-process-foo))))) + + (with-current-buffer erc-server-buffer-bar + (erc-cmd-JOIN "#chan") + (erc-d-t-wait-for 3 "#chan buffers renamed" (get-buffer chan-buf-foo)) + (erc-d-t-wait-for 3 "#chan buffers renamed" (get-buffer chan-buf-bar)) + (with-current-buffer chan-buf-bar + (erc-d-t-wait-for 3 "server-buffer is barnet" + (eq erc-server-process erc-server-process-bar)) + (funcall expect 5 "marry her instantly"))) + + (ert-info ("Reconnect to foonet") + (with-current-buffer (setq erc-server-buffer-foo + (funcall foo-reconnector)) + (should (member (if foo-id '(oofnet "#chan") '(foonet "#chan")) + erc-autojoin-channels-alist)) + (erc-d-t-wait-for 3 "process is alive" (erc-server-process-alive)) + (setq erc-server-process-foo erc-server-process) + (erc-d-t-wait-for 2 "Network set to foonet" (eq erc-network 'foonet)) + (should (string= (buffer-name) (if foo-id "oofnet" "foonet"))) + (funcall expect 5 "foonet"))) + + (ert-info ("#chan@foonet is clean, no cross-contamination") + (with-current-buffer chan-buf-foo + (erc-d-t-wait-for 3 "server buffer is foonet" + (eq erc-server-process erc-server-process-foo)) + (funcall expect 3 "") + (erc-d-t-search-for -0.1 "") + (while (accept-process-output erc-server-process-foo)) + (funcall expect 3 "not given me"))) + + (ert-info ("All #chan@barnet output received") + (with-current-buffer chan-buf-bar + (while (accept-process-output erc-server-process-bar)) + (funcall expect 3 "hath an uncle here"))))) + +(ert-deftest erc-scenarios-base-session-id-autojoin--cmd-reconnect () + (let ((connect (lambda () + (with-current-buffer "foonet" + (erc-cmd-RECONNECT) + (should (eq (current-buffer) + (process-buffer erc-server-process))) + (current-buffer))))) + (erc-scenarios-common--base-session-id-autojoin connect nil nil))) + +(ert-deftest erc-scenarios-base-session-id-autojoin--cmd-reconnect-id () + (let ((connect (lambda () + (with-current-buffer "oofnet" + (erc-cmd-RECONNECT) + (should (eq (current-buffer) + (process-buffer erc-server-process))) + (current-buffer))))) + (erc-scenarios-common--base-session-id-autojoin connect 'oofnet nil))) + +(ert-deftest erc-scenarios-base-session-id-autojoin--cmd-reconnect-ids () + (let ((connect (lambda () + (with-current-buffer "oofnet" + (erc-cmd-RECONNECT) + (should (eq (current-buffer) + (process-buffer erc-server-process))) + (current-buffer))))) + (erc-scenarios-common--base-session-id-autojoin connect 'oofnet 'rabnet))) + +(ert-deftest erc-scenarios-base-session-id-autojoin--new-invocation () + (let ((connect (lambda () + (erc :server "127.0.0.1" + :port (with-current-buffer "foonet" + (process-contact erc-server-process :service)) + :nick "tester" + :password "foonet:changeme" + :full-name "tester")))) + (erc-scenarios-common--base-session-id-autojoin connect nil nil))) + +(ert-deftest erc-scenarios-base-session-id-autojoin--new-invocation-id () + (let ((connect (lambda () + (erc :server "127.0.0.1" + :port (with-current-buffer "oofnet" + (process-contact erc-server-process :service)) + :nick "tester" + :password "foonet:changeme" + :full-name "tester" + :id 'oofnet)))) + (erc-scenarios-common--base-session-id-autojoin connect 'oofnet nil))) + +(ert-deftest erc-scenarios-base-session-id-autojoin--new-invocation-ids () + (let ((connect (lambda () + (erc :server "127.0.0.1" + :port (with-current-buffer "oofnet" + (process-contact erc-server-process :service)) + :nick "tester" + :password "foonet:changeme" + :full-name "tester" + :id 'oofnet)))) + (erc-scenarios-common--base-session-id-autojoin connect 'oofnet 'rabnet))) + ;; Playback for same channel on two networks routed correctly. ;; Originally from Bug#48598: 28.0.50; buffer-naming collisions ;; involving bouncers in ERC. -- 2.31.1