Bump dev & adjust duplicated exports (#5651)

This commit is contained in:
Jaco
2023-05-21 12:40:07 +03:00
committed by GitHub
parent 0e46592f4d
commit 3d0a1701fa
45 changed files with 418 additions and 123 deletions
+2 -1
View File
@@ -21,7 +21,7 @@ describe('Combinator', (): void => {
fns = [];
});
it('it triggers on all values', async (): Promise<void> => {
it('triggers on all values', async (): Promise<void> => {
await new Promise<boolean>((resolve) => {
let count = 0;
const combinator = new Combinator(
@@ -90,6 +90,7 @@ describe('Combinator', (): void => {
});
});
// eslint-disable-next-line jest/expect-expect
it('unsubscribes as required', async (): Promise<void> => {
await new Promise<void>((resolve) => {
// eslint-disable-next-line @typescript-eslint/require-await
+1
View File
@@ -87,6 +87,7 @@ describe('ApiPromise', (): void => {
await api.disconnect();
});
// eslint-disable-next-line jest/expect-expect
it('Create API instance will error on failure to await ready', async (): Promise<void> => {
class ErrorApiPromise extends ApiPromise {
constructor () {
+7
View File
@@ -25,12 +25,19 @@ export type { Signer, SignerResult } from '@polkadot/types/types';
export { ApiBase } from '../base/index.js';
// all starred
// eslint-disable-next-line import/export
export * from '@polkadot/api/types/calls';
// eslint-disable-next-line import/export
export * from '@polkadot/api/types/consts';
// eslint-disable-next-line import/export
export * from '@polkadot/api/types/errors';
// eslint-disable-next-line import/export
export * from '@polkadot/api/types/events';
// eslint-disable-next-line import/export
export * from '@polkadot/api/types/storage';
// eslint-disable-next-line import/export
export * from '@polkadot/api/types/submittable';
// eslint-disable-next-line import/export
export * from '@polkadot/api-base/types';
// A smaller interface of ApiRx, used in derive and in SubmittableExtrinsic
+1 -1
View File
@@ -46,7 +46,7 @@ describe('extractStorageArgs', (): void => {
).toThrow('staking.payee(AccountId32) is a map, requiring 1 arguments, 0 found');
});
it('validates map, 1 arg (failing with no args)', (): void => {
it('validates map, 1 arg (failing with more args)', (): void => {
expect(
() => extractStorageArgs(registry, storage.staking.payee, ['abc', 'def'])
).toThrow('staking.payee(AccountId32) is a map, requiring 1 arguments, 2 found');
+1 -1
View File
@@ -28,7 +28,7 @@ describe('replay', (): void => {
await new Promise<boolean>((resolve) => {
rpc.system.chain().subscribe((value: any): void => {
if (value) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access, jest/no-conditional-expect
expect(value.toString()).toEqual('mockChain'); // Defined in MockProvider
resolve(true);
}
@@ -45,14 +45,17 @@ describe('Http', (): void => {
it('does not (yet) support subscribe', async (): Promise<void> => {
await http.subscribe('', '', [], (cb): void => {
// eslint-disable-next-line jest/no-conditional-expect
expect(cb).toEqual(expect.anything());
}).catch((error): void => {
// eslint-disable-next-line jest/no-conditional-expect
expect((error as Error).message).toMatch(/does not have subscriptions/);
});
});
it('does not (yet) support unsubscribe', async (): Promise<void> => {
await http.unsubscribe('', '', 0).catch((error): void => {
// eslint-disable-next-line jest/no-conditional-expect
expect((error as Error).message).toMatch(/does not have subscriptions/);
});
});
@@ -10,6 +10,7 @@ import { HttpProvider } from './index.js';
// Does not work with Node 18 (native fetch)
// See https://github.com/nock/nock/issues/2397
// eslint-disable-next-line jest/no-disabled-tests
describe.skip('send', (): void => {
let http: HttpProvider;
let mock: Mock;
@@ -53,6 +54,7 @@ describe.skip('send', (): void => {
return http
.send('test_error', [])
.catch((error): void => {
// eslint-disable-next-line jest/no-conditional-expect
expect((error as Error).message).toMatch(/\[500\]/);
});
});
+2 -1
View File
@@ -21,7 +21,8 @@ describe('on', (): void => {
await mock.disconnect();
});
it('it emits both connected and disconnected events', async (): Promise<void> => {
// eslint-disable-next-line jest/expect-expect
it('emits both connected and disconnected events', async (): Promise<void> => {
const events: Record<string, boolean> = { connected: false, disconnected: false };
await new Promise<boolean>((resolve) => {
@@ -23,6 +23,7 @@ describe('send', (): void => {
return mock
.send('something_invalid', [])
.catch((error): void => {
// eslint-disable-next-line jest/no-conditional-expect
expect((error as Error).message).toMatch(/Invalid method/);
});
});
@@ -23,6 +23,7 @@ describe('subscribe', (): void => {
await mock
.subscribe('test', 'test_notFound')
.catch((error): void => {
// eslint-disable-next-line jest/no-conditional-expect
expect((error as Error).message).toMatch(/Invalid method 'test_notFound'/);
});
});
@@ -41,12 +42,14 @@ describe('subscribe', (): void => {
await new Promise<boolean>((resolve) => {
mock.subscribe('chain_newHead', 'chain_subscribeNewHead', (_: any, value: string): void => {
// eslint-disable-next-line jest/no-conditional-expect
expect(value).toEqual('testValue');
resolve(true);
}).catch(console.error);
});
});
// eslint-disable-next-line jest/expect-expect
it('calls back with new headers', async (): Promise<void> => {
await new Promise<boolean>((resolve) => {
mock.subscribe('chain_newHead', 'chain_subscribeNewHead', (_: any, header: { number: number }): void => {
@@ -57,6 +60,7 @@ describe('subscribe', (): void => {
});
});
// eslint-disable-next-line jest/expect-expect
it('handles errors within callbacks gracefully', async (): Promise<void> => {
let hasThrown = false;
@@ -30,12 +30,14 @@ describe('unsubscribe', (): void => {
await mock
.unsubscribe('chain_newHead', 'chain_subscribeNewHead', 5)
.catch((error): boolean => {
// eslint-disable-next-line jest/no-conditional-expect
expect((error as Error).message).toMatch(/Unable to find/);
return false;
});
});
// eslint-disable-next-line jest/expect-expect
it('unsubscribes successfully', async (): Promise<void> => {
await mock.unsubscribe('chain_newHead', 'chain_subscribeNewHead', id);
});
@@ -46,6 +48,7 @@ describe('unsubscribe', (): void => {
mock.unsubscribe('chain_newHead', 'chain_subscribeNewHead', id)
)
.catch((error): boolean => {
// eslint-disable-next-line jest/no-conditional-expect
expect((error as Error).message).toMatch(/Unable to find/);
return false;
@@ -321,6 +321,7 @@ describe('ScProvider', () => {
expect(chain._isTerminated()).toBe(true);
});
// eslint-disable-next-line jest/expect-expect
it('does not throw when disconnecting on an already disconnected Provider', async () => {
const provider = new ScProvider(mockSc, '');
@@ -39,10 +39,12 @@ describe('Ws', (): void => {
).toEqual(false);
});
// eslint-disable-next-line jest/expect-expect
it('allows you to initialize the provider with custom headers', () => {
createWs([], 100, { foo: 'bar' });
});
// eslint-disable-next-line jest/expect-expect
it('allows you to set custom timeout value for handlers', () => {
const CUSTOM_TIMEOUT_S = 90;
const CUSTOM_TIMEOUT_MS = CUSTOM_TIMEOUT_S * 1000;
@@ -52,6 +54,7 @@ describe('Ws', (): void => {
});
describe('Endpoint Parsing', (): void => {
// eslint-disable-next-line jest/expect-expect
it('Succeeds when WsProvider endpoint is a valid string', () => {
/* eslint-disable no-new */
new WsProvider(TEST_WS_URL, 0);
@@ -63,6 +66,7 @@ describe('Endpoint Parsing', (): void => {
).toThrow(/^Endpoint should start with /);
});
// eslint-disable-next-line jest/expect-expect
it('Succeeds when WsProvider endpoint is a valid array', () => {
const endpoints: string[] = ['ws://127.0.0.1:9955', 'wss://testnet.io:9944', 'ws://mychain.com:9933'];
@@ -59,6 +59,7 @@ describe('send', (): void => {
ws
.send('test_encoding', [{ error: 'send error' }])
.catch((error): void => {
// eslint-disable-next-line jest/no-conditional-expect
expect((error as Error).message).toEqual('send error');
})
);
@@ -99,6 +100,7 @@ describe('send', (): void => {
ws
.send('test_error', [])
.catch((error): void => {
// eslint-disable-next-line jest/no-conditional-expect
expect((error as Error).message).toMatch(/666: error/);
})
);
+3
View File
@@ -8,3 +8,6 @@ import { readTemplate } from './file.js';
Handlebars.registerPartial({
docs: Handlebars.compile(readTemplate('docs'))
});
// empty export
export const __TYPEGEN_DUMMY_DOCS = 'DUMMY_DOCS';
@@ -16,7 +16,7 @@ describe('Compact', (): void => {
describe('constructor', (): void => {
it('fails on > MAX_SAFE_INTEGER', (): void => {
// eslint-disable-next-line @typescript-eslint/no-loss-of-precision
// eslint-disable-next-line @typescript-eslint/no-loss-of-precision, no-loss-of-precision
expect(() => new Compact(registry, 'u128', 9007199254740999)).toThrow(/integer <= Number.MAX_SAFE_INTEGER/);
});
+2 -2
View File
@@ -18,7 +18,7 @@ describe('Result', (): void => {
it('decodes from a u8a (success)', (): void => {
const result = new Type(registry, new Uint8Array([0, 1, 2, 3, 4]));
expect(result.isOk);
expect(result.isOk).toBe(true);
expect(result.asOk.toU8a()).toEqual(new Uint8Array([1, 2, 3, 4]));
expect(result.toHex()).toEqual('0x0001020304');
expect(result.toJSON()).toEqual({
@@ -29,7 +29,7 @@ describe('Result', (): void => {
it('decodes from a u8a (error)', (): void => {
const result = new Type(registry, new Uint8Array([1, 4 << 2, 100, 101, 102, 103]));
expect(result.isErr);
expect(result.isErr).toBe(true);
expect(result.asErr.toU8a()).toEqual(new Uint8Array([4 << 2, 100, 101, 102, 103]));
expect(result.toHex()).toEqual('0x011064656667');
expect(result.toJSON()).toEqual({
+2 -2
View File
@@ -13,9 +13,9 @@ describe('UInt', (): void => {
const registry = new TypeRegistry();
it('fails on > MAX_SAFE_INTEGER and float', (): void => {
// eslint-disable-next-line @typescript-eslint/no-loss-of-precision
// eslint-disable-next-line @typescript-eslint/no-loss-of-precision, no-loss-of-precision
expect(() => new UInt(registry, 9007199254740999)).toThrow(/integer <= Number.MAX_SAFE_INTEGER/);
// eslint-disable-next-line @typescript-eslint/no-loss-of-precision
// eslint-disable-next-line @typescript-eslint/no-loss-of-precision, no-loss-of-precision
expect(() => new UInt(registry, -9007199254740999)).toThrow(/integer <= Number.MAX_SAFE_INTEGER/);
expect(() => new UInt(registry, 9.123)).toThrow(/integer <= Number.MAX_SAFE_INTEGER/);
});
+2 -2
View File
@@ -39,7 +39,7 @@ describe('Vec', (): void => {
expect(new Vec(registry, Text, null)).toHaveLength(0);
});
it('decodes a complex type via construction', (): void => {
it('decodes a complex type via construction (1)', (): void => {
const test = createTypeUnsafe<Vec<ITuple<[PropIndex, AccountId]>>>(registry, 'Vec<(PropIndex, AccountId)>', [new Uint8Array([
4, 10, 0, 0, 0, 209, 114, 167, 76, 218, 76, 134, 89, 18, 195, 43, 160, 168, 10, 87, 174, 105, 171, 174, 65, 14, 92, 203, 89, 222, 232, 78, 47, 68, 50, 219, 79
])]);
@@ -48,7 +48,7 @@ describe('Vec', (): void => {
expect(test[0][1].toString()).toEqual('5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaQua');
});
it('decodes a complex type via construction', (): void => {
it('decodes a complex type via construction (2)', (): void => {
const INPUT = '0x08cc0200000000ce0200000001';
const test = createTypeUnsafe<Vec<Codec>>(registry, 'Vec<(u32, [u32; 0], u16)>', [INPUT]);
@@ -141,7 +141,7 @@ export class BTreeSet<V extends Codec = Codec> extends Set<V> implements ISet<V>
* @description Returns a breakdown of the hex encoding for this Codec
*/
public inspect (): Inspect {
const inner = new Array<Inspect>();
const inner: Inspect[] = [];
for (const v of this.values()) {
inner.push(v.inspect());
@@ -218,7 +218,7 @@ export class BTreeSet<V extends Codec = Codec> extends Set<V> implements ISet<V>
* @param isBare true when the value has none of the type-specific prefixes (internal)
*/
public toU8a (isBare?: boolean): Uint8Array {
const encoded = new Array<Uint8Array>();
const encoded: Uint8Array[] = [];
if (!isBare) {
encoded.push(compactToU8a(this.size));
@@ -15,7 +15,7 @@ const registry = new TypeRegistry();
describe('BitVec', (): void => {
describe('decoding known', (): void => {
TESTS.forEach((test): void => {
describe(test, (): void => {
describe(`${test}`, (): void => {
const input = hexToU8a(test);
const bitvec = new BitVec(registry, input);
+2 -2
View File
@@ -154,7 +154,7 @@ export class CodecMap<K extends Codec = Codec, V extends Codec = Codec> extends
* @description Returns a breakdown of the hex encoding for this Codec
*/
public inspect (): Inspect {
const inner = new Array<Inspect>();
const inner: Inspect[] = [];
for (const [k, v] of this.entries()) {
inner.push(k.inspect());
@@ -240,7 +240,7 @@ export class CodecMap<K extends Codec = Codec, V extends Codec = Codec> extends
* @param isBare true when the value has none of the type-specific prefixes (internal)
*/
public toU8a (isBare?: boolean): Uint8Array {
const encoded = new Array<Uint8Array>();
const encoded: Uint8Array[] = [];
if (!isBare) {
encoded.push(compactToU8a(this.size));
+1 -1
View File
@@ -233,7 +233,7 @@ export class Struct<
* @description Returns a breakdown of the hex encoding for this Codec
*/
public inspect (isBare?: BareOpts): Inspect {
const inner = new Array<Inspect>();
const inner: Inspect[] = [];
for (const [k, v] of this.entries()) {
inner.push({
@@ -1,6 +1,8 @@
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
// SPDX-License-Identifier: Apache-2.0
/* global it */
// Shamelessly copied from @polkadot/util/test
import { formatDecimal, formatNumber } from '@polkadot/util';
+1 -2
View File
@@ -6,5 +6,4 @@ export { packageInfo } from './packageInfo.js';
export { TypeDefInfo } from './types/index.js';
// all starred
export * from './create/index.js';
export * from './util/index.js';
export * from './exports.js';
+6
View File
@@ -0,0 +1,6 @@
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
// SPDX-License-Identifier: Apache-2.0
// all starred
export * from './create/index.js';
export * from './util/index.js';
@@ -45,6 +45,7 @@ for (const chain of keys) {
});
for (const [blockNumber, specVersion] of allMan[chain]) {
// eslint-disable-next-line jest/expect-expect
it(`blockNumber=${blockNumber}, specVersion=${specVersion}`, async (): Promise<void> => {
const found = avail.find(([n, s]) => n === blockNumber && s === specVersion);
@@ -64,7 +64,8 @@ describe('generated', (): void => {
});
for (const chain of Object.keys(allMan)) {
describe(chain, (): void => {
describe(`${chain}`, (): void => {
// eslint-disable-next-line jest/expect-expect
it('should have all generated', (): void => {
const missing = allMan[chain as keyof typeof allMan].filter(([na, sa]) =>
!allGen[chain as keyof typeof allGen].some(([nb, sb]) =>
@@ -78,10 +79,12 @@ describe('generated', (): void => {
}
});
// eslint-disable-next-line jest/expect-expect
it('manual should be correctly ordered', (): void => {
checkOrder(chain, (allGen as Record<string, ChainUpgradesExpanded>)[chain]);
});
// eslint-disable-next-line jest/expect-expect
it('generated should be correctly ordered', (): void => {
checkOrder(chain, (allMan as Record<string, ChainUpgradesRaw>)[chain]);
});
@@ -91,7 +94,7 @@ describe('generated', (): void => {
describe('upgrades', (): void => {
TESTS.forEach(({ genesisHash, network, versions }): void => {
describe(network, (): void => {
describe(`${network}`, (): void => {
const chain = upgrades.find((n) => n.network === network);
if (!chain) {
+2 -2
View File
@@ -198,14 +198,14 @@ describe('createType', (): void => {
it('allows for re-registration of a type', (): void => {
const balDef = registry.createType('Balance');
expect(balDef instanceof registry.createClass('Balance'));
expect(balDef instanceof registry.createClass('Balance')).toBe(true);
expect(balDef.bitLength()).toEqual(128);
registry.register({ Balance: 'u32' });
const balu32 = registry.createType('Balance');
expect(balu32 instanceof registry.createClass('Balance'));
expect(balu32 instanceof registry.createClass('Balance')).toBe(true);
expect(balu32.bitLength()).toEqual(32);
});
+1 -1
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
// all external
export * from '@polkadot/types-create';
export * from '@polkadot/types-create/exports';
// all local
export * from './createClass.js';
+1 -1
View File
@@ -31,7 +31,7 @@ describe('TypeRegistry', (): void => {
expect(Type).toBeDefined();
// eslint-disable-next-line no-prototype-builtins
expect(isChildClass(DoNotConstruct, Type));
expect(isChildClass(DoNotConstruct, Type)).toBe(true);
});
it('can register single type', (): void => {
@@ -1,6 +1,8 @@
// Copyright 2017-2023 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
/* eslint-disable jest/expect-expect */
/// <reference types="@polkadot/dev-test/globals.d.ts" />
import { BN } from '@polkadot/util';
@@ -55,7 +55,7 @@ describe('ChainProperties', (): void => {
expect(tokenSymbol.unwrap().eq(['KSM'])).toBe(true);
});
it('has a sane toHuman', (): void => {
it('has a sane toHuman (single tokenDecimals)', (): void => {
expect(
registry.createType('ChainProperties', {
ss58Format: 42,
@@ -69,7 +69,7 @@ describe('ChainProperties', (): void => {
});
});
it('has a sane toHuman', (): void => {
it('has a sane toHuman (multiple tokenDecimals)', (): void => {
expect(
registry.createType('ChainProperties', {
ss58Format: 2,
+5 -1
View File
@@ -30,7 +30,7 @@ const metadata = new Metadata(registry, metadataStatic);
registry.setMetadata(metadata);
function testTypes (type: string, typeNames: string[]): void {
describe(type, (): void => {
describe(`${type}`, (): void => {
describe(`${type}:: default creation`, (): void => {
typeNames.forEach((name): void => {
it(`creates an empty ${name}`, (): void => {
@@ -38,8 +38,10 @@ function testTypes (type: string, typeNames: string[]): void {
registry.createType(name);
if (UNCONSTRUCTABLE.includes(name.toLowerCase())) {
// eslint-disable-next-line jest/no-conditional-expect
expect(constructFn).toThrow();
} else {
// eslint-disable-next-line jest/no-conditional-expect
expect(constructFn).not.toThrow();
}
});
@@ -53,8 +55,10 @@ function testTypes (type: string, typeNames: string[]): void {
registry.createType(name, registry.createType('Bytes'));
if (UNCONSTRUCTABLE.includes(name.toLowerCase())) {
// eslint-disable-next-line jest/no-conditional-expect
expect(constructFn).toThrow();
} else {
// eslint-disable-next-line jest/no-conditional-expect
expect(constructFn).not.toThrow();
}
});
@@ -53,7 +53,7 @@ describe('type definitions', (): void => {
);
for (const [key, { types }] of allTypes) {
describe(key, (): void => {
describe(`${key}`, (): void => {
const typesKeys = Object.keys(types).filter((type) =>
// meant to fail
type !== 'ExtrinsicUnknown' &&
@@ -80,11 +80,11 @@ describe('rpc definitions', (): void => {
);
for (const [section, { rpc }] of rpcs) {
describe(section, (): void => {
describe(`${section}`, (): void => {
const methodsEntries = Object.entries<DefinitionRpc>(rpc);
for (const [method, { params, type }] of methodsEntries) {
describe(method, (): void => {
describe(`${method}`, (): void => {
// We cannot constuct V0, so just ignore
if (section !== 'state' || method !== 'getMetadata') {
it(`output ${type} is known`, (): void => {
@@ -114,17 +114,17 @@ describe('runtime definitions', (): void => {
);
for (const [key, { runtime }] of runtimes) {
describe(key, (): void => {
describe(`${key}`, (): void => {
const versionsEntries = Object.entries<DefinitionsCallEntry[]>(runtime);
for (const [key, versions] of versionsEntries) {
describe(key, (): void => {
describe(`${key}`, (): void => {
for (const { methods, version } of versions) {
describe(`version ${version}`, (): void => {
const methodsEntries = Object.entries<DefinitionCall>(methods);
for (const [key, { params, type }] of methodsEntries) {
describe(key, (): void => {
describe(`${key}`, (): void => {
// Applied from runtime, used in Funglibles
if (type !== 'Result<Vec<XcmV3MultiAsset>, FungiblesAccessError>') {
it(`output ${type} is known`, (): void => {
@@ -3,6 +3,8 @@
/// <reference types="@polkadot/dev-test/globals.d.ts" />
/* global describe, it, expect */
import type { Registry } from '@polkadot/types-codec/types';
import type { Check } from './types.js';