From 7cac50601fad9dda83f364c8840f421c39f45a81 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 15 Dec 2016 22:45:35 +0100 Subject: [PATCH] Add JS tests for parity_netPeers --- js/src/api/format/output.spec.js | 44 ++++++++++++++++++++++++++-- js/src/api/rpc/parity/parity.spec.js | 2 +- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/js/src/api/format/output.spec.js b/js/src/api/format/output.spec.js index b44047610..d791e340c 100644 --- a/js/src/api/format/output.spec.js +++ b/js/src/api/format/output.spec.js @@ -147,10 +147,50 @@ describe('api/format/output', () => { describe('outPeers', () => { it('converts all internal numbers to BigNumbers', () => { - expect(outPeers({ active: 789, connected: '456', max: 0x7b })).to.deep.equal({ + expect(outPeers({ + active: 789, + connected: '456', + max: 0x7b, + peers: [ + { + caps: ["par/1"], + id: "0x01", + name: "Parity", + network: { + localAddress: "10.0.0.1", + remoteAddress: "10.0.0.1" + }, + protocols: { + par: { + difficulty: "0x0f", + head: "0x02", + version: 63 + } + } + } + ] + })).to.deep.equal({ active: new BigNumber(789), connected: new BigNumber(456), - max: new BigNumber(123) + max: new BigNumber(123), + peers: [ + { + caps: ["par/1"], + id: "0x01", + name: "Parity", + network: { + localAddress: "10.0.0.1", + remoteAddress: "10.0.0.1" + }, + protocols: { + par: { + difficulty: new BigNumber(15), + head: "0x02", + version: 63 + } + } + } + ] }); }); }); diff --git a/js/src/api/rpc/parity/parity.spec.js b/js/src/api/rpc/parity/parity.spec.js index d0d97cd0b..b58c8f85c 100644 --- a/js/src/api/rpc/parity/parity.spec.js +++ b/js/src/api/rpc/parity/parity.spec.js @@ -80,7 +80,7 @@ describe('api/rpc/parity', () => { describe('newPeers', () => { it('returns the peer structure, formatted', () => { - mockHttp([{ method: 'parity_netPeers', reply: { result: { active: 123, connected: 456, max: 789 } } }]); + mockHttp([{ method: 'parity_netPeers', reply: { result: { active: 123, connected: 456, max: 789, peers: [] } } }]); return instance.netPeers().then((peers) => { expect(peers.active.eq(123)).to.be.true;