Additional mortal era tests (#2259)

* Additional moratl era tests

* birth !== current (output the same)
This commit is contained in:
Jaco Greeff
2020-05-11 08:53:05 +02:00
committed by GitHub
parent 6f6a32a7a2
commit d75d8bec0e
8 changed files with 401 additions and 292 deletions
+7
View File
@@ -4,4 +4,11 @@
import BN from 'bn.js';
export const FALLBACK_MAX_HASH_COUNT = 250;
// default here to 5 min eras, adjusted based on the actual blocktime
export const FALLBACK_PERIOD = new BN(6 * 1000);
export const MAX_FINALITY_LAG = new BN(5);
export const MORTAL_PERIOD = new BN(5 * 60 * 1000);
+2 -6
View File
@@ -5,23 +5,19 @@
import { Header, Index } from '@polkadot/types/interfaces';
import { AnyNumber, Codec, IExtrinsicEra } from '@polkadot/types/types';
import BN from 'bn.js';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { isNumber, isUndefined } from '@polkadot/util';
import { FALLBACK_PERIOD, MAX_FINALITY_LAG, MORTAL_PERIOD } from './constants';
interface Result {
header: Header | null;
mortalLength: number;
nonce: Index;
}
// default here to 5 min eras, adjusted based on the actual blocktime
const FALLBACK_PERIOD = new BN(6 * 1000);
const MAX_FINALITY_LAG = new BN(5);
const MORTAL_PERIOD = new BN(5 * 60 * 1000);
function latestNonce (api: ApiInterfaceRx, address: string): Observable<Index> {
return api.derive.balances.account(address).pipe(
map(({ accountNonce }): Index => accountNonce)