Add JS tests for parity_netPeers

This commit is contained in:
Gav Wood 2016-12-15 22:45:35 +01:00
parent 869fbf5108
commit 7cac50601f
No known key found for this signature in database
GPG Key ID: C49C1ACA1CC9B252
2 changed files with 43 additions and 3 deletions

View File

@ -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
}
}
}
]
});
});
});

View File

@ -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;