scansion/objects/client.lua

Thu, 23 Mar 2023 15:15:01 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Thu, 23 Mar 2023 15:15:01 +0000
changeset 176
7674fb1dcc41
parent 175
e48074386468
permissions
-rw-r--r--

client: Fix harmless error logged when calling 'done' too many times

8
42b4e73c0d30 client: Wait for login to complete before continuing past the 'connects' action
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
1 local async = require "scansion.async";
66
909c00296c2a client: Make use of new scansion.error library, log the received stanza when different to expected one
Matthew Wild <mwild1@gmail.com>
parents: 60
diff changeset
2 local new_error = require "scansion.error".new_error;
4
c54194d8cc30 client: verse improvements
Matthew Wild <mwild1@gmail.com>
parents: 1
diff changeset
3 local verse = require "verse".init("client");
1
017c5809d537 client: Enable verse log output
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
4
0
2e31b584f8d9 It is better to write and run incomplete tests than not to run complete tests. -- Martin Fowler
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5 local parse_xml = require "scansion.xml".parse;
6
0c94ea0cabec client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents: 4
diff changeset
6
82
f90056b8e278 main.lua, client: Make timeouts more coherent (stanza timeout was greater than action timeout), add command-line options to change them
Matthew Wild <mwild1@gmail.com>
parents: 73
diff changeset
7 local default_stanza_timeout = 3;
6
0c94ea0cabec client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents: 4
diff changeset
8
0c94ea0cabec client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents: 4
diff changeset
9 local stanzacmp = require "scansion.stanzacmp";
0c94ea0cabec client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents: 4
diff changeset
10
171
433a1f36d0d3 client: Move some generic utility functions to a helpers module
Matthew Wild <mwild1@gmail.com>
parents: 164
diff changeset
11 local helpers = require "scansion.helpers";
16
59f176aa3465 client: Allow simple variable substitution in XML in scripts
Matthew Wild <mwild1@gmail.com>
parents: 15
diff changeset
12
0
2e31b584f8d9 It is better to write and run incomplete tests than not to run complete tests. -- Martin Fowler
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 return {
2e31b584f8d9 It is better to write and run incomplete tests than not to run complete tests. -- Martin Fowler
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 _validate = function (client)
2e31b584f8d9 It is better to write and run incomplete tests than not to run complete tests. -- Martin Fowler
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 assert(client.jid, "No JID specified");
23
af7a51d78b7b client: Improve stream logging, now prefixed by client name (taken from script)
Matthew Wild <mwild1@gmail.com>
parents: 22
diff changeset
16 client.stream = verse.new(verse.new_logger(client.name));
48
6450aea6c564 scansion.objects.client: Pass on 'connect_host' to the stream
Kim Alvefur <zash@zash.se>
parents: 46
diff changeset
17 client.stream.connect_host = client.connect_host
49
69c329681c3b scansion.objects.client: And the port too
Kim Alvefur <zash@zash.se>
parents: 48
diff changeset
18 client.stream.connect_port = client.connect_port
23
af7a51d78b7b client: Improve stream logging, now prefixed by client name (taken from script)
Matthew Wild <mwild1@gmail.com>
parents: 22
diff changeset
19
af7a51d78b7b client: Improve stream logging, now prefixed by client name (taken from script)
Matthew Wild <mwild1@gmail.com>
parents: 22
diff changeset
20 function client.log(fmt, ...)
af7a51d78b7b client: Improve stream logging, now prefixed by client name (taken from script)
Matthew Wild <mwild1@gmail.com>
parents: 22
diff changeset
21 return client.stream:info(fmt, ...);
af7a51d78b7b client: Improve stream logging, now prefixed by client name (taken from script)
Matthew Wild <mwild1@gmail.com>
parents: 22
diff changeset
22 end
10
75bf4c021461 client: ALL the debugging on
Matthew Wild <mwild1@gmail.com>
parents: 8
diff changeset
23
75bf4c021461 client: ALL the debugging on
Matthew Wild <mwild1@gmail.com>
parents: 8
diff changeset
24 -- This one prints all received data
23
af7a51d78b7b client: Improve stream logging, now prefixed by client name (taken from script)
Matthew Wild <mwild1@gmail.com>
parents: 22
diff changeset
25 client.stream:hook("incoming-raw", function (s) client.log("Data in: %s", s); end, 1000);
af7a51d78b7b client: Improve stream logging, now prefixed by client name (taken from script)
Matthew Wild <mwild1@gmail.com>
parents: 22
diff changeset
26 client.stream:hook("outgoing-raw", function (s) client.log("Data out: %s", s); end, 1000);
af7a51d78b7b client: Improve stream logging, now prefixed by client name (taken from script)
Matthew Wild <mwild1@gmail.com>
parents: 22
diff changeset
27 -- And incoming, parsed, stanzas
af7a51d78b7b client: Improve stream logging, now prefixed by client name (taken from script)
Matthew Wild <mwild1@gmail.com>
parents: 22
diff changeset
28 client.stream:hook("stanza", function (s) client.log("Stanza: %s", s) end);
60
e032cdb517ab client.lua: Handle unexpected disconnects in the middle of a test
Matthew Wild <mwild1@gmail.com>
parents: 53
diff changeset
29 -- Handle unexpected disconnects
e032cdb517ab client.lua: Handle unexpected disconnects in the middle of a test
Matthew Wild <mwild1@gmail.com>
parents: 53
diff changeset
30 client.stream:hook("disconnected", function (s)
118
073136acfeab client: Add _finish handler to disconnect from server if still connected
Matthew Wild <mwild1@gmail.com>
parents: 111
diff changeset
31 if not (client.disconnect_expected or client.script.finished) or (s.reason and s.reason ~= "stream closed" and s.reason ~= "closed") then
90
8458f8bdb3b0 client: Detect unexpected disconnects more reliably
Matthew Wild <mwild1@gmail.com>
parents: 84
diff changeset
32 client.log("Unexpected disconnect!");
8458f8bdb3b0 client: Detect unexpected disconnects more reliably
Matthew Wild <mwild1@gmail.com>
parents: 84
diff changeset
33 error("Unexpected disconnect"..(s.reason and " ("..tostring(s.reason)..")" or ""));
8458f8bdb3b0 client: Detect unexpected disconnects more reliably
Matthew Wild <mwild1@gmail.com>
parents: 84
diff changeset
34 end
60
e032cdb517ab client.lua: Handle unexpected disconnects in the middle of a test
Matthew Wild <mwild1@gmail.com>
parents: 53
diff changeset
35 end);
0
2e31b584f8d9 It is better to write and run incomplete tests than not to run complete tests. -- Martin Fowler
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
36 end;
2e31b584f8d9 It is better to write and run incomplete tests than not to run complete tests. -- Martin Fowler
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
37
118
073136acfeab client: Add _finish handler to disconnect from server if still connected
Matthew Wild <mwild1@gmail.com>
parents: 111
diff changeset
38 _finish = function (client)
073136acfeab client: Add _finish handler to disconnect from server if still connected
Matthew Wild <mwild1@gmail.com>
parents: 111
diff changeset
39 if client.stream.connected then
073136acfeab client: Add _finish handler to disconnect from server if still connected
Matthew Wild <mwild1@gmail.com>
parents: 111
diff changeset
40 client.disconnect_expected = true;
073136acfeab client: Add _finish handler to disconnect from server if still connected
Matthew Wild <mwild1@gmail.com>
parents: 111
diff changeset
41 client.stream:close();
073136acfeab client: Add _finish handler to disconnect from server if still connected
Matthew Wild <mwild1@gmail.com>
parents: 111
diff changeset
42 end
073136acfeab client: Add _finish handler to disconnect from server if still connected
Matthew Wild <mwild1@gmail.com>
parents: 111
diff changeset
43 end;
073136acfeab client: Add _finish handler to disconnect from server if still connected
Matthew Wild <mwild1@gmail.com>
parents: 111
diff changeset
44
0
2e31b584f8d9 It is better to write and run incomplete tests than not to run complete tests. -- Martin Fowler
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
45 connects = function (client)
8
42b4e73c0d30 client: Wait for login to complete before continuing past the 'connects' action
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
46 local wait, done = async.waiter();
52
3eedbb76e3f2 scansion.objects.client: Split long line into one statement per line
Kim Alvefur <zash@zash.se>
parents: 51
diff changeset
47 client.stream:hook("ready", function ()
53
3208dff3fb31 scansion.objects.client: Pause connection before resuming async processing
Kim Alvefur <zash@zash.se>
parents: 52
diff changeset
48 client.stream.conn:pause()
52
3eedbb76e3f2 scansion.objects.client: Split long line into one statement per line
Kim Alvefur <zash@zash.se>
parents: 51
diff changeset
49 client.log"ready"
3eedbb76e3f2 scansion.objects.client: Split long line into one statement per line
Kim Alvefur <zash@zash.se>
parents: 51
diff changeset
50 done()
3eedbb76e3f2 scansion.objects.client: Split long line into one statement per line
Kim Alvefur <zash@zash.se>
parents: 51
diff changeset
51 client.log("ready done")
3eedbb76e3f2 scansion.objects.client: Split long line into one statement per line
Kim Alvefur <zash@zash.se>
parents: 51
diff changeset
52 end);
4
c54194d8cc30 client: verse improvements
Matthew Wild <mwild1@gmail.com>
parents: 1
diff changeset
53 client.stream:connect_client(client.jid, client.password);
8
42b4e73c0d30 client: Wait for login to complete before continuing past the 'connects' action
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
54 wait();
15
0441673df075 client: Add full JID as property of clients
Matthew Wild <mwild1@gmail.com>
parents: 10
diff changeset
55 client.full_jid = client.stream.jid;
50
0ce9c9a0c2a0 scansion.objects.client: Expose a 'host' property with the bare hostname
Kim Alvefur <zash@zash.se>
parents: 49
diff changeset
56 client.host = client.stream.host;
0
2e31b584f8d9 It is better to write and run incomplete tests than not to run complete tests. -- Martin Fowler
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
57 end;
2e31b584f8d9 It is better to write and run incomplete tests than not to run complete tests. -- Martin Fowler
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
58
2e31b584f8d9 It is better to write and run incomplete tests than not to run complete tests. -- Martin Fowler
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
59 sends = function (client, data)
171
433a1f36d0d3 client: Move some generic utility functions to a helpers module
Matthew Wild <mwild1@gmail.com>
parents: 164
diff changeset
60 local stanza = helpers.fill_vars(client.script, assert(parse_xml((table.concat(data):gsub("\t", " ")))));
73
1c07ef6c6502 client: Wait for 'drained' event when sending stanzas (experimental, may help with syncing to server's logs)
Matthew Wild <mwild1@gmail.com>
parents: 66
diff changeset
61 local wait, done = async.waiter();
1c07ef6c6502 client: Wait for 'drained' event when sending stanzas (experimental, may help with syncing to server's logs)
Matthew Wild <mwild1@gmail.com>
parents: 66
diff changeset
62 local function handle_drained()
1c07ef6c6502 client: Wait for 'drained' event when sending stanzas (experimental, may help with syncing to server's logs)
Matthew Wild <mwild1@gmail.com>
parents: 66
diff changeset
63 client.stream:unhook("drained", handle_drained);
1c07ef6c6502 client: Wait for 'drained' event when sending stanzas (experimental, may help with syncing to server's logs)
Matthew Wild <mwild1@gmail.com>
parents: 66
diff changeset
64 done();
1c07ef6c6502 client: Wait for 'drained' event when sending stanzas (experimental, may help with syncing to server's logs)
Matthew Wild <mwild1@gmail.com>
parents: 66
diff changeset
65 end
1c07ef6c6502 client: Wait for 'drained' event when sending stanzas (experimental, may help with syncing to server's logs)
Matthew Wild <mwild1@gmail.com>
parents: 66
diff changeset
66 client.stream:hook("drained", handle_drained);
6
0c94ea0cabec client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents: 4
diff changeset
67 client.stream:send(stanza);
73
1c07ef6c6502 client: Wait for 'drained' event when sending stanzas (experimental, may help with syncing to server's logs)
Matthew Wild <mwild1@gmail.com>
parents: 66
diff changeset
68 wait();
0
2e31b584f8d9 It is better to write and run incomplete tests than not to run complete tests. -- Martin Fowler
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
69 end;
2e31b584f8d9 It is better to write and run incomplete tests than not to run complete tests. -- Martin Fowler
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
70
2e31b584f8d9 It is better to write and run incomplete tests than not to run complete tests. -- Martin Fowler
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
71 receives = function (client, data)
26
c32334d33438 client: Wait for received stanzas using async waiter
Matthew Wild <mwild1@gmail.com>
parents: 25
diff changeset
72 local wait, done = async.waiter();
84
c9061cd9951b client: Support for "receives: nothing", to verify that the server does not respond to a given stanza, for example
Matthew Wild <mwild1@gmail.com>
parents: 83
diff changeset
73 local expected_stanza = false;
164
14500a149b31 client: Ignore timeout timer if we received a stanza
Matthew Wild <mwild1@gmail.com>
parents: 130
diff changeset
74 local have_received_stanza = false;
84
c9061cd9951b client: Support for "receives: nothing", to verify that the server does not respond to a given stanza, for example
Matthew Wild <mwild1@gmail.com>
parents: 83
diff changeset
75 data = table.concat(data):gsub("\t", " "):gsub("^%s+", ""):gsub("%s+$", "");
c9061cd9951b client: Support for "receives: nothing", to verify that the server does not respond to a given stanza, for example
Matthew Wild <mwild1@gmail.com>
parents: 83
diff changeset
76 if data ~= "nothing" then
171
433a1f36d0d3 client: Move some generic utility functions to a helpers module
Matthew Wild <mwild1@gmail.com>
parents: 164
diff changeset
77 expected_stanza = helpers.fill_vars(client.script, assert(parse_xml(data)));
84
c9061cd9951b client: Support for "receives: nothing", to verify that the server does not respond to a given stanza, for example
Matthew Wild <mwild1@gmail.com>
parents: 83
diff changeset
78 end
6
0c94ea0cabec client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents: 4
diff changeset
79 local function stanza_handler(received_stanza)
164
14500a149b31 client: Ignore timeout timer if we received a stanza
Matthew Wild <mwild1@gmail.com>
parents: 130
diff changeset
80 have_received_stanza = true;
84
c9061cd9951b client: Support for "receives: nothing", to verify that the server does not respond to a given stanza, for example
Matthew Wild <mwild1@gmail.com>
parents: 83
diff changeset
81 if not expected_stanza then
111
25530dccf696 scansion.error, client: Change error syntax slightly, so first param is identifier string
Matthew Wild <mwild1@gmail.com>
parents: 105
diff changeset
82 error(new_error("unexpected-stanza", {
25530dccf696 scansion.error, client: Change error syntax slightly, so first param is identifier string
Matthew Wild <mwild1@gmail.com>
parents: 105
diff changeset
83 text = "Received unexpected stanza";
25530dccf696 scansion.error, client: Change error syntax slightly, so first param is identifier string
Matthew Wild <mwild1@gmail.com>
parents: 105
diff changeset
84 stanza = tostring(received_stanza);
25530dccf696 scansion.error, client: Change error syntax slightly, so first param is identifier string
Matthew Wild <mwild1@gmail.com>
parents: 105
diff changeset
85 }));
173
14ed4cb241f4 scansion: Support for per-script captures
Matthew Wild <mwild1@gmail.com>
parents: 172
diff changeset
86 elseif not expected_stanza or not stanzacmp.stanzas_match(expected_stanza, received_stanza, client.script.captures) then
84
c9061cd9951b client: Support for "receives: nothing", to verify that the server does not respond to a given stanza, for example
Matthew Wild <mwild1@gmail.com>
parents: 83
diff changeset
87 if not expected_stanza then
c9061cd9951b client: Support for "receives: nothing", to verify that the server does not respond to a given stanza, for example
Matthew Wild <mwild1@gmail.com>
parents: 83
diff changeset
88 client.log("Received a stanza when none were expected: %s", received_stanza);
c9061cd9951b client: Support for "receives: nothing", to verify that the server does not respond to a given stanza, for example
Matthew Wild <mwild1@gmail.com>
parents: 83
diff changeset
89 else
c9061cd9951b client: Support for "receives: nothing", to verify that the server does not respond to a given stanza, for example
Matthew Wild <mwild1@gmail.com>
parents: 83
diff changeset
90 client.log("Expected: %s", expected_stanza);
c9061cd9951b client: Support for "receives: nothing", to verify that the server does not respond to a given stanza, for example
Matthew Wild <mwild1@gmail.com>
parents: 83
diff changeset
91 client.log("Received: %s", received_stanza);
c9061cd9951b client: Support for "receives: nothing", to verify that the server does not respond to a given stanza, for example
Matthew Wild <mwild1@gmail.com>
parents: 83
diff changeset
92 end
111
25530dccf696 scansion.error, client: Change error syntax slightly, so first param is identifier string
Matthew Wild <mwild1@gmail.com>
parents: 105
diff changeset
93 error(new_error("unexpected-stanza", {
25530dccf696 scansion.error, client: Change error syntax slightly, so first param is identifier string
Matthew Wild <mwild1@gmail.com>
parents: 105
diff changeset
94 text = "Received unexpected stanza";
105
da98bb33cee6 scansion.objects.client: Include expected stanza in error, if any
Matthew Wild <mwild1@gmail.com>
parents: 90
diff changeset
95 stanza = tostring(received_stanza);
da98bb33cee6 scansion.objects.client: Include expected stanza in error, if any
Matthew Wild <mwild1@gmail.com>
parents: 90
diff changeset
96 expected = expected_stanza and tostring(expected_stanza) or nil;
da98bb33cee6 scansion.objects.client: Include expected stanza in error, if any
Matthew Wild <mwild1@gmail.com>
parents: 90
diff changeset
97 }));
6
0c94ea0cabec client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents: 4
diff changeset
98 else
83
52f8fa7f999e client: Store last received id so it can be used in scripts
Matthew Wild <mwild1@gmail.com>
parents: 82
diff changeset
99 client.last_received_id = received_stanza.attr.id;
23
af7a51d78b7b client: Improve stream logging, now prefixed by client name (taken from script)
Matthew Wild <mwild1@gmail.com>
parents: 22
diff changeset
100 client.log("YES! %s", expected_stanza)
6
0c94ea0cabec client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents: 4
diff changeset
101 end
0c94ea0cabec client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents: 4
diff changeset
102 expected_stanza = nil;
27
34d405303242 client: Remove stanza handler when stanza comes in
Matthew Wild <mwild1@gmail.com>
parents: 26
diff changeset
103 client.stream:unhook("stanza", stanza_handler);
51
afc7765827be scansion.objects.client: Hold of reading from clients when they are not expecting stanzas
Kim Alvefur <zash@zash.se>
parents: 50
diff changeset
104 client.stream.conn:pause();
90
8458f8bdb3b0 client: Detect unexpected disconnects more reliably
Matthew Wild <mwild1@gmail.com>
parents: 84
diff changeset
105 client.log("Calling done")
26
c32334d33438 client: Wait for received stanzas using async waiter
Matthew Wild <mwild1@gmail.com>
parents: 25
diff changeset
106 done();
175
e48074386468 client: Tell Verse that stanzas are "handled"
Matthew Wild <mwild1@gmail.com>
parents: 173
diff changeset
107 return true;
6
0c94ea0cabec client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents: 4
diff changeset
108 end
0c94ea0cabec client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents: 4
diff changeset
109 client.stream:hook("stanza", stanza_handler, 100);
176
7674fb1dcc41 client: Fix harmless error logged when calling 'done' too many times
Matthew Wild <mwild1@gmail.com>
parents: 175
diff changeset
110 local finished_waiting;
82
f90056b8e278 main.lua, client: Make timeouts more coherent (stanza timeout was greater than action timeout), add command-line options to change them
Matthew Wild <mwild1@gmail.com>
parents: 73
diff changeset
111 verse.add_task(client.stanza_timeout or default_stanza_timeout, function ()
176
7674fb1dcc41 client: Fix harmless error logged when calling 'done' too many times
Matthew Wild <mwild1@gmail.com>
parents: 175
diff changeset
112 if not finished_waiting then
7674fb1dcc41 client: Fix harmless error logged when calling 'done' too many times
Matthew Wild <mwild1@gmail.com>
parents: 175
diff changeset
113 done();
7674fb1dcc41 client: Fix harmless error logged when calling 'done' too many times
Matthew Wild <mwild1@gmail.com>
parents: 175
diff changeset
114 end
172
2c17151ed21b client: Fix timeout handling
Matthew Wild <mwild1@gmail.com>
parents: 171
diff changeset
115 end);
2c17151ed21b client: Fix timeout handling
Matthew Wild <mwild1@gmail.com>
parents: 171
diff changeset
116 client.stream.conn:resume();
2c17151ed21b client: Fix timeout handling
Matthew Wild <mwild1@gmail.com>
parents: 171
diff changeset
117 wait();
176
7674fb1dcc41 client: Fix harmless error logged when calling 'done' too many times
Matthew Wild <mwild1@gmail.com>
parents: 175
diff changeset
118 finished_waiting = true;
172
2c17151ed21b client: Fix timeout handling
Matthew Wild <mwild1@gmail.com>
parents: 171
diff changeset
119
2c17151ed21b client: Fix timeout handling
Matthew Wild <mwild1@gmail.com>
parents: 171
diff changeset
120 if not have_received_stanza then
82
f90056b8e278 main.lua, client: Make timeouts more coherent (stanza timeout was greater than action timeout), add command-line options to change them
Matthew Wild <mwild1@gmail.com>
parents: 73
diff changeset
121 if expected_stanza then
f90056b8e278 main.lua, client: Make timeouts more coherent (stanza timeout was greater than action timeout), add command-line options to change them
Matthew Wild <mwild1@gmail.com>
parents: 73
diff changeset
122 client.log("TIMEOUT waiting for %s", expected_stanza)
130
ce99abde467b client: Throw scansion error on stanza timeout, to avoid traceback
Matthew Wild <mwild1@gmail.com>
parents: 118
diff changeset
123 local e = new_error("stanza-timeout", { text = "Timed out waiting for stanza" });
ce99abde467b client: Throw scansion error on stanza timeout, to avoid traceback
Matthew Wild <mwild1@gmail.com>
parents: 118
diff changeset
124 error(e);
82
f90056b8e278 main.lua, client: Make timeouts more coherent (stanza timeout was greater than action timeout), add command-line options to change them
Matthew Wild <mwild1@gmail.com>
parents: 73
diff changeset
125 end
f90056b8e278 main.lua, client: Make timeouts more coherent (stanza timeout was greater than action timeout), add command-line options to change them
Matthew Wild <mwild1@gmail.com>
parents: 73
diff changeset
126 if expected_stanza == false then
f90056b8e278 main.lua, client: Make timeouts more coherent (stanza timeout was greater than action timeout), add command-line options to change them
Matthew Wild <mwild1@gmail.com>
parents: 73
diff changeset
127 client.log("Good - no stanzas were received (expected)");
f90056b8e278 main.lua, client: Make timeouts more coherent (stanza timeout was greater than action timeout), add command-line options to change them
Matthew Wild <mwild1@gmail.com>
parents: 73
diff changeset
128 done();
f90056b8e278 main.lua, client: Make timeouts more coherent (stanza timeout was greater than action timeout), add command-line options to change them
Matthew Wild <mwild1@gmail.com>
parents: 73
diff changeset
129 end
172
2c17151ed21b client: Fix timeout handling
Matthew Wild <mwild1@gmail.com>
parents: 171
diff changeset
130 end
0
2e31b584f8d9 It is better to write and run incomplete tests than not to run complete tests. -- Martin Fowler
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
131 end;
2e31b584f8d9 It is better to write and run incomplete tests than not to run complete tests. -- Martin Fowler
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
132
2e31b584f8d9 It is better to write and run incomplete tests than not to run complete tests. -- Martin Fowler
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
133 disconnects = function (client)
90
8458f8bdb3b0 client: Detect unexpected disconnects more reliably
Matthew Wild <mwild1@gmail.com>
parents: 84
diff changeset
134 client.disconnect_expected = true;
29
9dcdea04601c client: Implement 'disconnects' action
Matthew Wild <mwild1@gmail.com>
parents: 28
diff changeset
135 client.stream:close();
0
2e31b584f8d9 It is better to write and run incomplete tests than not to run complete tests. -- Martin Fowler
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
136 end;
2e31b584f8d9 It is better to write and run incomplete tests than not to run complete tests. -- Martin Fowler
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
137 }

mercurial