1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
| | ;;; erc-scenarios-base-network-id-samenet.el --- netid-id samenet scenarios -*- lexical-binding: t -*-
;; Copyright (C) 2022 Free Software Foundation, Inc.
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Code:
(require 'ert-x)
(eval-and-compile
(let ((load-path (cons (ert-resource-directory) load-path)))
(require 'erc-scenarios-common)))
(eval-when-compile (require 'erc-join))
(cl-defun erc-scenarios-common--base-network-id-same-network
((&key nick id server chan
&aux (nick-a nick) (id-a id) (serv-buf-a server) (chan-buf-a chan))
(&key nick id server chan
&aux (nick-b nick) (id-b id) (serv-buf-b server) (chan-buf-b chan)))
(erc-scenarios-common-with-cleanup
((erc-scenarios-common-dialog "base/netid/samenet")
(dumb-server (erc-d-run "localhost" t 'tester 'chester))
(port (process-contact dumb-server :service))
(expect (erc-d-t-make-expecter))
(erc-server-flood-penalty 0.1)
(erc-server-flood-margin 30)
erc-serv-buf-a erc-serv-buf-b)
(when (and id-a (zerop (random 2))) (setq id-a (symbol-name id-a)))
(when (and id-b (zerop (random 2))) (setq id-b (symbol-name id-b)))
(ert-info ("Connect to foonet with nick tester")
(with-current-buffer
(setq erc-serv-buf-a (erc :server "127.0.0.1"
:port port
:nick nick-a
:password "changeme"
:full-name nick-a
:id id-a))
(erc-scenarios-common-assert-initial-buf-name id-a port)
(erc-d-t-wait-for 5 (eq erc-network 'foonet))))
(ert-info ("Connect to foonet with nick chester")
(with-current-buffer
(setq erc-serv-buf-b (erc :server "127.0.0.1"
:port port
:nick nick-b
:password "changeme"
:full-name nick-b
:id id-b))
(erc-scenarios-common-assert-initial-buf-name id-b port)))
(erc-d-t-wait-for 3 (not (erc-scenarios-common-buflist "127.0.0.1")))
(with-current-buffer erc-serv-buf-a
(should (string= (buffer-name) serv-buf-a))
(funcall expect 8 "debug mode")
(erc-cmd-JOIN "#chan"))
(with-current-buffer erc-serv-buf-b
(should (string= (buffer-name) serv-buf-b))
(funcall expect 8 "debug mode")
(erc-cmd-JOIN "#chan"))
(erc-d-t-wait-for 10 (get-buffer chan-buf-a))
(erc-d-t-wait-for 10 (get-buffer chan-buf-b))
(ert-info ("Greets other nick in same channel")
(with-current-buffer chan-buf-a
(funcall expect 5 "chester")
(funcall expect 5 "find the forester")
(erc-cmd-MSG "#chan chester: hi")))
(ert-info ("Sees other nick in same channel")
(with-current-buffer chan-buf-b
(funcall expect 5 "tester")
(funcall expect 10 "<tester> chester: hi")
(funcall expect 5 "This was lofty")
(erc-cmd-MSG "#chan hi tester")))
(with-current-buffer chan-buf-a
(funcall expect 5 "To employ you towards")
(erc-cmd-QUIT ""))
(with-current-buffer chan-buf-b
(funcall expect 5 "To employ you towards")
(erc-cmd-QUIT ""))))
(ert-deftest erc-scenarios-base-network-id-same-network--two-ids ()
:tags '(:expensive-test)
(erc-scenarios-common--base-network-id-same-network
(list :nick "tester"
:id 'tester/foonet
:server "tester/foonet"
:chan "#chan@tester/foonet")
(list :nick "chester"
:id 'chester/foonet
:server "chester/foonet"
:chan "#chan@chester/foonet")))
(ert-deftest erc-scenarios-base-network-id-same-network--one-id-tester ()
:tags '(:expensive-test)
(erc-scenarios-common--base-network-id-same-network
(list :nick "tester"
:id 'tester/foonet
:server "tester/foonet"
:chan "#chan@tester/foonet")
(list :nick "chester"
:id nil
:server "foonet"
:chan "#chan@foonet")))
(ert-deftest erc-scenarios-base-network-id-same-network--one-id-chester ()
:tags '(:expensive-test)
(erc-scenarios-common--base-network-id-same-network
(list :nick "tester"
:id nil
:server "foonet"
:chan "#chan@foonet")
(list :nick "chester"
:id 'chester/foonet
:server "chester/foonet"
:chan "#chan@chester/foonet")))
(ert-deftest erc-scenarios-base-network-id-same-network--no-ids ()
:tags '(:expensive-test)
(erc-scenarios-common--base-network-id-same-network
(list :nick "tester"
:id nil
:server "foonet/tester"
:chan "#chan@foonet/tester") ; <- note net before nick
(list :nick "chester"
:id nil
:server "foonet/chester"
:chan "#chan@foonet/chester")))
;;; erc-scenarios-base-network-id-samenet.el ends here
|