Skip to content

Commit

Permalink
fix: update polkadot-js deps, and adjust tests for getWeight (#890)
Browse files Browse the repository at this point in the history
* fix: update polkadot-js api, and apps-config

* fix(tests): remove createApiAugmentation for getWeights test
  • Loading branch information
TarikGul committed Apr 7, 2022
1 parent 54abf69 commit c348363
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 134 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
"test:test-release": "yarn start:test-release"
},
"dependencies": {
"@polkadot/api": "^7.14.3",
"@polkadot/apps-config": "^0.110.1",
"@polkadot/api": "^7.15.1",
"@polkadot/apps-config": "^0.111.1",
"@polkadot/util-crypto": "^8.7.1",
"@substrate/calc": "^0.2.8",
"argparse": "^2.0.1",
Expand All @@ -78,11 +78,11 @@
"tsc-watch": "^4.4.0"
},
"resolutions": {
"@polkadot/api": "7.14.3",
"@polkadot/api": "7.15.1",
"@polkadot/keyring": "8.7.1",
"@polkadot/networks": "8.7.1",
"@polkadot/types": "7.14.3",
"@polkadot/types-known": "7.14.3",
"@polkadot/types": "7.15.1",
"@polkadot/types-known": "7.15.1",
"@polkadot/util": "8.7.1",
"@polkadot/util-crypto": "8.7.1",
"@polkadot/wasm-crypto": "5.1.1",
Expand Down
34 changes: 26 additions & 8 deletions src/services/blocks/BlocksService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ import LRU from 'lru-cache';

import { sanitizeNumbers } from '../../sanitize/sanitizeNumbers';
import { createCall } from '../../test-helpers/createCall';
import { polkadotMetadataV29 } from '../../test-helpers/metadata/metadata';
import {
kusamaRegistry,
polkadotRegistry,
} from '../../test-helpers/registries';
import { createApiWithAugmentations } from '../../test-helpers/typeFactory';
import { ExtBaseWeightValue, PerClassValue } from '../../types/chains-config';
import { IBlock, IExtrinsic } from '../../types/responses/';
import {
Expand Down Expand Up @@ -309,23 +307,43 @@ describe('BlocksService', () => {
// Reset LRU cache
cache.reset();

const historicApi = createApiWithAugmentations(
polkadotMetadataV29.toHex()
) as ApiDecoration<'promise'>;
/**
* This is the mockApi adjusted to mock a runtime that uses
* consts.system.blockWeights for its weight nomination.
*/
const mockHistoricApiAdjusted = {
consts: {
system: {
blockWeights: {
perClass: {
normal: {
baseExtrinsic: polkadotRegistry.createType('u64', 125000000),
},
operational: {
baseExtrinsic: polkadotRegistry.createType('u64', 125000000),
},
mandatory: {
baseExtrinsic: polkadotRegistry.createType('u64', 125000000),
},
},
},
},
},
} as unknown as ApiDecoration<'promise'>;

const weightValue = blocksService['getWeight'](historicApi);
const weightValue = blocksService['getWeight'](mockHistoricApiAdjusted);

expect(
(weightValue as unknown as PerClassValue).perClass.normal.baseExtrinsic
).toBe(BigInt(125000000));
expect(
(weightValue as unknown as PerClassValue).perClass.operational
.baseExtrinsic
).toBe(BigInt(1));
).toBe(BigInt(125000000));
expect(
(weightValue as unknown as PerClassValue).perClass.mandatory
.baseExtrinsic
).toBe(BigInt(512000000000001));
).toBe(BigInt(125000000));
});
});

Expand Down
Loading

0 comments on commit c348363

Please sign in to comment.