Adjust tests for node:test env (#5509)
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
"version": "9.14.3-2-x",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@babel/runtime": "^7.21.0",
|
||||
"@polkadot/api-base": "9.14.3-2-x",
|
||||
"@polkadot/rpc-augment": "9.14.3-2-x",
|
||||
"@polkadot/types": "9.14.3-2-x",
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
"version": "9.14.3-2-x",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@babel/runtime": "^7.21.0",
|
||||
"@polkadot/rpc-core": "9.14.3-2-x",
|
||||
"@polkadot/types": "9.14.3-2-x",
|
||||
"@polkadot/util": "^10.4.2",
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
"version": "9.14.3-2-x",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@babel/runtime": "^7.21.0",
|
||||
"@polkadot/api": "9.14.3-2-x",
|
||||
"@polkadot/types": "9.14.3-2-x",
|
||||
"@polkadot/types-codec": "9.14.3-2-x",
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
// Copyright 2017-2023 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import process from 'process';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import process from 'node:process';
|
||||
|
||||
import { TypeDefInfo } from '@polkadot/types/types';
|
||||
import { blake2AsHex } from '@polkadot/util-crypto';
|
||||
@@ -86,24 +89,26 @@ describe('Abi', (): void => {
|
||||
});
|
||||
|
||||
describe('TypeDef', (): void => {
|
||||
it.each(Object.keys(abis))('initializes from a contract ABI: %s', (abiName): void => {
|
||||
const abi = new Abi(abis[abiName]);
|
||||
const json = stringifyJson(abi.registry);
|
||||
const cmpFile = path.join(cmpPath, `${abiName}.test.json`);
|
||||
const cmpText = fs.readFileSync(cmpFile, 'utf-8');
|
||||
for (const [abiName, abiJson] of Object.entries(abis)) {
|
||||
it(`initializes from a contract ABI: ${abiName}`, (): void => {
|
||||
const abi = new Abi(abiJson);
|
||||
const registryJson = stringifyJson(abi.registry);
|
||||
const cmpFile = path.join(cmpPath, `${abiName}.test.json`);
|
||||
const cmpText = fs.readFileSync(cmpFile, 'utf-8');
|
||||
|
||||
try {
|
||||
expect(JSON.parse(json)).toEqual(JSON.parse(cmpText));
|
||||
} catch (error) {
|
||||
if (process.env.GITHUB_REPOSITORY) {
|
||||
console.error(json);
|
||||
try {
|
||||
expect(JSON.parse(registryJson)).toEqual(JSON.parse(cmpText));
|
||||
} catch (error) {
|
||||
if (process.env.GITHUB_REPOSITORY) {
|
||||
console.error(registryJson);
|
||||
|
||||
throw error;
|
||||
throw error;
|
||||
}
|
||||
|
||||
fs.writeFileSync(cmpFile, registryJson, { flag: 'w' });
|
||||
}
|
||||
|
||||
fs.writeFileSync(cmpFile, json, { flag: 'w' });
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
it('has the correct hash for the source', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import abis from '../test/contracts';
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
// Copyright 2017-2023 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import process from 'process';
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import process from 'node:process';
|
||||
|
||||
import { toPromiseMethod } from '@polkadot/api';
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
"version": "9.14.3-2-x",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@babel/runtime": "^7.21.0",
|
||||
"@polkadot/api": "9.14.3-2-x",
|
||||
"@polkadot/api-augment": "9.14.3-2-x",
|
||||
"@polkadot/api-base": "9.14.3-2-x",
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { SubmittableExtrinsic } from '@polkadot/api-base/types';
|
||||
import type { Bytes, Option, StorageKey } from '@polkadot/types';
|
||||
import type { Bounty, BountyIndex, Proposal, ProposalIndex } from '@polkadot/types/interfaces';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
||||
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
||||
@@ -39,7 +42,9 @@ describe('derive', (): void => {
|
||||
describe('builtin', (): void => {
|
||||
const api = new ApiRx({ provider: new MockProvider(registry), registry });
|
||||
|
||||
beforeAll(() => waitReady(api));
|
||||
beforeAll(async () => {
|
||||
await waitReady(api);
|
||||
});
|
||||
afterAll(() => api.disconnect());
|
||||
|
||||
testFunction(api)('accounts', 'idAndIndex', []);
|
||||
@@ -82,7 +87,9 @@ describe('derive', (): void => {
|
||||
throwOnConnect: true
|
||||
});
|
||||
|
||||
beforeAll(() => waitReady(api));
|
||||
beforeAll(async () => {
|
||||
await waitReady(api);
|
||||
});
|
||||
afterAll(() => api.disconnect());
|
||||
|
||||
// override
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { ApprovalFlag } from '@polkadot/types/interfaces';
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
"version": "9.14.3-2-x",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@babel/runtime": "^7.21.0",
|
||||
"@polkadot/api-augment": "9.14.3-2-x",
|
||||
"@polkadot/api-base": "9.14.3-2-x",
|
||||
"@polkadot/api-derive": "9.14.3-2-x",
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { UnsubscribePromise } from '../types';
|
||||
|
||||
import { Combinator } from './Combinator';
|
||||
@@ -84,7 +87,7 @@ describe('Combinator', (): void => {
|
||||
|
||||
it('unsubscribes as required', (done): void => {
|
||||
// eslint-disable-next-line @typescript-eslint/require-await
|
||||
const mocker = async (): Promise<any> => done;
|
||||
const mocker = () => Promise.resolve(done);
|
||||
const combinator = new Combinator([
|
||||
mocker,
|
||||
// eslint-disable-next-line @typescript-eslint/require-await
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { SubmittableExtrinsic } from '../types';
|
||||
|
||||
@@ -101,7 +104,7 @@ describe('ApiPromise', (): void => {
|
||||
|
||||
await api.disconnect();
|
||||
|
||||
fail('Expected an error but none occurred.');
|
||||
throw new Error('Expected an error but none occurred.');
|
||||
} catch {
|
||||
// Pass
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
// Copyright 2017-2023 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { augmentObject } from './augmentObject';
|
||||
|
||||
describe('augmentObject', (): void => {
|
||||
let spy: jest.SpyInstance;
|
||||
let spy: ReturnType<typeof jest.spyOn>;
|
||||
|
||||
beforeEach((): void => {
|
||||
spy = jest.spyOn(console, 'warn');
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { decorateStorage, Metadata, TypeRegistry } from '@polkadot/types';
|
||||
import metaStatic from '@polkadot/types-support/metadata/static-substrate';
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
"version": "9.14.3-2-x",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@babel/runtime": "^7.21.0",
|
||||
"@polkadot/rpc-core": "9.14.3-2-x",
|
||||
"@polkadot/types": "9.14.3-2-x",
|
||||
"@polkadot/types-codec": "9.14.3-2-x",
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
"version": "9.14.3-2-x",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@babel/runtime": "^7.21.0",
|
||||
"@polkadot/rpc-augment": "9.14.3-2-x",
|
||||
"@polkadot/rpc-provider": "9.14.3-2-x",
|
||||
"@polkadot/types": "9.14.3-2-x",
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/rpc-core authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { RpcInterface } from './types';
|
||||
|
||||
import { createTestPairs } from '@polkadot/keyring/testingPairs';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/rpc-core authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { ProviderInterface } from '@polkadot/rpc-provider/types';
|
||||
|
||||
import { MockProvider } from '@polkadot/rpc-provider/mock';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/rpc-core authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { ProviderInterface } from '@polkadot/rpc-provider/types';
|
||||
import type { DefinitionRpc } from '@polkadot/types/types';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/rpc-core authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { RpcInterface } from './types';
|
||||
|
||||
import { MockProvider } from '@polkadot/rpc-provider/mock';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { of, timer } from 'rxjs';
|
||||
|
||||
import { drr } from '.';
|
||||
@@ -17,7 +20,9 @@ describe('drr', (): void => {
|
||||
expect(count).toBe(1);
|
||||
sub.unsubscribe();
|
||||
|
||||
setTimeout(done, 2000);
|
||||
setTimeout(() => {
|
||||
done();
|
||||
}, 2000);
|
||||
}, 50);
|
||||
});
|
||||
|
||||
@@ -31,7 +36,9 @@ describe('drr', (): void => {
|
||||
const sub = obs.subscribe((value): void => {
|
||||
expect(value > 1).toBe(true);
|
||||
|
||||
setTimeout(done, 2000);
|
||||
setTimeout(() => {
|
||||
done();
|
||||
}, 2000);
|
||||
});
|
||||
|
||||
sub.unsubscribe();
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
"version": "9.14.3-2-x",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@babel/runtime": "^7.21.0",
|
||||
"@polkadot/keyring": "^10.4.2",
|
||||
"@polkadot/types": "9.14.3-2-x",
|
||||
"@polkadot/types-support": "9.14.3-2-x",
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/rpc-provider authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { JsonRpcResponse } from '../types';
|
||||
|
||||
import { RpcCoder } from '.';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/rpc-provider authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { RpcCoder } from '.';
|
||||
|
||||
describe('encodeJson', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/rpc-provider authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { RpcCoder } from '.';
|
||||
|
||||
describe('encodeObject', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/rpc-provider authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { isError } from '@polkadot/util/is/error';
|
||||
|
||||
import RpcError from './error';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/rpc-provider authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TEST_HTTP_URL } from '../mock/mockHttp';
|
||||
import { HttpProvider } from './';
|
||||
|
||||
@@ -41,16 +44,16 @@ describe('Http', (): void => {
|
||||
expect(http.isConnected).toEqual(true);
|
||||
});
|
||||
|
||||
it('does not (yet) support subscribe', (): Promise<number | void> => {
|
||||
return http.subscribe('', '', [], (cb): void => {
|
||||
it('does not (yet) support subscribe', async (): Promise<void> => {
|
||||
await http.subscribe('', '', [], (cb): void => {
|
||||
expect(cb).toEqual(expect.anything());
|
||||
}).catch((error): void => {
|
||||
expect((error as Error).message).toMatch(/does not have subscriptions/);
|
||||
});
|
||||
});
|
||||
|
||||
it('does not (yet) support unsubscribe', (): Promise<boolean | void> => {
|
||||
return http.unsubscribe('', '', 0).catch((error): void => {
|
||||
it('does not (yet) support unsubscribe', async (): Promise<void> => {
|
||||
await http.unsubscribe('', '', 0).catch((error): void => {
|
||||
expect((error as Error).message).toMatch(/does not have subscriptions/);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/rpc-provider authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { Mock } from '../mock/types';
|
||||
|
||||
import { mockHttp, TEST_HTTP_URL } from '../mock/mockHttp';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/rpc-provider authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { LRUCache } from './lru';
|
||||
|
||||
describe('LRUCache', (): void => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/rpc-provider authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { ProviderInterfaceEmitted } from '../types';
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/rpc-provider authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
import { MockProvider } from '.';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/rpc-provider authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
import { MockProvider } from './';
|
||||
@@ -17,16 +20,16 @@ describe('subscribe', (): void => {
|
||||
await mock.disconnect();
|
||||
});
|
||||
|
||||
it('fails on unknown methods', (): Promise<number | void> => {
|
||||
return mock
|
||||
it('fails on unknown methods', async (): Promise<void> => {
|
||||
await mock
|
||||
.subscribe('test', 'test_notFound')
|
||||
.catch((error): void => {
|
||||
expect((error as Error).message).toMatch(/Invalid method 'test_notFound'/);
|
||||
});
|
||||
});
|
||||
|
||||
it('returns a subscription id', (): Promise<void> => {
|
||||
return mock
|
||||
it('returns a subscription id', async (): Promise<void> => {
|
||||
await mock
|
||||
.subscribe('chain_newHead', 'chain_subscribeNewHead', (): void => undefined)
|
||||
.then((id): void => {
|
||||
expect(id).toEqual(1);
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Server } from 'mock-socket';
|
||||
import type { Constructor } from '@polkadot/types/types';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||
export interface Global extends NodeJS.Global {
|
||||
WebSocket: Constructor<WebSocket>;
|
||||
export type Global = typeof globalThis & {
|
||||
WebSocket: typeof WebSocket;
|
||||
fetch: any;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/rpc-provider authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
import { MockProvider } from '.';
|
||||
@@ -24,8 +27,8 @@ describe('unsubscribe', (): void => {
|
||||
await mock.disconnect();
|
||||
});
|
||||
|
||||
it('fails on unknown ids', (): Promise<boolean> => {
|
||||
return mock
|
||||
it('fails on unknown ids', async (): Promise<void> => {
|
||||
await mock
|
||||
.unsubscribe('chain_newHead', 'chain_subscribeNewHead', 5)
|
||||
.catch((error): boolean => {
|
||||
expect((error as Error).message).toMatch(/Unable to find/);
|
||||
@@ -34,12 +37,12 @@ describe('unsubscribe', (): void => {
|
||||
});
|
||||
});
|
||||
|
||||
it('unsubscribes successfully', (): Promise<boolean> => {
|
||||
return mock.unsubscribe('chain_newHead', 'chain_subscribeNewHead', id);
|
||||
it('unsubscribes successfully', async (): Promise<void> => {
|
||||
await mock.unsubscribe('chain_newHead', 'chain_subscribeNewHead', id);
|
||||
});
|
||||
|
||||
it('fails on double unsubscribe', (): Promise<boolean> => {
|
||||
return mock.unsubscribe('chain_newHead', 'chain_subscribeNewHead', id)
|
||||
it('fails on double unsubscribe', async (): Promise<void> => {
|
||||
await mock.unsubscribe('chain_newHead', 'chain_subscribeNewHead', id)
|
||||
.then((): Promise<boolean> =>
|
||||
mock.unsubscribe('chain_newHead', 'chain_subscribeNewHead', id)
|
||||
)
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/rpc-provider authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
/* eslint-disable sort-keys */
|
||||
/* eslint-disable promise/param-names */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/rpc-provider authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { Mock } from '../mock/types';
|
||||
|
||||
import { mockWs } from '../mock/mockWs';
|
||||
|
||||
@@ -22,22 +22,20 @@ const known: Record<number, string> = {
|
||||
1015: 'TLS Handshake'
|
||||
};
|
||||
|
||||
function getUnmapped (code: number): string | void {
|
||||
if (code <= 1999) {
|
||||
return '(For WebSocket standard)';
|
||||
} else if (code <= 2999) {
|
||||
return '(For WebSocket extensions)';
|
||||
} else if (code <= 3999) {
|
||||
return '(For libraries and frameworks)';
|
||||
} else if (code <= 4999) {
|
||||
return '(For applications)';
|
||||
}
|
||||
}
|
||||
|
||||
export function getWSErrorString (code: number): string {
|
||||
if (code >= 0 && code <= 999) {
|
||||
return '(Unused)';
|
||||
} else if (code >= 1016) {
|
||||
if (code <= 1999) {
|
||||
return '(For WebSocket standard)';
|
||||
} else if (code <= 2999) {
|
||||
return '(For WebSocket extensions)';
|
||||
} else if (code <= 3999) {
|
||||
return '(For libraries and frameworks)';
|
||||
} else if (code <= 4999) {
|
||||
return '(For applications)';
|
||||
}
|
||||
}
|
||||
|
||||
return known[code] || getUnmapped(code) || '(Unknown)';
|
||||
return known[code] || '(Unknown)';
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/rpc-provider authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { Request } from '../mock/mockWs';
|
||||
|
||||
import { mockWs } from '../mock/mockWs';
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/rpc-provider authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Constructor } from '@polkadot/types/types';
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { Request } from '../mock/mockWs';
|
||||
|
||||
import { mockWs } from '../mock/mockWs';
|
||||
@@ -26,7 +28,7 @@ function createWs (autoConnect = 1000): Promise<WsProvider> {
|
||||
}
|
||||
|
||||
describe('send', (): void => {
|
||||
let globalWs: Constructor<WebSocket>;
|
||||
let globalWs: typeof WebSocket;
|
||||
|
||||
beforeEach((): void => {
|
||||
globalWs = global.WebSocket;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/rpc-provider authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { WsProvider } from './';
|
||||
|
||||
describe('state', (): void => {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/rpc-provider authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Constructor } from '@polkadot/types/types';
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { Request } from '../mock/mockWs';
|
||||
import type { Global, Mock } from './../mock/types';
|
||||
|
||||
@@ -26,7 +28,7 @@ function createWs (autoConnect = 1000): Promise<WsProvider> {
|
||||
}
|
||||
|
||||
describe('subscribe', (): void => {
|
||||
let globalWs: Constructor<WebSocket>;
|
||||
let globalWs: typeof WebSocket;
|
||||
|
||||
beforeEach((): void => {
|
||||
globalWs = global.WebSocket;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/rpc-provider authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Constructor } from '@polkadot/types/types';
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { Request } from '../mock/mockWs';
|
||||
import type { Global, Mock } from './../mock/types';
|
||||
|
||||
@@ -26,7 +28,7 @@ function createWs (autoConnect = 1000): Promise<WsProvider> {
|
||||
}
|
||||
|
||||
describe('subscribe', (): void => {
|
||||
let globalWs: Constructor<WebSocket>;
|
||||
let globalWs: typeof WebSocket;
|
||||
|
||||
beforeEach((): void => {
|
||||
globalWs = global.WebSocket;
|
||||
@@ -45,7 +47,7 @@ describe('subscribe', (): void => {
|
||||
}
|
||||
});
|
||||
|
||||
it('removes subscriptions', (): Promise<boolean> => {
|
||||
it('removes subscriptions', async (): Promise<void> => {
|
||||
createMock([
|
||||
{
|
||||
id: 1,
|
||||
@@ -63,7 +65,7 @@ describe('subscribe', (): void => {
|
||||
}
|
||||
]);
|
||||
|
||||
return createWs().then((ws) =>
|
||||
await createWs().then((ws) =>
|
||||
ws
|
||||
.subscribe('test', 'subscribe_test', [], (cb): void => {
|
||||
expect(cb).toEqual(expect.anything());
|
||||
|
||||
@@ -30,9 +30,9 @@
|
||||
"polkadot-types-internal-metadata": "./scripts/polkadot-types-internal-metadata.cjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.20.12",
|
||||
"@babel/register": "^7.18.9",
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@babel/core": "^7.21.0",
|
||||
"@babel/register": "^7.21.0",
|
||||
"@babel/runtime": "^7.21.0",
|
||||
"@polkadot/api": "9.14.3-2-x",
|
||||
"@polkadot/api-augment": "9.14.3-2-x",
|
||||
"@polkadot/rpc-augment": "9.14.3-2-x",
|
||||
@@ -47,7 +47,7 @@
|
||||
"@polkadot/x-ws": "^10.4.2",
|
||||
"handlebars": "^4.7.7",
|
||||
"websocket": "^1.0.34",
|
||||
"yargs": "^17.7.0"
|
||||
"yargs": "^17.7.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/websocket": "^1.0.5",
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { MetadataLatest, SiLookupTypeId } from '@polkadot/types/interfaces'
|
||||
import type { PortableRegistry } from '@polkadot/types/metadata';
|
||||
import type { Codec, DefinitionRpcParam } from '@polkadot/types/types';
|
||||
|
||||
import fs from 'fs';
|
||||
import fs from 'node:fs';
|
||||
|
||||
import { Metadata, TypeRegistry, Vec } from '@polkadot/types';
|
||||
import * as definitions from '@polkadot/types/interfaces/definitions';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2023 @polkadot/typegen authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import fs from 'fs';
|
||||
import fs from 'node:fs';
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
// Copyright 2017-2023 @polkadot/typegen authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
import { getSimilarTypes } from './derived';
|
||||
|
||||
describe('getSimilarTypes', (): void => {
|
||||
let registry: TypeRegistry;
|
||||
|
||||
const registry = new TypeRegistry();
|
||||
const mockImports = {
|
||||
codecTypes: {},
|
||||
definitions: {},
|
||||
@@ -22,10 +24,6 @@ describe('getSimilarTypes', (): void => {
|
||||
typesTypes: {}
|
||||
};
|
||||
|
||||
beforeAll((): void => {
|
||||
registry = new TypeRegistry();
|
||||
});
|
||||
|
||||
it('handles nested Tuples', (): void => {
|
||||
expect(getSimilarTypes(registry, {}, '(AccountId, (Balance, u32), u64)', mockImports)).toEqual([
|
||||
'ITuple<[AccountId, ITuple<[Balance, u32]>, u64]>',
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/typegen authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import process from 'process';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import process from 'node:process';
|
||||
|
||||
import { packageInfo } from '../packageInfo';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/typegen authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import { formatType } from './formatting';
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
"version": "9.14.3-2-x",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@babel/runtime": "^7.21.0",
|
||||
"@polkadot/types": "9.14.3-2-x",
|
||||
"@polkadot/types-codec": "9.14.3-2-x",
|
||||
"@polkadot/util": "^10.4.2"
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
"version": "9.14.3-2-x",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@babel/runtime": "^7.21.0",
|
||||
"@polkadot/util": "^10.4.2",
|
||||
"@polkadot/x-bigint": "^10.4.2"
|
||||
},
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { CodecDate, Compact, U32 } from '@polkadot/types-codec';
|
||||
import { BN } from '@polkadot/util';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { DoNotConstruct } from '@polkadot/types-codec';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { Registry } from '@polkadot/types-codec/types';
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { Int } from '@polkadot/types-codec';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { Null } from '@polkadot/types-codec';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { bool, Bytes, Null, Option, Text, U32 } from '@polkadot/types-codec';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { Result, Text, u32 } from '@polkadot/types-codec';
|
||||
import { hexToString } from '@polkadot/util';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { BlockNumber, VoteThreshold } from '@polkadot/types/interfaces';
|
||||
import type { AnyTupleValue, CodecTo } from '@polkadot/types-codec/types';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { UInt } from '@polkadot/types-codec';
|
||||
import { BN, BN_TWO, isBn } from '@polkadot/util';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { PropIndex } from '@polkadot/types/interfaces/democracy';
|
||||
import type { Codec, CodecTo, ITuple } from '@polkadot/types-codec/types';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { Text, u16, VecFixed } from '@polkadot/types-codec';
|
||||
import { stringToU8a } from '@polkadot/util';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { CodecClass, ITuple } from '@polkadot/types-codec/types';
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { CodecClass, CodecTo } from '@polkadot/types-codec/types';
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { hexToU8a } from '@polkadot/util';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { Bytes } from '@polkadot/types-codec';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { HashMap, Struct, Text, U32 } from '@polkadot/types-codec';
|
||||
import { stringToU8a } from '@polkadot/util';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { Linkage } from '@polkadot/types-codec';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { CodecTo } from '@polkadot/types-codec/types';
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { OptionBool } from '@polkadot/types-codec';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { Range, U32 } from '@polkadot/types-codec';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { Text, Type } from '@polkadot/types-codec';
|
||||
import { stringToU8a, u8aConcat } from '@polkadot/util';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { U8aFixed } from '@polkadot/types-codec';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { Bytes, Raw, u32, WrapperKeepOpaque } from '@polkadot/types-codec';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { WrapperOpaque } from '@polkadot/types-codec';
|
||||
import { u8aConcat } from '@polkadot/util';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { CodecTo } from '@polkadot/types-codec/types';
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { CodecTo } from '@polkadot/types-codec/types';
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { F32, F64 } from '@polkadot/types-codec';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { AnyU8a, CodecTo } from '@polkadot/types-codec/types';
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { CodecTo } from '@polkadot/types-codec/types';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { CodecTo } from '@polkadot/types-codec/types';
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-codec authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { alias, flattenSingleTuple, removeColons, removeExtensions } from '@polkadot/types-codec/utils/sanitize';
|
||||
|
||||
describe('sanitize', (): void => {
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
"version": "9.14.3-2-x",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@babel/runtime": "^7.21.0",
|
||||
"@polkadot/types-codec": "9.14.3-2-x",
|
||||
"@polkadot/util": "^10.4.2"
|
||||
},
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { encodeTypeDef, TypeDefInfo } from '@polkadot/types-create';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
import { getTypeDef, TypeDefInfo } from '@polkadot/types-create';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { typeSplit } from '@polkadot/types-create';
|
||||
|
||||
describe('typeSplit', (): void => {
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
"version": "9.14.3-2-x",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@babel/runtime": "^7.21.0",
|
||||
"@polkadot/networks": "^10.4.2",
|
||||
"@polkadot/types": "9.14.3-2-x",
|
||||
"@polkadot/types-codec": "9.14.3-2-x",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import type { HexString } from '@polkadot/util/types';
|
||||
import type { ChainUpgradesExpanded } from '../types';
|
||||
|
||||
import fs from 'fs';
|
||||
import fs from 'node:fs';
|
||||
|
||||
import { ApiPromise, WsProvider } from '@polkadot/api';
|
||||
|
||||
@@ -18,42 +18,46 @@ const urls = {
|
||||
westend: 'wss://westend-rpc.polkadot.io'
|
||||
};
|
||||
|
||||
describe.each(keys)('generate %s', (chain): void => {
|
||||
const avail = allGen[chain];
|
||||
const final: ChainUpgradesExpanded = [];
|
||||
let api: ApiPromise;
|
||||
for (const chain of keys) {
|
||||
describe(`generate ${chain}`, (): void => {
|
||||
const avail = allGen[chain];
|
||||
const final: ChainUpgradesExpanded = [];
|
||||
let api: ApiPromise;
|
||||
|
||||
beforeAll(async (): Promise<void> => {
|
||||
api = await ApiPromise.create({ provider: new WsProvider(urls[chain]) });
|
||||
});
|
||||
beforeAll(async (): Promise<void> => {
|
||||
api = await ApiPromise.create({ provider: new WsProvider(urls[chain]) });
|
||||
});
|
||||
|
||||
afterAll(async (): Promise<void> => {
|
||||
fs.writeFileSync(`packages/types-known/src/upgrades/e2e/${chain}.ts`, `// Copyright 2017-${new Date().getFullYear()} @polkadot/types-known authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
afterAll(async (): Promise<void> => {
|
||||
fs.writeFileSync(`packages/types-known/src/upgrades/e2e/${chain}.ts`, `// Copyright 2017-${new Date().getFullYear()} @polkadot/types-known authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Auto-generated from on-chain data & manual definitions, do not edit
|
||||
/* eslint-disable quotes, comma-spacing */
|
||||
// Auto-generated from on-chain data & manual definitions, do not edit
|
||||
/* eslint-disable quotes, comma-spacing */
|
||||
|
||||
import type { ChainUpgradesExpanded } from '../types';
|
||||
import type { ChainUpgradesExpanded } from '../types';
|
||||
|
||||
const upgrades: ChainUpgradesExpanded = ${JSON.stringify(final, null, 2)};
|
||||
const upgrades: ChainUpgradesExpanded = ${JSON.stringify(final, null, 2)};
|
||||
|
||||
export default upgrades;
|
||||
`);
|
||||
await api.disconnect();
|
||||
});
|
||||
export default upgrades;
|
||||
`);
|
||||
await api.disconnect();
|
||||
});
|
||||
|
||||
it.each(allMan[chain])('%s', async (blockNumber, specVersion): Promise<void> => {
|
||||
const found = avail.find(([n, s]) => n === blockNumber && s === specVersion);
|
||||
for (const [blockNumber, specVersion] of allMan[chain]) {
|
||||
it(`blockNumber=${blockNumber}, specVersion=${specVersion}`, async (): Promise<void> => {
|
||||
const found = avail.find(([n, s]) => n === blockNumber && s === specVersion);
|
||||
|
||||
if (found) {
|
||||
final.push(found);
|
||||
} else {
|
||||
const blockHash = await api.rpc.chain.getBlockHash(blockNumber + 1);
|
||||
const runtime = await api.rpc.state.getRuntimeVersion(blockHash);
|
||||
const apis = runtime.apis.map(([api, version]): [HexString, number] => [api.toHex(), version.toNumber()]);
|
||||
if (found) {
|
||||
final.push(found);
|
||||
} else {
|
||||
const blockHash = await api.rpc.chain.getBlockHash(blockNumber + 1);
|
||||
const runtime = await api.rpc.state.getRuntimeVersion(blockHash);
|
||||
const apis = runtime.apis.map(([api, version]): [HexString, number] => [api.toHex(), version.toNumber()]);
|
||||
|
||||
final.push([blockNumber, specVersion, apis]);
|
||||
final.push([blockNumber, specVersion, apis]);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types-known authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import type { ChainUpgradesExpanded, ChainUpgradesRaw } from './types';
|
||||
|
||||
import { stringify, u8aEq } from '@polkadot/util';
|
||||
@@ -61,28 +64,30 @@ describe('generated', (): void => {
|
||||
expect(Object.keys(allMan).sort()).toEqual(Object.keys(allGen).sort());
|
||||
});
|
||||
|
||||
describe.each(Object.keys(allMan))('%s', (chain): void => {
|
||||
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]) =>
|
||||
nb === na &&
|
||||
sb === sa
|
||||
)
|
||||
);
|
||||
for (const chain of Object.keys(allMan)) {
|
||||
describe(chain, (): void => {
|
||||
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]) =>
|
||||
nb === na &&
|
||||
sb === sa
|
||||
)
|
||||
);
|
||||
|
||||
if (missing.length !== 0) {
|
||||
throw new Error(`${chain}:: missing generated apis found, run yarn test:one packages/types-known/src/upgrades/e2e`);
|
||||
}
|
||||
});
|
||||
if (missing.length !== 0) {
|
||||
throw new Error(`${chain}:: missing generated apis found, run yarn test:one packages/types-known/src/upgrades/e2e`);
|
||||
}
|
||||
});
|
||||
|
||||
it('manual should be correctly ordered', (): void => {
|
||||
checkOrder(chain, (allGen as Record<string, ChainUpgradesExpanded>)[chain]);
|
||||
});
|
||||
it('manual should be correctly ordered', (): void => {
|
||||
checkOrder(chain, (allGen as Record<string, ChainUpgradesExpanded>)[chain]);
|
||||
});
|
||||
|
||||
it('generated should be correctly ordered', (): void => {
|
||||
checkOrder(chain, (allMan as Record<string, ChainUpgradesRaw>)[chain]);
|
||||
it('generated should be correctly ordered', (): void => {
|
||||
checkOrder(chain, (allMan as Record<string, ChainUpgradesRaw>)[chain]);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
describe('upgrades', (): void => {
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
"version": "9.14.3-2-x",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@babel/runtime": "^7.21.0",
|
||||
"@polkadot/util": "^10.4.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
"version": "9.14.3-2-x",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@babel/runtime": "^7.21.0",
|
||||
"@polkadot/keyring": "^10.4.2",
|
||||
"@polkadot/types-augment": "9.14.3-2-x",
|
||||
"@polkadot/types-codec": "9.14.3-2-x",
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeDefInfo } from '@polkadot/types-create';
|
||||
|
||||
import { createClass, getTypeClass, TypeRegistry } from '.';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { CodecSet, Int } from '@polkadot/types-codec';
|
||||
|
||||
import { createClass, TypeRegistry } from '.';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
|
||||
import type { Codec, CodecClass } from '@polkadot/types-codec/types';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
|
||||
import { Raw } from '@polkadot/types-codec';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '../create';
|
||||
import { GenericAccountIndex as AccountIndex } from '../generic';
|
||||
import { GenericEthereumAccountId as AccountId, GenericEthereumLookupSource as Address } from '.';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import rpcMetadata from '@polkadot/types-support/metadata/static-substrate';
|
||||
|
||||
import { TypeRegistry } from '../create';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { TypeRegistry } from '../create';
|
||||
import { GenericExtrinsicEra as ExtrinsicEra } from '.';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
/// <reference types="@polkadot/dev/node/test/node" />
|
||||
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { TypeRegistry } from '../create';
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user