mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-10-20 18:56:30 +00:00
Tests: build types by the app's names; fix rebrand-broken fixtures
- The static metadata in @pezkuwi/types-support predates the rename and only knows Pallet* names, while the app (and the test-support creation helpers) use PezpalletBountiesBountyStatus, PezpalletAllianceCid, ... createAugmentedApi now also registers the @pezkuwi/types-augment lookup definitions, and createLookupRegistry gives specs a plain registry that knows them. - calculateBountyBond: the description had been rewritten from "Kusama" (24 bytes) to "Dicle" (23 bytes) with the expected bond left for 24; now "Pezkuwi network UI Bounty" (25 bytes) and its value. - page-alliance had no tsconfig.spec.json, so its spec was never type-checked; added, and specs are excluded from its build config.
This commit is contained in:
1 parent
09fbca8121
commit
9302b4ff16
11 files changed
+61
-11
No files matched your search
@@ -15,6 +15,9 @@
|
|||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "1.0.2-1-x",
|
"version": "1.0.2-1-x",
|
||||||
|
"devDependencies": {
|
||||||
|
"@pezkuwi/test-support": "1.0.2-1-x"
|
||||||
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": "*",
|
"react": "*",
|
||||||
"react-dom": "*",
|
"react-dom": "*",
|
||||||
|
|||||||
@@ -3,15 +3,11 @@
|
|||||||
|
|
||||||
/// <reference types="@pezkuwi/dev-test/globals.d.ts" />
|
/// <reference types="@pezkuwi/dev-test/globals.d.ts" />
|
||||||
|
|
||||||
import { Metadata, TypeRegistry } from '@pezkuwi/types';
|
import { createLookupRegistry } from '@pezkuwi/test-support/api';
|
||||||
import bizinikiwi from '@pezkuwi/types-support/metadata/static-bizinikiwi';
|
|
||||||
|
|
||||||
import { createCid, createPalletCid } from './util.js';
|
import { createCid, createPalletCid } from './util.js';
|
||||||
|
|
||||||
const registry = new TypeRegistry();
|
const registry = createLookupRegistry();
|
||||||
const metadata = new Metadata(registry, bizinikiwi);
|
|
||||||
|
|
||||||
registry.setMetadata(metadata);
|
|
||||||
|
|
||||||
describe('util', (): void => {
|
describe('util', (): void => {
|
||||||
describe('createPalletCid', (): void => {
|
describe('createPalletCid', (): void => {
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
"outDir": "./build",
|
"outDir": "./build",
|
||||||
"rootDir": "./src"
|
"rootDir": "./src"
|
||||||
},
|
},
|
||||||
|
"exclude": [
|
||||||
|
"**/*.spec.ts",
|
||||||
|
"**/*.spec.tsx"
|
||||||
|
],
|
||||||
"references": [
|
"references": [
|
||||||
{ "path": "../page-tech-comm/tsconfig.build.json" },
|
{ "path": "../page-tech-comm/tsconfig.build.json" },
|
||||||
{ "path": "../react-components/tsconfig.build.json" }
|
{ "path": "../react-components/tsconfig.build.json" }
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"baseUrl": "..",
|
||||||
|
"outDir": "./build",
|
||||||
|
"rootDir": "./src",
|
||||||
|
"emitDeclarationOnly": false,
|
||||||
|
"noEmit": true
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"**/*.spec.ts",
|
||||||
|
"**/*.spec.tsx"
|
||||||
|
],
|
||||||
|
"references": [
|
||||||
|
{ "path": "../page-alliance/tsconfig.build.json" },
|
||||||
|
{ "path": "../test-support/tsconfig.build.json" }
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -14,7 +14,8 @@ describe('Calculate bounty bond', () => {
|
|||||||
const depositBase = registry.createType('BalanceOf', new BN(166666666666));
|
const depositBase = registry.createType('BalanceOf', new BN(166666666666));
|
||||||
const depositPerByte = registry.createType('BalanceOf', new BN(1666666666));
|
const depositPerByte = registry.createType('BalanceOf', new BN(1666666666));
|
||||||
|
|
||||||
expect(calculateBountyBond('Dicle network UI Bounty', depositBase, depositPerByte)).toEqual(new BN(206666666650));
|
// 25 bytes: 166666666666 + 25 * 1666666666
|
||||||
|
expect(calculateBountyBond('Pezkuwi network UI Bounty', depositBase, depositPerByte)).toEqual(new BN(208333333316));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles utf-8 chars', () => {
|
it('handles utf-8 chars', () => {
|
||||||
|
|||||||
@@ -3,15 +3,15 @@
|
|||||||
|
|
||||||
/// <reference types="@pezkuwi/dev-test/globals.d.ts" />
|
/// <reference types="@pezkuwi/dev-test/globals.d.ts" />
|
||||||
|
|
||||||
import { TypeRegistry } from '@pezkuwi/types/create';
|
import { createLookupRegistry } from '@pezkuwi/test-support/api';
|
||||||
|
|
||||||
import { getBountyStatus } from './getBountyStatus.js';
|
import { getBountyStatus } from './getBountyStatus.js';
|
||||||
|
|
||||||
describe('get bounty status', () => {
|
describe('get bounty status', () => {
|
||||||
let registry: TypeRegistry;
|
let registry: ReturnType<typeof createLookupRegistry>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
registry = new TypeRegistry();
|
registry = createLookupRegistry();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('for CuratorProposed state it has curator defined', () => {
|
it('for CuratorProposed state it has curator defined', () => {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
"@testing-library/react": "^14.1.2"
|
"@testing-library/react": "^14.1.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@pezkuwi/types-augment": "^16.5.37",
|
||||||
"@pezkuwi/types-support": "16.5.37",
|
"@pezkuwi/types-support": "16.5.37",
|
||||||
"@testing-library/jest-dom": "^5.17.0",
|
"@testing-library/jest-dom": "^5.17.0",
|
||||||
"tsconfig-paths": "^4.2.0"
|
"tsconfig-paths": "^4.2.0"
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
// Copyright 2017-2026 @pezkuwi/test-support authors & contributors
|
// Copyright 2017-2026 @pezkuwi/test-support authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
import type { Registry } from '@pezkuwi/types/types';
|
import type { Registry, RegistryTypes } from '@pezkuwi/types/types';
|
||||||
|
|
||||||
import { ApiPromise, WsProvider } from '@pezkuwi/api';
|
import { ApiPromise, WsProvider } from '@pezkuwi/api';
|
||||||
import { Metadata, TypeRegistry } from '@pezkuwi/types';
|
import { Metadata, TypeRegistry } from '@pezkuwi/types';
|
||||||
|
import lookupDefinitions from '@pezkuwi/types-augment/lookup/definitions';
|
||||||
import metaStatic from '@pezkuwi/types-support/metadata/static-bizinikiwi';
|
import metaStatic from '@pezkuwi/types-support/metadata/static-bizinikiwi';
|
||||||
|
|
||||||
// PezkuwiChain requires AuthorizeCall signed extension for all transactions
|
// PezkuwiChain requires AuthorizeCall signed extension for all transactions
|
||||||
@@ -23,6 +24,10 @@ export function createAugmentedApi (): ApiPromise {
|
|||||||
const metadata = new Metadata(registry as unknown as Registry, metaStatic);
|
const metadata = new Metadata(registry as unknown as Registry, metaStatic);
|
||||||
|
|
||||||
registry.setMetadata(metadata);
|
registry.setMetadata(metadata);
|
||||||
|
// The static metadata predates the rename and only has Pallet* names; the
|
||||||
|
// app (and the creation helpers) use the Pezpallet* lookup names.
|
||||||
|
// RegistryTypes does not model a struct's `_alias`, which the registry accepts
|
||||||
|
registry.register(lookupDefinitions.types as RegistryTypes);
|
||||||
|
|
||||||
const api = new ApiPromise({
|
const api = new ApiPromise({
|
||||||
provider: new WsProvider('ws://', false),
|
provider: new WsProvider('ws://', false),
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// Copyright 2017-2026 @pezkuwi/test-support authors & contributors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import type { RegistryTypes } from '@pezkuwi/types/types';
|
||||||
|
|
||||||
|
import { TypeRegistry } from '@pezkuwi/types/create';
|
||||||
|
import lookupDefinitions from '@pezkuwi/types-augment/lookup/definitions';
|
||||||
|
|
||||||
|
// A registry that knows the runtime types by the names the app uses
|
||||||
|
// (PezpalletBountiesBountyStatus, PezpalletAllianceCid, ...). The static
|
||||||
|
// metadata in @pezkuwi/types-support predates the rename and only has the
|
||||||
|
// Pallet* names.
|
||||||
|
export function createLookupRegistry (): TypeRegistry {
|
||||||
|
const registry = new TypeRegistry();
|
||||||
|
|
||||||
|
// RegistryTypes does not model a struct's `_alias`, which the registry accepts
|
||||||
|
registry.register(lookupDefinitions.types as RegistryTypes);
|
||||||
|
|
||||||
|
return registry;
|
||||||
|
}
|
||||||
@@ -5,3 +5,4 @@ import '@pezkuwi/api-augment/bizinikiwi';
|
|||||||
|
|
||||||
export * from './createApi.js';
|
export * from './createApi.js';
|
||||||
export * from './createAugmentedApi.js';
|
export * from './createAugmentedApi.js';
|
||||||
|
export * from './createLookupRegistry.js';
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
{ "path": "./packages/page-addresses/tsconfig.spec.json" },
|
{ "path": "./packages/page-addresses/tsconfig.spec.json" },
|
||||||
{ "path": "./packages/page-addresses/tsconfig.test.json" },
|
{ "path": "./packages/page-addresses/tsconfig.test.json" },
|
||||||
{ "path": "./packages/page-alliance/tsconfig.build.json" },
|
{ "path": "./packages/page-alliance/tsconfig.build.json" },
|
||||||
|
{ "path": "./packages/page-alliance/tsconfig.spec.json" },
|
||||||
{ "path": "./packages/page-ambassador/tsconfig.build.json" },
|
{ "path": "./packages/page-ambassador/tsconfig.build.json" },
|
||||||
{ "path": "./packages/page-assets/tsconfig.build.json" },
|
{ "path": "./packages/page-assets/tsconfig.build.json" },
|
||||||
{ "path": "./packages/page-bounties/tsconfig.build.json" },
|
{ "path": "./packages/page-bounties/tsconfig.build.json" },
|
||||||
|
|||||||
Reference in new issue
Block a user