Fix for RPC bugs caused by uk spelling (#904)

* Replaced UK with US spelling

* -ised to -ized

* UK -> US spelling in chain rpc methods

* Tests for RPC chain methods on Alex
This commit is contained in:
Stefanie Doll
2019-05-14 21:27:16 +02:00
committed by Jaco Greeff
parent ce2bbadf82
commit db78aeb225
6 changed files with 29 additions and 12 deletions
+1 -1
View File
@@ -40,7 +40,7 @@ _Retrieval of chain data_
- **summary**: Get the block hash for a specific block
▸ **getFinalizedHead**(): `Hash`
- **summary**: Get hash of the last finalised block in the canon chain
- **summary**: Get hash of the last finalized block in the canon chain
▸ **getHeader**(hash?: `Hash`): `Header`
- **summary**: Retrieves the header for a specific block
@@ -10,13 +10,13 @@ import { BlockNumber, Header } from '@polkadot/types';
import { drr } from '../util/drr';
/**
* @description Get the latest finalised block number.
* @description Get the latest finalized block number.
* example
* <BR>
*
* ```javascript
* api.derive.chain.bestNumberFinalized((blockNumber) => {
* console.log(`the current finalised block is #${blockNumber}`);
* console.log(`the current finalized block is #${blockNumber}`);
* });
* ```
*/
@@ -12,13 +12,13 @@ import { bestNumber } from './bestNumber';
import { bestNumberFinalized } from './bestNumberFinalized';
/**
* @description Calculates the lag between finalised head and best head
* @description Calculates the lag between finalized head and best head
* @example
* <BR>
*
* ```javascript
* api.derive.chain.bestNumberLag((lag) => {
* console.log(`finalised is ${lag} blocks behind head`);
* console.log(`finalized is ${lag} blocks behind head`);
* });
* ```
*/
@@ -5,6 +5,8 @@
import Api from '../../src/promise';
import WsProvider from '../../../rpc-provider/src/ws';
import { Hash, Header } from '@polkadot/types';
describe.skip('alex queries', () => {
let api;
@@ -65,6 +67,20 @@ describe.skip('alex queries', () => {
// done();
});
});
it('Gets the hash of the last finalized header', async (done) => {
api.rpc.chain.getFinalizedHead((head) => {
expect(head instanceof Hash).toBe(true);
done();
});
});
it('Subscribes to the best finalized header on ALEX', async (done) => {
api.rpc.chain.subscribeFinalizedHeads((heads) => {
expect(heads instanceof Header).toBe(true);
done();
});
});
});
describe.skip('Local archive queries (for debug)', () => {
+3 -1
View File
@@ -36,7 +36,9 @@ interface WSProviderInterface extends ProviderInterface {
}
const ALIASSES: { [index: string]: string } = {
'chain_finalisedHead': 'chain_finalizedHead'
'chain_finalisedHead': 'chain_finalizedHead',
'chain_subscribeFinalisedHeads': 'chain_subscribeFinalizedHeads',
'chain_unsubscribeFinalisedHeads': 'chain_unsubscribeFinalizedHeads'
};
const l = logger('api-ws');
+5 -6
View File
@@ -34,7 +34,7 @@ const getBlockHash: RpcMethodOpt = {
};
const getFinalizedHead: RpcMethodOpt = {
description: 'Get hash of the last finalised block in the canon chain',
description: 'Get hash of the last finalized block in the canon chain',
params: [],
type: 'Hash'
};
@@ -63,9 +63,8 @@ const subscribeFinalizedHeads: RpcMethodOpt = {
params: [],
pubsub: [
'finalizedHead',
// TODO US spelling
'subscribeFinalisedHeads',
'unsubscribeFinalisedHeads'
'subscribeFinalizedHeads',
'unsubscribeFinalizedHeads'
],
type: 'Header'
};
@@ -95,11 +94,11 @@ export default {
getBlock: createMethod(section, 'getBlock', getBlock),
getBlockHash: createMethod(section, 'getBlockHash', getBlockHash),
// TODO US spelling
getFinalizedHead: createMethod(section, 'getFinalisedHead', getFinalizedHead),
getFinalizedHead: createMethod(section, 'getFinalizedHead', getFinalizedHead),
getHeader: createMethod(section, 'getHeader', getHeader),
getRuntimeVersion: createMethod(section, 'getRuntimeVersion', getRuntimeVersion),
// TODO US spelling
subscribeFinalizedHeads: createMethod(section, 'subscribeFinalisedHeads', subscribeFinalizedHeads),
subscribeFinalizedHeads: createMethod(section, 'subscribeFinalizedHeads', subscribeFinalizedHeads),
subscribeRuntimeVersion: createMethod(section, 'subscribeRuntimeVersion', subscribeRuntimeVersion),
subscribeNewHead: createMethod(section, 'subscribeNewHead', subscribeNewHead)
}