difftreelog
feat tests requirePallets
in: master
21 files changed
tests/src/rmrk/acceptNft.test.tsdiffbeforeafterboth8} 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';121213describe('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 tests/src/rmrk/addResource.test.tsdiffbeforeafterboth12 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';161617describe('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 });323233 it('add resource', async () => {33 it('add resource', async () => {tests/src/rmrk/addTheme.test.tsdiffbeforeafterboth3import {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';778describe('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 });141415 const alice = '//Alice';15 const alice = '//Alice';tests/src/rmrk/burnNft.test.tsdiffbeforeafterboth556import 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';9910chai.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 });22222323tests/src/rmrk/changeCollectionIssuer.test.tsdiffbeforeafterboth1import {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 });18181919tests/src/rmrk/createBase.test.tsdiffbeforeafterboth1import {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';445describe('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 });111112 const alice = '//Alice';12 const alice = '//Alice';tests/src/rmrk/createCollection.test.tsdiffbeforeafterboth1import {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';445describe('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 });11111212tests/src/rmrk/deleteCollection.test.tsdiffbeforeafterboth1import {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';556describe('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 });121213 const Alice = '//Alice';13 const Alice = '//Alice';tests/src/rmrk/equipNft.test.tsdiffbeforeafterboth1import {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 });131131132 it('equip nft', async () => {132 it('equip nft', async () => {tests/src/rmrk/getOwnedNfts.test.tsdiffbeforeafterboth1import {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';669 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 });14141515tests/src/rmrk/lockCollection.test.tsdiffbeforeafterboth1import {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';5511 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 });161617 it('lock collection', async () => {17 it('lock collection', async () => {tests/src/rmrk/mintNft.test.tsdiffbeforeafterboth1import {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 });15151616tests/src/rmrk/rejectNft.test.tsdiffbeforeafterboth8} 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';121213describe('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 });19192020tests/src/rmrk/removeResource.test.tsdiffbeforeafterboth1import {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 });252526 const Alice = '//Alice';26 const Alice = '//Alice';tests/src/rmrk/rmrkIsolation.test.tsdiffbeforeafterboth6 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 });7070tests/src/rmrk/sendNft.test.tsdiffbeforeafterboth3import {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';778describe('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 });141415 const maxNftId = 0xFFFFFFFF;15 const maxNftId = 0xFFFFFFFF;tests/src/rmrk/setCollectionProperty.test.tsdiffbeforeafterboth1import {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';5510 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 });151516 it('set collection property', async () => {16 it('set collection property', async () => {tests/src/rmrk/setEquippableList.test.tsdiffbeforeafterboth1import {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';556describe("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 });121213 const alice = '//Alice';13 const alice = '//Alice';tests/src/rmrk/setNftProperty.test.tsdiffbeforeafterboth1import {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 });131314 const alice = '//Alice';14 const alice = '//Alice';tests/src/rmrk/setResourcePriorities.test.tsdiffbeforeafterboth1import {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';556describe('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 });121213 const alice = '//Alice';13 const alice = '//Alice';tests/src/util/helpers.tsdiffbeforeafterboth28import {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';313232chai.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}7475export function requirePallets(mocha: Context, api: ApiPromise, requiredPallets: string[]) {76 const pallets = getModuleNames(api);7778 const isAllPalletsPresent = requiredPallets.every(p => pallets.includes(p));7980 if (!isAllPalletsPresent) {81 mocha.skip();82 }83}728473export 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') {