Expose WS subscribe/unsubscribe (#63)

* Expose WS subscribe

* Support unsubscribe

* Align unsubscribe with method

* Basic e2e sub test

* Cleanup parameter positions

* Small update

* Handle non-supplied in output formatter
This commit is contained in:
Jaco Greeff
2018-04-16 13:49:02 +02:00
committed by GitHub
parent 232cd11e9d
commit 462fa6e5c4
26 changed files with 427 additions and 83 deletions
+33
View File
@@ -0,0 +1,33 @@
// Copyright 2017-2018 Jaco Greeff
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
const createApi = require('../../api/src');
const createProvider = require('../src/ws');
describe.skip('e2e', () => {
let api;
beforeEach(() => {
jest.setTimeout(30000);
api = createApi(createProvider('ws://127.0.0.1:9944'));
});
it('subscribes to client_newHead', (done) => {
let count = 0;
api.chain
.newHead((error, data) => {
console.log('newHead: result =', [error, data]);
expect(data).toBeDefined();
if (++count === 3) {
done();
}
})
.then((subscriptionId) => {
console.log('newHead: subscriptionId =', subscriptionId);
});
});
});