git.delta.rocks / unique-network / refs/commits / b544464f4ffd

difftreelog

feat tests requirePallets

Daniel Shiposha2022-08-03parent: #fe18d26.patch.diff
in: master

21 files changed

modifiedtests/src/rmrk/acceptNft.test.tsdiffbeforeafterboth
8} from './util/tx';8} from './util/tx';
9import {NftIdTuple} from './util/fetch';9import {NftIdTuple} from './util/fetch';
10import {isNftChildOfAnother, expectTxFailure} from './util/helpers';10import {isNftChildOfAnother, expectTxFailure} from './util/helpers';
11import { getModuleNames, Pallets } from '../util/helpers';11import { requirePallets, Pallets } from '../util/helpers';
1212
13describe('integration test: accept NFT', () => {13describe('integration test: accept NFT', () => {
14 let api: any;14 let api: any;
15 before(async function() {15 before(async function() {
16 api = await getApiConnection();16 api = await getApiConnection();
17 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();17 requirePallets(this, api, [Pallets.RmrkCore]);
18 });18 });
19 19
20 20
modifiedtests/src/rmrk/addResource.test.tsdiffbeforeafterboth
12 addNftComposableResource,12 addNftComposableResource,
13} from './util/tx';13} from './util/tx';
14import {RmrkTraitsResourceResourceInfo as ResourceInfo} from '@polkadot/types/lookup';14import {RmrkTraitsResourceResourceInfo as ResourceInfo} from '@polkadot/types/lookup';
15import { getModuleNames, Pallets } from '../util/helpers';15import { requirePallets, Pallets } from '../util/helpers';
1616
17describe('integration test: add NFT resource', () => {17describe('integration test: add NFT resource', () => {
18 const Alice = '//Alice';18 const Alice = '//Alice';
27 let api: any;27 let api: any;
28 before(async function() {28 before(async function() {
29 api = await getApiConnection();29 api = await getApiConnection();
30 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();30 requirePallets(this, api, [Pallets.RmrkCore]);
31 });31 });
3232
33 it('add resource', async () => {33 it('add resource', async () => {
modifiedtests/src/rmrk/addTheme.test.tsdiffbeforeafterboth
3import {createBase, addTheme} from './util/tx';3import {createBase, addTheme} from './util/tx';
4import {expectTxFailure} from './util/helpers';4import {expectTxFailure} from './util/helpers';
5import {getThemeNames} from './util/fetch';5import {getThemeNames} from './util/fetch';
6import { getModuleNames, Pallets } from '../util/helpers';6import { requirePallets, Pallets } from '../util/helpers';
77
8describe('integration test: add Theme to Base', () => {8describe('integration test: add Theme to Base', () => {
9 let api: any;9 let api: any;
10 before(async function() {10 before(async function() {
11 api = await getApiConnection();11 api = await getApiConnection();
12 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();12 requirePallets(this, api, [Pallets.RmrkEquip]);
13 });13 });
1414
15 const alice = '//Alice';15 const alice = '//Alice';
modifiedtests/src/rmrk/burnNft.test.tsdiffbeforeafterboth
55
6import chai from 'chai';6import chai from 'chai';
7import chaiAsPromised from 'chai-as-promised';7import chaiAsPromised from 'chai-as-promised';
8import { getModuleNames, Pallets } from '../util/helpers';8import { requirePallets, Pallets } from '../util/helpers';
99
10chai.use(chaiAsPromised);10chai.use(chaiAsPromised);
11const expect = chai.expect;11const expect = chai.expect;
17 let api: any;17 let api: any;
18 before(async function() {18 before(async function() {
19 api = await getApiConnection();19 api = await getApiConnection();
20 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();20 requirePallets(this, api, [Pallets.RmrkCore]);
21 });21 });
2222
2323
modifiedtests/src/rmrk/changeCollectionIssuer.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import { getModuleNames, Pallets } from '../util/helpers';2import { requirePallets, Pallets } from '../util/helpers';
3import {expectTxFailure} from './util/helpers';3import {expectTxFailure} from './util/helpers';
4import {4import {
5 changeIssuer,5 changeIssuer,
13 let api: any;13 let api: any;
14 before(async function() {14 before(async function() {
15 api = await getApiConnection();15 api = await getApiConnection();
16 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();16 requirePallets(this, api, [Pallets.RmrkCore]);
17 });17 });
1818
1919
modifiedtests/src/rmrk/createBase.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import { getModuleNames, Pallets } from '../util/helpers';2import { requirePallets, Pallets } from '../util/helpers';
3import {createCollection, createBase} from './util/tx';3import {createCollection, createBase} from './util/tx';
44
5describe('integration test: create new Base', () => {5describe('integration test: create new Base', () => {
6 let api: any;6 let api: any;
7 before(async function() {7 before(async function() {
8 api = await getApiConnection();8 api = await getApiConnection();
9 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();9 requirePallets(this, api, [Pallets.RmrkCore, Pallets.RmrkEquip]);
10 });10 });
1111
12 const alice = '//Alice';12 const alice = '//Alice';
modifiedtests/src/rmrk/createCollection.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import {getModuleNames, Pallets} from '../util/helpers';2import {requirePallets, Pallets} from '../util/helpers';
3import {createCollection} from './util/tx';3import {createCollection} from './util/tx';
44
5describe('Integration test: create new collection', () => {5describe('Integration test: create new collection', () => {
6 let api: any;6 let api: any;
7 before(async function () {7 before(async function () {
8 api = await getApiConnection();8 api = await getApiConnection();
9 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();9 requirePallets(this, api, [Pallets.RmrkCore]);
10 });10 });
1111
1212
modifiedtests/src/rmrk/deleteCollection.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import { getModuleNames, Pallets } from '../util/helpers';2import { requirePallets, Pallets } from '../util/helpers';
3import {expectTxFailure} from './util/helpers';3import {expectTxFailure} from './util/helpers';
4import {createCollection, deleteCollection} from './util/tx';4import {createCollection, deleteCollection} from './util/tx';
55
6describe('integration test: delete collection', () => {6describe('integration test: delete collection', () => {
7 let api: any;7 let api: any;
8 before(async function () {8 before(async function () {
9 api = await getApiConnection();9 api = await getApiConnection();
10 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();10 requirePallets(this, api, [Pallets.RmrkCore]);
11 });11 });
1212
13 const Alice = '//Alice';13 const Alice = '//Alice';
modifiedtests/src/rmrk/equipNft.test.tsdiffbeforeafterboth
1import {ApiPromise} from '@polkadot/api';1import {ApiPromise} from '@polkadot/api';
2import {expect} from 'chai';2import {expect} from 'chai';
3import {getApiConnection} from '../substrate/substrate-api';3import {getApiConnection} from '../substrate/substrate-api';
4import {getModuleNames, Pallets} from '../util/helpers';4import {requirePallets, Pallets} from '../util/helpers';
5import {getNft, getParts, NftIdTuple} from './util/fetch';5import {getNft, getParts, NftIdTuple} from './util/fetch';
6import {expectTxFailure} from './util/helpers';6import {expectTxFailure} from './util/helpers';
7import {7import {
126 126
127 before(async function () {127 before(async function () {
128 api = await getApiConnection();128 api = await getApiConnection();
129 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();129 requirePallets(this, api, [Pallets.RmrkCore, Pallets.RmrkEquip]);
130 });130 });
131131
132 it('equip nft', async () => {132 it('equip nft', async () => {
modifiedtests/src/rmrk/getOwnedNfts.test.tsdiffbeforeafterboth
1import {expect} from 'chai';1import {expect} from 'chai';
2import {getApiConnection} from '../substrate/substrate-api';2import {getApiConnection} from '../substrate/substrate-api';
3import { getModuleNames, Pallets } from '../util/helpers';3import { requirePallets, Pallets } from '../util/helpers';
4import {getOwnedNfts} from './util/fetch';4import {getOwnedNfts} from './util/fetch';
5import {mintNft, createCollection} from './util/tx';5import {mintNft, createCollection} from './util/tx';
66
9 9
10 before(async function () {10 before(async function () {
11 api = await getApiConnection();11 api = await getApiConnection();
12 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();12 requirePallets(this, api, [Pallets.RmrkCore]);
13 });13 });
1414
1515
modifiedtests/src/rmrk/lockCollection.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import { getModuleNames, Pallets } from '../util/helpers';2import { requirePallets, Pallets } from '../util/helpers';
3import {expectTxFailure} from './util/helpers';3import {expectTxFailure} from './util/helpers';
4import {createCollection, lockCollection, mintNft} from './util/tx';4import {createCollection, lockCollection, mintNft} from './util/tx';
55
11 let api: any;11 let api: any;
12 before(async function () {12 before(async function () {
13 api = await getApiConnection();13 api = await getApiConnection();
14 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();14 requirePallets(this, api, [Pallets.RmrkCore]);
15 });15 });
1616
17 it('lock collection', async () => {17 it('lock collection', async () => {
modifiedtests/src/rmrk/mintNft.test.tsdiffbeforeafterboth
1import {expect} from 'chai';1import {expect} from 'chai';
2import {getApiConnection} from '../substrate/substrate-api';2import {getApiConnection} from '../substrate/substrate-api';
3import { getModuleNames, Pallets } from '../util/helpers';3import { requirePallets, Pallets } from '../util/helpers';
4import {getNft} from './util/fetch';4import {getNft} from './util/fetch';
5import {expectTxFailure} from './util/helpers';5import {expectTxFailure} from './util/helpers';
6import {createCollection, mintNft} from './util/tx';6import {createCollection, mintNft} from './util/tx';
10 10
11 before(async function () {11 before(async function () {
12 api = await getApiConnection();12 api = await getApiConnection();
13 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();13 requirePallets(this, api, [Pallets.RmrkCore]);
14 });14 });
1515
1616
modifiedtests/src/rmrk/rejectNft.test.tsdiffbeforeafterboth
8} from './util/tx';8} from './util/tx';
9import {getChildren, NftIdTuple} from './util/fetch';9import {getChildren, NftIdTuple} from './util/fetch';
10import {isNftChildOfAnother, expectTxFailure} from './util/helpers';10import {isNftChildOfAnother, expectTxFailure} from './util/helpers';
11import { getModuleNames, Pallets } from '../util/helpers';11import { requirePallets, Pallets } from '../util/helpers';
1212
13describe('integration test: reject NFT', () => {13describe('integration test: reject NFT', () => {
14 let api: any;14 let api: any;
15 before(async function () {15 before(async function () {
16 api = await getApiConnection();16 api = await getApiConnection();
17 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();17 requirePallets(this, api, [Pallets.RmrkCore]);
18 });18 });
1919
2020
modifiedtests/src/rmrk/removeResource.test.tsdiffbeforeafterboth
1import {expect} from 'chai';1import {expect} from 'chai';
2import privateKey from '../substrate/privateKey';2import privateKey from '../substrate/privateKey';
3import {executeTransaction, getApiConnection} from '../substrate/substrate-api';3import {executeTransaction, getApiConnection} from '../substrate/substrate-api';
4import { getModuleNames, Pallets } from '../util/helpers';4import { requirePallets, Pallets } from '../util/helpers';
5import {getNft, NftIdTuple} from './util/fetch';5import {getNft, NftIdTuple} from './util/fetch';
6import {expectTxFailure} from './util/helpers';6import {expectTxFailure} from './util/helpers';
7import {7import {
20 before(async function() {20 before(async function() {
21 api = await getApiConnection();21 api = await getApiConnection();
22 ss58Format = api.registry.getChainProperties()!.toJSON().ss58Format;22 ss58Format = api.registry.getChainProperties()!.toJSON().ss58Format;
23 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();23 requirePallets(this, api, [Pallets.RmrkCore]);
24 });24 });
2525
26 const Alice = '//Alice';26 const Alice = '//Alice';
modifiedtests/src/rmrk/rmrkIsolation.test.tsdiffbeforeafterboth
6 getCreateCollectionResult,6 getCreateCollectionResult,
7 getDetailedCollectionInfo,7 getDetailedCollectionInfo,
8 getGenericResult,8 getGenericResult,
9 getModuleNames,9 requirePallets,
10 normalizeAccountId,10 normalizeAccountId,
11 Pallets,11 Pallets,
12} from '../util/helpers';12} from '../util/helpers';
64 before(async function() {64 before(async function() {
65 await usingApi(async (api, privateKeyWrapper) => {65 await usingApi(async (api, privateKeyWrapper) => {
66 alice = privateKeyWrapper('//Alice');66 alice = privateKeyWrapper('//Alice');
67 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();67 requirePallets(this, api, [Pallets.RmrkCore]);
68 });68 });
69 });69 });
7070
modifiedtests/src/rmrk/sendNft.test.tsdiffbeforeafterboth
3import {createCollection, mintNft, sendNft} from './util/tx';3import {createCollection, mintNft, sendNft} from './util/tx';
4import {NftIdTuple} from './util/fetch';4import {NftIdTuple} from './util/fetch';
5import {isNftChildOfAnother, expectTxFailure} from './util/helpers';5import {isNftChildOfAnother, expectTxFailure} from './util/helpers';
6import { getModuleNames, Pallets } from '../util/helpers';6import { requirePallets, Pallets } from '../util/helpers';
77
8describe('integration test: send NFT', () => {8describe('integration test: send NFT', () => {
9 let api: any;9 let api: any;
10 before(async function () {10 before(async function () {
11 api = await getApiConnection();11 api = await getApiConnection();
12 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();12 requirePallets(this, api, [Pallets.RmrkCore]);
13 });13 });
1414
15 const maxNftId = 0xFFFFFFFF;15 const maxNftId = 0xFFFFFFFF;
modifiedtests/src/rmrk/setCollectionProperty.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import { getModuleNames, Pallets } from '../util/helpers';2import { requirePallets, Pallets } from '../util/helpers';
3import {expectTxFailure} from './util/helpers';3import {expectTxFailure} from './util/helpers';
4import {createCollection, setPropertyCollection} from './util/tx';4import {createCollection, setPropertyCollection} from './util/tx';
55
10 let api: any;10 let api: any;
11 before(async function () {11 before(async function () {
12 api = await getApiConnection();12 api = await getApiConnection();
13 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();13 requirePallets(this, api, [Pallets.RmrkCore]);
14 });14 });
1515
16 it('set collection property', async () => {16 it('set collection property', async () => {
modifiedtests/src/rmrk/setEquippableList.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import { getModuleNames, Pallets } from '../util/helpers';2import { requirePallets, Pallets } from '../util/helpers';
3import {expectTxFailure} from './util/helpers';3import {expectTxFailure} from './util/helpers';
4import {createCollection, createBase, setEquippableList} from './util/tx';4import {createCollection, createBase, setEquippableList} from './util/tx';
55
6describe("integration test: set slot's Equippable List", () => {6describe("integration test: set slot's Equippable List", () => {
7 let api: any;7 let api: any;
8 before(async function () {8 before(async function () {
9 api = await getApiConnection();9 api = await getApiConnection();
10 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();10 requirePallets(this, api, [Pallets.RmrkCore]);
11 });11 });
1212
13 const alice = '//Alice';13 const alice = '//Alice';
modifiedtests/src/rmrk/setNftProperty.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import { getModuleNames, Pallets } from '../util/helpers';2import { requirePallets, Pallets } from '../util/helpers';
3import {NftIdTuple} from './util/fetch';3import {NftIdTuple} from './util/fetch';
4import {expectTxFailure} from './util/helpers';4import {expectTxFailure} from './util/helpers';
5import {createCollection, mintNft, sendNft, setNftProperty} from './util/tx';5import {createCollection, mintNft, sendNft, setNftProperty} from './util/tx';
8 let api: any;8 let api: any;
9 before(async function () {9 before(async function () {
10 api = await getApiConnection();10 api = await getApiConnection();
11 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();11 requirePallets(this, api, [Pallets.RmrkCore]);
12 });12 });
1313
14 const alice = '//Alice';14 const alice = '//Alice';
modifiedtests/src/rmrk/setResourcePriorities.test.tsdiffbeforeafterboth
1import {getApiConnection} from '../substrate/substrate-api';1import {getApiConnection} from '../substrate/substrate-api';
2import { getModuleNames, Pallets } from '../util/helpers';2import { requirePallets, Pallets } from '../util/helpers';
3import {expectTxFailure} from './util/helpers';3import {expectTxFailure} from './util/helpers';
4import {mintNft, createCollection, setResourcePriorities} from './util/tx';4import {mintNft, createCollection, setResourcePriorities} from './util/tx';
55
6describe('integration test: set NFT resource priorities', () => {6describe('integration test: set NFT resource priorities', () => {
7 let api: any;7 let api: any;
8 before(async function () {8 before(async function () {
9 api = await getApiConnection();9 api = await getApiConnection();
10 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();10 requirePallets(this, api, [Pallets.RmrkCore]);
11 });11 });
1212
13 const alice = '//Alice';13 const alice = '//Alice';
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
28import {hexToStr, strToUTF16, utf16ToStr} from './util';28import {hexToStr, strToUTF16, utf16ToStr} from './util';
29import {UpDataStructsRpcCollection, UpDataStructsCreateItemData, UpDataStructsProperty} from '@polkadot/types/lookup';29import {UpDataStructsRpcCollection, UpDataStructsCreateItemData, UpDataStructsProperty} from '@polkadot/types/lookup';
30import {UpDataStructsTokenChild} from '../interfaces';30import {UpDataStructsTokenChild} from '../interfaces';
31import { Context } from 'mocha';
3132
32chai.use(chaiAsPromised);33chai.use(chaiAsPromised);
33const expect = chai.expect;34const expect = chai.expect;
42export enum Pallets {43export enum Pallets {
43 Inflation = 'inflation',44 Inflation = 'inflation',
44 RmrkCore = 'rmrkcore',45 RmrkCore = 'rmrkcore',
46 RmrkEquip = 'rmrkequip',
45 ReFungible = 'refungible',47 ReFungible = 'refungible',
46 Fungible = 'fungible',48 Fungible = 'fungible',
47 NFT = 'nonfungible',49 NFT = 'nonfungible',
70 return modulesNames;72 return modulesNames;
71}73}
74
75export function requirePallets(mocha: Context, api: ApiPromise, requiredPallets: string[]) {
76 const pallets = getModuleNames(api);
77
78 const isAllPalletsPresent = requiredPallets.every(p => pallets.includes(p));
79
80 if (!isAllPalletsPresent) {
81 mocha.skip();
82 }
83}
7284
73export function normalizeAccountId(input: string | AccountId | CrossAccountId | IKeyringPair): CrossAccountId {85export function normalizeAccountId(input: string | AccountId | CrossAccountId | IKeyringPair): CrossAccountId {
74 if (typeof input === 'string') {86 if (typeof input === 'string') {