[FIX] handle websocket errors in browsers

emit not RippledNotInitializedError if server doesn't have any
completed ledgers on connect
This commit is contained in:
Ivan Tivonenko
2016-03-29 20:31:54 +03:00
parent 14bbe3e30b
commit 5da78ce583
10 changed files with 236 additions and 96 deletions

26
test/utils/net-utils.js Normal file
View File

@@ -0,0 +1,26 @@
'use strict'; // eslint-disable-line
const net = require('net');
// using a free port instead of a constant port enables parallelization
function getFreePort() {
return new Promise((resolve, reject) => {
const server = net.createServer();
let port;
server.on('listening', function() {
port = server.address().port;
server.close();
});
server.on('close', function() {
resolve(port);
});
server.on('error', function(error) {
reject(error);
});
server.listen(0);
});
}
module.exports = {
getFreePort
};