forked from XRPLF/rippled
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebsocket-test.js
59 lines (49 loc) · 1.43 KB
/
websocket-test.js
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
var assert = require('assert');
var extend = require("extend");
var Server = require("./server").Server;
var Remote = require("ripple-lib").Remote;
var testutils = require('./testutils');
var config = testutils.init_config();
suite('WebSocket connection', function() {
var server;
setup(function(done) {
this.timeout(2000);
var host = config.server_default;
var cfg = testutils.get_server_config(config, host);
if (cfg.no_server) {
done();
} else {
server = Server.from_config(host, cfg);
server.once('started', done)
server.start();
}
});
teardown(function(done) {
this.timeout(2000);
var cfg = testutils.get_server_config(config);
if (cfg.no_server) {
done();
} else {
server.on('stopped', done);
server.stop();
}
});
test('WebSocket connect and disconnect', function(done) {
// This timeout probably doesn't need to be this long, because
// the test itself completes in less than half a second.
// However, some of the overhead, especially on Windows can
// push the measured time out this far.
this.timeout(3000);
var host = config.server_default;
var alpha = Remote.from_config(host);
alpha.on('connected', function () {
alpha.on('disconnected', function () {
// CLOSED
done();
});
alpha.disconnect();
})
alpha.connect();
});
});
// vim:sw=2:sts=2:ts=8:et