WIP cli tests for rpc

This commit is contained in:
ansuz
2019-09-05 18:01:21 +02:00
parent 023c29795a
commit d81ff791ad
5 changed files with 85 additions and 48 deletions

View File

@@ -24,13 +24,15 @@ var createNetwork = Client.createNetwork = function (url, cb) {
var info = {};
Netflux.connect(url, function (url) {
// this websocket seems to never close properly if the error is
// ECONNREFUSED
info.websocket = new WebSocket(url)
.on('error', function (err) {
console.log(err);
CB(err);
})
.on('close', function (err) {
console.log("close");
console.log(err);
console.log("CLOSE_ERROR", err);
delete info.websocket;
});
return info.websocket;
}).then(function (network) {
@@ -77,7 +79,10 @@ Client.create = function (config, cb) {
if (config.network) { return; }
// connect to the network...
createNetwork('ws://localhost:3000/cryptpad_websocket', w(function (err, info) {
//console.log(_network);
if (err) {
w.abort();
return void CB(err);
}
config.network = info.network;
config.websocket = info.websocket;
}));