parity.js api.parity.chainStatus should handle { blockGap: null } (#4327)

* Add tests for null blockGap values

* Handle null blockGap values
This commit is contained in:
Jaco Greeff 2017-01-27 14:42:22 +01:00 committed by GitHub
parent 1940809dd4
commit 076c8b9de7
3 changed files with 19 additions and 1 deletions

View File

@ -79,7 +79,9 @@ export function outChainStatus (status) {
Object.keys(status).forEach((key) => { Object.keys(status).forEach((key) => {
switch (key) { switch (key) {
case 'blockGap': case 'blockGap':
status[key] = status[key].map(outNumber); status[key] = status[key]
? status[key].map(outNumber)
: status[key];
break; break;
} }
}); });

View File

@ -135,6 +135,14 @@ describe('api/format/output', () => {
blockGap: [new BigNumber(0x1234), new BigNumber(0x5678)] blockGap: [new BigNumber(0x1234), new BigNumber(0x5678)]
}); });
}); });
it('handles null blockGap values', () => {
const status = {
blockGap: null
};
expect(outChainStatus(status)).to.deep.equal(status);
});
}); });
describe('outDate', () => { describe('outDate', () => {

View File

@ -19,6 +19,14 @@ import { createHttpApi } from '../../../../test/e2e/ethapi';
describe('ethapi.parity', () => { describe('ethapi.parity', () => {
const ethapi = createHttpApi(); const ethapi = createHttpApi();
describe('chainStatus', () => {
it('returns and translates the status', () => {
return ethapi.parity.chainStatus().then((value) => {
expect(value).to.be.ok;
});
});
});
describe('gasFloorTarget', () => { describe('gasFloorTarget', () => {
it('returns and translates the target', () => { it('returns and translates the target', () => {
return ethapi.parity.gasFloorTarget().then((value) => { return ethapi.parity.gasFloorTarget().then((value) => {