3.7.3 (w/ Polkadot 27 upgrade blocks) (#3139)

This commit is contained in:
Jaco Greeff
2021-02-02 17:29:43 +01:00
committed by GitHub
parent 0352a30b6b
commit 724574afe7
17 changed files with 257 additions and 241 deletions
+48 -34
View File
@@ -5,44 +5,58 @@ import { assert, u8aEq } from '@polkadot/util';
import all from '.';
interface TestDef {
genesisHash: string;
network: string;
versions: [number, [number, number]][];
}
const TESTS: TestDef[] = [
{
genesisHash: '0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe',
network: 'kusama',
versions: [
[0, [0, 1020]],
[17, [901442, 1045]]
]
},
{
genesisHash: '0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3',
network: 'polkadot',
versions: [
[0, [0, 0]],
[19, [2436698, 26]]
]
},
{
genesisHash: '0xe143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e',
network: 'westend',
versions: [
[0, [214356, 4]],
[23, [4207800, 48]]
]
}
];
describe('upgrades', (): void => {
it('is valid', (): void => {
expect(all).toBeDefined();
});
TESTS.forEach(({ genesisHash, network, versions }): void => {
describe(network, (): void => {
const chain = all.find((n) => n.network === network);
it('has a valid entries for Kusama', (): void => {
const kusama = all.find(({ network }) => network === 'kusama');
assert(chain, `Unable to find the entry for ${network}`);
assert(kusama, 'Unable to find the entry for Kusama');
it('has a valid genesisHash', (): void => {
expect(u8aEq(chain.genesisHash, genesisHash)).toBe(true);
});
const version = kusama.versions[17];
versions.forEach(([index, [blockNumber, specVersion]]): void => {
it(`has a valid entry at index ${index}`, (): void => {
const version = chain.versions[index];
expect(u8aEq(kusama.genesisHash, '0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe')).toBe(true);
expect(version.blockNumber.eqn(901442)).toBe(true);
expect(version.specVersion.eqn(1045)).toBe(true);
});
it('has a valid entries for Polkadot', (): void => {
const polkadot = all.find(({ network }) => network === 'polkadot');
assert(polkadot, 'Unable to find the entry for Polkadot');
const version = polkadot.versions[19];
expect(u8aEq(polkadot.genesisHash, '0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3')).toBe(true);
expect(version.blockNumber.eqn(2436698)).toBe(true);
expect(version.specVersion.eqn(26)).toBe(true);
});
it('has a valid entries for Westend', (): void => {
const westend = all.find(({ network }) => network === 'westend');
assert(westend, 'Unable to find the entry for Polkadot');
const version = westend.versions[23];
expect(u8aEq(westend.genesisHash, '0xe143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e')).toBe(true);
expect(version.blockNumber.eqn(4207800)).toBe(true);
expect(version.specVersion.eqn(48)).toBe(true);
expect(version.blockNumber.eqn(blockNumber)).toBe(true);
expect(version.specVersion.eqn(specVersion)).toBe(true);
});
});
});
});
});
+3 -7
View File
@@ -21,7 +21,7 @@ const NET_EXTRA: Record<string, { genesisHash: string[] }> = {
};
/** @internal */
function checkOrder (network: string, versions: [number, number][]): [number, number][] {
function checkOrder (network: string, versions: ChainUpgradesRaw): [number, number][] {
const ooo = versions.filter((curr, index): boolean => {
const prev = versions[index - 1];
@@ -36,7 +36,7 @@ function checkOrder (network: string, versions: [number, number][]): [number, nu
}
/** @internal */
function rawToFinal (network: string, versions: ChainUpgradesRaw): ChainUpgrades {
function mapRaw ([network, versions]: [string, ChainUpgradesRaw]): ChainUpgrades {
const chain = networks.find((n) => n.network === network) || NET_EXTRA[network];
assert(chain, `Unable to find info for chain ${network}`);
@@ -52,10 +52,6 @@ function rawToFinal (network: string, versions: ChainUpgradesRaw): ChainUpgrades
}
// Type overrides for specific spec types & versions as given in runtimeVersion
const upgrades: ChainUpgrades[] = [
rawToFinal('kusama', kusama),
rawToFinal('polkadot', polkadot),
rawToFinal('westend', westend)
];
const upgrades = Object.entries({ kusama, polkadot, westend }).map(mapRaw);
export default upgrades;
@@ -7,7 +7,8 @@ const upgrades: ChainUpgradesRaw = [
[0, 0], [29231, 1], [188836, 5], [199405, 6], [214264, 7],
[244358, 8], [303079, 9], [314201, 10], [342400, 11], [443963, 12],
[528470, 13], [687751, 14], [746085, 15], [787923, 16], [799302, 17],
[1205128, 18], [1603423, 23], [1733218, 24], [2005673, 25], [2436698, 26]
[1205128, 18], [1603423, 23], [1733218, 24], [2005673, 25], [2436698, 26],
[3613564, 27]
];
export default upgrades;