Elections derive (#1143)

* elections

* headers

* lint

* lint

* lint

* lint

* fixes

* lint

* voterSets
This commit is contained in:
kwingram25
2019-07-19 21:27:02 +02:00
committed by Jaco Greeff
parent cbd717ca65
commit ab74db5126
11 changed files with 252 additions and 29 deletions
@@ -9,7 +9,7 @@ import { RewardDestination } from '@polkadot/types';
import { SubmittableResult } from '@polkadot/api';
import { HeaderExtended } from '@polkadot/api-derive/type';
import { DerivedBalances, DerivedFees, DerivedSessionInfo, DerivedStaking } from '@polkadot/api-derive/types';
import { DerivedBalances, DerivedElectionsInfo, DerivedFees, DerivedSessionInfo, DerivedStaking } from '@polkadot/api-derive/types';
const ALICE_STASH = testingPairs().alice_stash.address;
const WS = 'ws://127.0.0.1:9944/';
@@ -57,6 +57,14 @@ describe.skip('derive e2e', (): void => {
});
});
it('retrieves elections info', (done): Promise<() => void> => {
return api.derive.elections.info((info: DerivedElectionsInfo): void => {
console.error('fees', JSON.stringify(info));
done();
});
});
it('retrieves the balances', (done): Promise<() => void> => {
return api.derive.balances.all('5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y', (balance: DerivedBalances): void => {
console.error(JSON.stringify(balance));
+19 -1
View File
@@ -6,7 +6,7 @@ import BN from 'bn.js';
import ApiRx from '@polkadot/api/rx/Api';
import { HeaderExtended } from '@polkadot/api-derive';
import { DerivedBalances, DerivedContractFees, DerivedFees, DerivedSessionInfo } from '@polkadot/api-derive/types';
import { DerivedBalances, DerivedContractFees, DerivedElectionsInfo, DerivedFees, DerivedSessionInfo } from '@polkadot/api-derive/types';
import { AccountId, AccountIndex, BlockNumber, Index } from '@polkadot/types';
import { WsProvider } from '@polkadot/rpc-provider';
@@ -225,6 +225,24 @@ describe.skip('Api-RX derive e2e', (): void => {
});
});
describe('derive.elections', (): void => {
describe('info', (): void => {
it('It returns an object with all relevant elections properties', async (done): Promise<void> => {
api.derive.elections.info().subscribe((info: DerivedElectionsInfo): void => {
expect(info).toEqual(expect.objectContaining({
members: expect.anything(),
candidates: expect.anything(),
candidateCount: expect.any(BN),
desiredSeats: expect.any(BN),
termDuration: expect.any(BN),
voteCount: expect.any(BN)
}));
done();
});
});
});
});
describe('derive.session', (): void => {
describe('sessionProgress', (): void => {
it('derive.session.sessionProgress', async (done): Promise<void> => {