difftreelog
feat tests requirePallets
in: master
21 files changed
tests/src/rmrk/acceptNft.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/acceptNft.test.ts
+++ b/tests/src/rmrk/acceptNft.test.ts
@@ -8,13 +8,13 @@
} from './util/tx';
import {NftIdTuple} from './util/fetch';
import {isNftChildOfAnother, expectTxFailure} from './util/helpers';
-import { getModuleNames, Pallets } from '../util/helpers';
+import { requirePallets, Pallets } from '../util/helpers';
describe('integration test: accept NFT', () => {
let api: any;
before(async function() {
api = await getApiConnection();
- if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ requirePallets(this, api, [Pallets.RmrkCore]);
});
tests/src/rmrk/addResource.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/addResource.test.ts
+++ b/tests/src/rmrk/addResource.test.ts
@@ -12,7 +12,7 @@
addNftComposableResource,
} from './util/tx';
import {RmrkTraitsResourceResourceInfo as ResourceInfo} from '@polkadot/types/lookup';
-import { getModuleNames, Pallets } from '../util/helpers';
+import { requirePallets, Pallets } from '../util/helpers';
describe('integration test: add NFT resource', () => {
const Alice = '//Alice';
@@ -27,7 +27,7 @@
let api: any;
before(async function() {
api = await getApiConnection();
- if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ requirePallets(this, api, [Pallets.RmrkCore]);
});
it('add resource', async () => {
tests/src/rmrk/addTheme.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/addTheme.test.ts
+++ b/tests/src/rmrk/addTheme.test.ts
@@ -3,13 +3,13 @@
import {createBase, addTheme} from './util/tx';
import {expectTxFailure} from './util/helpers';
import {getThemeNames} from './util/fetch';
-import { getModuleNames, Pallets } from '../util/helpers';
+import { requirePallets, Pallets } from '../util/helpers';
describe('integration test: add Theme to Base', () => {
let api: any;
before(async function() {
api = await getApiConnection();
- if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ requirePallets(this, api, [Pallets.RmrkEquip]);
});
const alice = '//Alice';
tests/src/rmrk/burnNft.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/burnNft.test.ts
+++ b/tests/src/rmrk/burnNft.test.ts
@@ -5,7 +5,7 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import { getModuleNames, Pallets } from '../util/helpers';
+import { requirePallets, Pallets } from '../util/helpers';
chai.use(chaiAsPromised);
const expect = chai.expect;
@@ -17,7 +17,7 @@
let api: any;
before(async function() {
api = await getApiConnection();
- if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ requirePallets(this, api, [Pallets.RmrkCore]);
});
tests/src/rmrk/changeCollectionIssuer.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/changeCollectionIssuer.test.ts
+++ b/tests/src/rmrk/changeCollectionIssuer.test.ts
@@ -1,5 +1,5 @@
import {getApiConnection} from '../substrate/substrate-api';
-import { getModuleNames, Pallets } from '../util/helpers';
+import { requirePallets, Pallets } from '../util/helpers';
import {expectTxFailure} from './util/helpers';
import {
changeIssuer,
@@ -13,7 +13,7 @@
let api: any;
before(async function() {
api = await getApiConnection();
- if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ requirePallets(this, api, [Pallets.RmrkCore]);
});
tests/src/rmrk/createBase.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/createBase.test.ts
+++ b/tests/src/rmrk/createBase.test.ts
@@ -1,12 +1,12 @@
import {getApiConnection} from '../substrate/substrate-api';
-import { getModuleNames, Pallets } from '../util/helpers';
+import { requirePallets, Pallets } from '../util/helpers';
import {createCollection, createBase} from './util/tx';
describe('integration test: create new Base', () => {
let api: any;
before(async function() {
api = await getApiConnection();
- if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ requirePallets(this, api, [Pallets.RmrkCore, Pallets.RmrkEquip]);
});
const alice = '//Alice';
tests/src/rmrk/createCollection.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/createCollection.test.ts
+++ b/tests/src/rmrk/createCollection.test.ts
@@ -1,12 +1,12 @@
import {getApiConnection} from '../substrate/substrate-api';
-import {getModuleNames, Pallets} from '../util/helpers';
+import {requirePallets, Pallets} from '../util/helpers';
import {createCollection} from './util/tx';
describe('Integration test: create new collection', () => {
let api: any;
before(async function () {
api = await getApiConnection();
- if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ requirePallets(this, api, [Pallets.RmrkCore]);
});
tests/src/rmrk/deleteCollection.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/deleteCollection.test.ts
+++ b/tests/src/rmrk/deleteCollection.test.ts
@@ -1,5 +1,5 @@
import {getApiConnection} from '../substrate/substrate-api';
-import { getModuleNames, Pallets } from '../util/helpers';
+import { requirePallets, Pallets } from '../util/helpers';
import {expectTxFailure} from './util/helpers';
import {createCollection, deleteCollection} from './util/tx';
@@ -7,7 +7,7 @@
let api: any;
before(async function () {
api = await getApiConnection();
- if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ requirePallets(this, api, [Pallets.RmrkCore]);
});
const Alice = '//Alice';
tests/src/rmrk/equipNft.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/equipNft.test.ts
+++ b/tests/src/rmrk/equipNft.test.ts
@@ -1,7 +1,7 @@
import {ApiPromise} from '@polkadot/api';
import {expect} from 'chai';
import {getApiConnection} from '../substrate/substrate-api';
-import {getModuleNames, Pallets} from '../util/helpers';
+import {requirePallets, Pallets} from '../util/helpers';
import {getNft, getParts, NftIdTuple} from './util/fetch';
import {expectTxFailure} from './util/helpers';
import {
@@ -126,7 +126,7 @@
before(async function () {
api = await getApiConnection();
- if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ requirePallets(this, api, [Pallets.RmrkCore, Pallets.RmrkEquip]);
});
it('equip nft', async () => {
tests/src/rmrk/getOwnedNfts.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/getOwnedNfts.test.ts
+++ b/tests/src/rmrk/getOwnedNfts.test.ts
@@ -1,6 +1,6 @@
import {expect} from 'chai';
import {getApiConnection} from '../substrate/substrate-api';
-import { getModuleNames, Pallets } from '../util/helpers';
+import { requirePallets, Pallets } from '../util/helpers';
import {getOwnedNfts} from './util/fetch';
import {mintNft, createCollection} from './util/tx';
@@ -9,7 +9,7 @@
before(async function () {
api = await getApiConnection();
- if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ requirePallets(this, api, [Pallets.RmrkCore]);
});
tests/src/rmrk/lockCollection.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/lockCollection.test.ts
+++ b/tests/src/rmrk/lockCollection.test.ts
@@ -1,5 +1,5 @@
import {getApiConnection} from '../substrate/substrate-api';
-import { getModuleNames, Pallets } from '../util/helpers';
+import { requirePallets, Pallets } from '../util/helpers';
import {expectTxFailure} from './util/helpers';
import {createCollection, lockCollection, mintNft} from './util/tx';
@@ -11,7 +11,7 @@
let api: any;
before(async function () {
api = await getApiConnection();
- if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ requirePallets(this, api, [Pallets.RmrkCore]);
});
it('lock collection', async () => {
tests/src/rmrk/mintNft.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/mintNft.test.ts
+++ b/tests/src/rmrk/mintNft.test.ts
@@ -1,6 +1,6 @@
import {expect} from 'chai';
import {getApiConnection} from '../substrate/substrate-api';
-import { getModuleNames, Pallets } from '../util/helpers';
+import { requirePallets, Pallets } from '../util/helpers';
import {getNft} from './util/fetch';
import {expectTxFailure} from './util/helpers';
import {createCollection, mintNft} from './util/tx';
@@ -10,7 +10,7 @@
before(async function () {
api = await getApiConnection();
- if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ requirePallets(this, api, [Pallets.RmrkCore]);
});
tests/src/rmrk/rejectNft.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/rejectNft.test.ts
+++ b/tests/src/rmrk/rejectNft.test.ts
@@ -8,13 +8,13 @@
} from './util/tx';
import {getChildren, NftIdTuple} from './util/fetch';
import {isNftChildOfAnother, expectTxFailure} from './util/helpers';
-import { getModuleNames, Pallets } from '../util/helpers';
+import { requirePallets, Pallets } from '../util/helpers';
describe('integration test: reject NFT', () => {
let api: any;
before(async function () {
api = await getApiConnection();
- if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ requirePallets(this, api, [Pallets.RmrkCore]);
});
tests/src/rmrk/removeResource.test.tsdiffbeforeafterboth1import {expect} from 'chai';2import privateKey from '../substrate/privateKey';3import {executeTransaction, getApiConnection} from '../substrate/substrate-api';4import { getModuleNames, Pallets } from '../util/helpers';5import {getNft, NftIdTuple} from './util/fetch';6import {expectTxFailure} from './util/helpers';7import {8 acceptNft, acceptResourceRemoval, addNftBasicResource,9 createBase,10 createCollection,11 mintNft, removeNftResource, sendNft,12} from './util/tx';1314151617describe('Integration test: remove nft resource', () => {18 let api: any;19 let ss58Format: string;20 before(async function() {21 api = await getApiConnection();22 ss58Format = api.registry.getChainProperties()!.toJSON().ss58Format;23 if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();24 });2526 const Alice = '//Alice';27 const Bob = '//Bob';28 const src = 'test-basic-src';29 const metadata = 'test-basic-metadata';30 const license = 'test-basic-license';31 const thumb = 'test-basic-thumb';3233 it('deleting a resource directly by the NFT owner', async () => {34 const collectionIdAlice = await createCollection(35 api,36 Alice,37 'test-metadata',38 null,39 'test-symbol',40 );4142 const nftAlice = await mintNft(43 api,44 Alice,45 Alice,46 collectionIdAlice,47 'nft-metadata',48 );4950 const resourceId = await addNftBasicResource(51 api,52 Alice,53 'added',54 collectionIdAlice,55 nftAlice,56 src,57 metadata,58 license,59 thumb,60 );6162 await removeNftResource(api, 'removed', Alice, collectionIdAlice, nftAlice, resourceId);63 });6465 it('deleting resources indirectly by the NFT owner', async () => {66 const collectionIdAlice = await createCollection(67 api,68 Alice,69 'test-metadata',70 null,71 'test-symbol',72 );7374 const parentNftId = await mintNft(api, Alice, Alice, collectionIdAlice, 'parent-nft-metadata');75 const childNftId = await mintNft(api, Alice, Alice, collectionIdAlice, 'child-nft-metadata');7677 const resourceId = await addNftBasicResource(78 api,79 Alice,80 'added',81 collectionIdAlice,82 childNftId,83 src,84 metadata,85 license,86 thumb,87 );8889 const newOwnerNFT: NftIdTuple = [collectionIdAlice, parentNftId];9091 await sendNft(api, 'sent', Alice, collectionIdAlice, childNftId, newOwnerNFT);9293 await removeNftResource(api, 'removed', Alice, collectionIdAlice, childNftId, resourceId);94 });9596 it('deleting a resource by the collection owner', async () => {97 const collectionIdAlice = await createCollection(98 api,99 Alice,100 'test-metadata',101 null,102 'test-symbol',103 );104105 const nftBob = await mintNft(106 api,107 Alice,108 Bob,109 collectionIdAlice,110 'nft-metadata',111 );112113 const resourceId = await addNftBasicResource(114 api,115 Alice,116 'pending',117 collectionIdAlice,118 nftBob,119 src,120 metadata,121 license,122 thumb,123 );124125 await removeNftResource(api, 'pending', Alice, collectionIdAlice, nftBob, resourceId);126 await acceptResourceRemoval(api, Bob, collectionIdAlice, nftBob, resourceId);127 });128129 it('deleting a resource in a nested NFT by the collection owner', async () => {130 const collectionIdAlice = await createCollection(131 api,132 Alice,133 'test-metadata',134 null,135 'test-symbol',136 );137138 const parentNftId = await mintNft(139 api,140 Alice,141 Bob,142 collectionIdAlice,143 'parent-nft-metadata',144 );145 const childNftId = await mintNft(146 api,147 Alice,148 Bob,149 collectionIdAlice,150 'child-nft-metadata',151 );152153 const resourceId = await addNftBasicResource(154 api,155 Alice,156 'pending',157 collectionIdAlice,158 childNftId,159 src,160 metadata,161 license,162 thumb,163 );164165 const newOwnerNFT: NftIdTuple = [collectionIdAlice, parentNftId];166167 await sendNft(api, 'sent', Bob, collectionIdAlice, childNftId, newOwnerNFT);168169 await removeNftResource(api, 'pending', Alice, collectionIdAlice, childNftId, resourceId);170 await acceptResourceRemoval(api, Bob, collectionIdAlice, childNftId, resourceId);171 });172173 it('[negative]: can\'t delete a resource in a non-existing collection', async () => {174 const collectionIdAlice = await createCollection(175 api,176 Alice,177 'test-metadata',178 null,179 'test-symbol',180 );181182 const nftAlice = await mintNft(183 api,184 Alice,185 Alice,186 collectionIdAlice,187 'nft-metadata',188 );189190 const resourceId = await addNftBasicResource(191 api,192 Alice,193 'added',194 collectionIdAlice,195 nftAlice,196 src,197 metadata,198 license,199 thumb,200 );201202 const tx = removeNftResource(api, 'removed', Alice, 0xFFFFFFFF, nftAlice, resourceId);203 await expectTxFailure(/rmrkCore\.CollectionUnknown/, tx); // FIXME: inappropriate error message (NoAvailableNftId)204 });205206 it('[negative]: only collection owner can delete a resource', async () => {207 const collectionIdAlice = await createCollection(208 api,209 Alice,210 'test-metadata',211 null,212 'test-symbol',213 );214215 const nftAlice = await mintNft(216 api,217 Alice,218 Alice,219 collectionIdAlice,220 'nft-metadata',221 );222223 const resourceId = await addNftBasicResource(224 api,225 Alice,226 'added',227 collectionIdAlice,228 nftAlice,229 src,230 metadata,231 license,232 thumb,233 );234235 const tx = removeNftResource(api, 'removed', Bob, collectionIdAlice, nftAlice, resourceId);236 await expectTxFailure(/rmrkCore\.NoPermission/, tx);237 });238239 it('[negative]: cannot delete a resource that does not exist', async () => {240 const collectionIdAlice = await createCollection(241 api,242 Alice,243 'test-metadata',244 null,245 'test-symbol',246 );247248 const nftAlice = await mintNft(249 api,250 Alice,251 Alice,252 collectionIdAlice,253 'nft-metadata',254 );255256 const tx = removeNftResource(api, 'removed', Alice, collectionIdAlice, nftAlice, 127);257 await expectTxFailure(/rmrkCore\.ResourceDoesntExist/, tx);258 });259260 it('[negative]: Cannot accept deleting resource without owner attempt do delete it', async () => {261 const collectionIdAlice = await createCollection(262 api,263 Alice,264 'test-metadata',265 null,266 'test-symbol',267 );268269 const nftBob = await mintNft(270 api,271 Alice,272 Bob,273 collectionIdAlice,274 'nft-metadata',275 );276277 const resourceId = await addNftBasicResource(278 api,279 Alice,280 'pending',281 collectionIdAlice,282 nftBob,283 src,284 metadata,285 license,286 thumb,287 );288289 const tx = acceptResourceRemoval(api, Bob, collectionIdAlice, nftBob, resourceId);290 await expectTxFailure(/rmrkCore\.ResourceNotPending/, tx);291 });292293 it('[negative]: cannot confirm the deletion of a non-existing resource', async () => {294 const collectionIdAlice = await createCollection(295 api,296 Alice,297 'test-metadata',298 null,299 'test-symbol',300 );301302 const nftBob = await mintNft(303 api,304 Alice,305 Bob,306 collectionIdAlice,307 'nft-metadata',308 );309310 const tx = acceptResourceRemoval(api, Bob, collectionIdAlice, nftBob, 127);311 await expectTxFailure(/rmrkCore\.ResourceDoesntExist/, tx);312 });313314 it('[negative]: Non-owner user cannot confirm the deletion of resource', async () => {315 const collectionIdAlice = await createCollection(316 api,317 Alice,318 'test-metadata',319 null,320 'test-symbol',321 );322323 const nftAlice = await mintNft(324 api,325 Alice,326 Alice,327 collectionIdAlice,328 'nft-metadata',329 );330331 const resourceId = await addNftBasicResource(332 api,333 Alice,334 'added',335 collectionIdAlice,336 nftAlice,337 src,338 metadata,339 license,340 thumb,341 );342343 const tx = acceptResourceRemoval(api, Bob, collectionIdAlice, nftAlice, resourceId);344 await expectTxFailure(/rmrkCore\.NoPermission/, tx);345 });346347 after(() => {348 api.disconnect();349 });350});1import {expect} from 'chai';2import privateKey from '../substrate/privateKey';3import {executeTransaction, getApiConnection} from '../substrate/substrate-api';4import { requirePallets, Pallets } from '../util/helpers';5import {getNft, NftIdTuple} from './util/fetch';6import {expectTxFailure} from './util/helpers';7import {8 acceptNft, acceptResourceRemoval, addNftBasicResource,9 createBase,10 createCollection,11 mintNft, removeNftResource, sendNft,12} from './util/tx';1314151617describe('Integration test: remove nft resource', () => {18 let api: any;19 let ss58Format: string;20 before(async function() {21 api = await getApiConnection();22 ss58Format = api.registry.getChainProperties()!.toJSON().ss58Format;23 requirePallets(this, api, [Pallets.RmrkCore]);24 });2526 const Alice = '//Alice';27 const Bob = '//Bob';28 const src = 'test-basic-src';29 const metadata = 'test-basic-metadata';30 const license = 'test-basic-license';31 const thumb = 'test-basic-thumb';3233 it('deleting a resource directly by the NFT owner', async () => {34 const collectionIdAlice = await createCollection(35 api,36 Alice,37 'test-metadata',38 null,39 'test-symbol',40 );4142 const nftAlice = await mintNft(43 api,44 Alice,45 Alice,46 collectionIdAlice,47 'nft-metadata',48 );4950 const resourceId = await addNftBasicResource(51 api,52 Alice,53 'added',54 collectionIdAlice,55 nftAlice,56 src,57 metadata,58 license,59 thumb,60 );6162 await removeNftResource(api, 'removed', Alice, collectionIdAlice, nftAlice, resourceId);63 });6465 it('deleting resources indirectly by the NFT owner', async () => {66 const collectionIdAlice = await createCollection(67 api,68 Alice,69 'test-metadata',70 null,71 'test-symbol',72 );7374 const parentNftId = await mintNft(api, Alice, Alice, collectionIdAlice, 'parent-nft-metadata');75 const childNftId = await mintNft(api, Alice, Alice, collectionIdAlice, 'child-nft-metadata');7677 const resourceId = await addNftBasicResource(78 api,79 Alice,80 'added',81 collectionIdAlice,82 childNftId,83 src,84 metadata,85 license,86 thumb,87 );8889 const newOwnerNFT: NftIdTuple = [collectionIdAlice, parentNftId];9091 await sendNft(api, 'sent', Alice, collectionIdAlice, childNftId, newOwnerNFT);9293 await removeNftResource(api, 'removed', Alice, collectionIdAlice, childNftId, resourceId);94 });9596 it('deleting a resource by the collection owner', async () => {97 const collectionIdAlice = await createCollection(98 api,99 Alice,100 'test-metadata',101 null,102 'test-symbol',103 );104105 const nftBob = await mintNft(106 api,107 Alice,108 Bob,109 collectionIdAlice,110 'nft-metadata',111 );112113 const resourceId = await addNftBasicResource(114 api,115 Alice,116 'pending',117 collectionIdAlice,118 nftBob,119 src,120 metadata,121 license,122 thumb,123 );124125 await removeNftResource(api, 'pending', Alice, collectionIdAlice, nftBob, resourceId);126 await acceptResourceRemoval(api, Bob, collectionIdAlice, nftBob, resourceId);127 });128129 it('deleting a resource in a nested NFT by the collection owner', async () => {130 const collectionIdAlice = await createCollection(131 api,132 Alice,133 'test-metadata',134 null,135 'test-symbol',136 );137138 const parentNftId = await mintNft(139 api,140 Alice,141 Bob,142 collectionIdAlice,143 'parent-nft-metadata',144 );145 const childNftId = await mintNft(146 api,147 Alice,148 Bob,149 collectionIdAlice,150 'child-nft-metadata',151 );152153 const resourceId = await addNftBasicResource(154 api,155 Alice,156 'pending',157 collectionIdAlice,158 childNftId,159 src,160 metadata,161 license,162 thumb,163 );164165 const newOwnerNFT: NftIdTuple = [collectionIdAlice, parentNftId];166167 await sendNft(api, 'sent', Bob, collectionIdAlice, childNftId, newOwnerNFT);168169 await removeNftResource(api, 'pending', Alice, collectionIdAlice, childNftId, resourceId);170 await acceptResourceRemoval(api, Bob, collectionIdAlice, childNftId, resourceId);171 });172173 it('[negative]: can\'t delete a resource in a non-existing collection', async () => {174 const collectionIdAlice = await createCollection(175 api,176 Alice,177 'test-metadata',178 null,179 'test-symbol',180 );181182 const nftAlice = await mintNft(183 api,184 Alice,185 Alice,186 collectionIdAlice,187 'nft-metadata',188 );189190 const resourceId = await addNftBasicResource(191 api,192 Alice,193 'added',194 collectionIdAlice,195 nftAlice,196 src,197 metadata,198 license,199 thumb,200 );201202 const tx = removeNftResource(api, 'removed', Alice, 0xFFFFFFFF, nftAlice, resourceId);203 await expectTxFailure(/rmrkCore\.CollectionUnknown/, tx); // FIXME: inappropriate error message (NoAvailableNftId)204 });205206 it('[negative]: only collection owner can delete a resource', async () => {207 const collectionIdAlice = await createCollection(208 api,209 Alice,210 'test-metadata',211 null,212 'test-symbol',213 );214215 const nftAlice = await mintNft(216 api,217 Alice,218 Alice,219 collectionIdAlice,220 'nft-metadata',221 );222223 const resourceId = await addNftBasicResource(224 api,225 Alice,226 'added',227 collectionIdAlice,228 nftAlice,229 src,230 metadata,231 license,232 thumb,233 );234235 const tx = removeNftResource(api, 'removed', Bob, collectionIdAlice, nftAlice, resourceId);236 await expectTxFailure(/rmrkCore\.NoPermission/, tx);237 });238239 it('[negative]: cannot delete a resource that does not exist', async () => {240 const collectionIdAlice = await createCollection(241 api,242 Alice,243 'test-metadata',244 null,245 'test-symbol',246 );247248 const nftAlice = await mintNft(249 api,250 Alice,251 Alice,252 collectionIdAlice,253 'nft-metadata',254 );255256 const tx = removeNftResource(api, 'removed', Alice, collectionIdAlice, nftAlice, 127);257 await expectTxFailure(/rmrkCore\.ResourceDoesntExist/, tx);258 });259260 it('[negative]: Cannot accept deleting resource without owner attempt do delete it', async () => {261 const collectionIdAlice = await createCollection(262 api,263 Alice,264 'test-metadata',265 null,266 'test-symbol',267 );268269 const nftBob = await mintNft(270 api,271 Alice,272 Bob,273 collectionIdAlice,274 'nft-metadata',275 );276277 const resourceId = await addNftBasicResource(278 api,279 Alice,280 'pending',281 collectionIdAlice,282 nftBob,283 src,284 metadata,285 license,286 thumb,287 );288289 const tx = acceptResourceRemoval(api, Bob, collectionIdAlice, nftBob, resourceId);290 await expectTxFailure(/rmrkCore\.ResourceNotPending/, tx);291 });292293 it('[negative]: cannot confirm the deletion of a non-existing resource', async () => {294 const collectionIdAlice = await createCollection(295 api,296 Alice,297 'test-metadata',298 null,299 'test-symbol',300 );301302 const nftBob = await mintNft(303 api,304 Alice,305 Bob,306 collectionIdAlice,307 'nft-metadata',308 );309310 const tx = acceptResourceRemoval(api, Bob, collectionIdAlice, nftBob, 127);311 await expectTxFailure(/rmrkCore\.ResourceDoesntExist/, tx);312 });313314 it('[negative]: Non-owner user cannot confirm the deletion of resource', async () => {315 const collectionIdAlice = await createCollection(316 api,317 Alice,318 'test-metadata',319 null,320 'test-symbol',321 );322323 const nftAlice = await mintNft(324 api,325 Alice,326 Alice,327 collectionIdAlice,328 'nft-metadata',329 );330331 const resourceId = await addNftBasicResource(332 api,333 Alice,334 'added',335 collectionIdAlice,336 nftAlice,337 src,338 metadata,339 license,340 thumb,341 );342343 const tx = acceptResourceRemoval(api, Bob, collectionIdAlice, nftAlice, resourceId);344 await expectTxFailure(/rmrkCore\.NoPermission/, tx);345 });346347 after(() => {348 api.disconnect();349 });350});tests/src/rmrk/rmrkIsolation.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/rmrkIsolation.test.ts
+++ b/tests/src/rmrk/rmrkIsolation.test.ts
@@ -6,7 +6,7 @@
getCreateCollectionResult,
getDetailedCollectionInfo,
getGenericResult,
- getModuleNames,
+ requirePallets,
normalizeAccountId,
Pallets,
} from '../util/helpers';
@@ -64,7 +64,7 @@
before(async function() {
await usingApi(async (api, privateKeyWrapper) => {
alice = privateKeyWrapper('//Alice');
- if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ requirePallets(this, api, [Pallets.RmrkCore]);
});
});
tests/src/rmrk/sendNft.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/sendNft.test.ts
+++ b/tests/src/rmrk/sendNft.test.ts
@@ -3,13 +3,13 @@
import {createCollection, mintNft, sendNft} from './util/tx';
import {NftIdTuple} from './util/fetch';
import {isNftChildOfAnother, expectTxFailure} from './util/helpers';
-import { getModuleNames, Pallets } from '../util/helpers';
+import { requirePallets, Pallets } from '../util/helpers';
describe('integration test: send NFT', () => {
let api: any;
before(async function () {
api = await getApiConnection();
- if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ requirePallets(this, api, [Pallets.RmrkCore]);
});
const maxNftId = 0xFFFFFFFF;
tests/src/rmrk/setCollectionProperty.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/setCollectionProperty.test.ts
+++ b/tests/src/rmrk/setCollectionProperty.test.ts
@@ -1,5 +1,5 @@
import {getApiConnection} from '../substrate/substrate-api';
-import { getModuleNames, Pallets } from '../util/helpers';
+import { requirePallets, Pallets } from '../util/helpers';
import {expectTxFailure} from './util/helpers';
import {createCollection, setPropertyCollection} from './util/tx';
@@ -10,7 +10,7 @@
let api: any;
before(async function () {
api = await getApiConnection();
- if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ requirePallets(this, api, [Pallets.RmrkCore]);
});
it('set collection property', async () => {
tests/src/rmrk/setEquippableList.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/setEquippableList.test.ts
+++ b/tests/src/rmrk/setEquippableList.test.ts
@@ -1,5 +1,5 @@
import {getApiConnection} from '../substrate/substrate-api';
-import { getModuleNames, Pallets } from '../util/helpers';
+import { requirePallets, Pallets } from '../util/helpers';
import {expectTxFailure} from './util/helpers';
import {createCollection, createBase, setEquippableList} from './util/tx';
@@ -7,7 +7,7 @@
let api: any;
before(async function () {
api = await getApiConnection();
- if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ requirePallets(this, api, [Pallets.RmrkCore]);
});
const alice = '//Alice';
tests/src/rmrk/setNftProperty.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/setNftProperty.test.ts
+++ b/tests/src/rmrk/setNftProperty.test.ts
@@ -1,5 +1,5 @@
import {getApiConnection} from '../substrate/substrate-api';
-import { getModuleNames, Pallets } from '../util/helpers';
+import { requirePallets, Pallets } from '../util/helpers';
import {NftIdTuple} from './util/fetch';
import {expectTxFailure} from './util/helpers';
import {createCollection, mintNft, sendNft, setNftProperty} from './util/tx';
@@ -8,7 +8,7 @@
let api: any;
before(async function () {
api = await getApiConnection();
- if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ requirePallets(this, api, [Pallets.RmrkCore]);
});
const alice = '//Alice';
tests/src/rmrk/setResourcePriorities.test.tsdiffbeforeafterboth--- a/tests/src/rmrk/setResourcePriorities.test.ts
+++ b/tests/src/rmrk/setResourcePriorities.test.ts
@@ -1,5 +1,5 @@
import {getApiConnection} from '../substrate/substrate-api';
-import { getModuleNames, Pallets } from '../util/helpers';
+import { requirePallets, Pallets } from '../util/helpers';
import {expectTxFailure} from './util/helpers';
import {mintNft, createCollection, setResourcePriorities} from './util/tx';
@@ -7,7 +7,7 @@
let api: any;
before(async function () {
api = await getApiConnection();
- if (!getModuleNames(api).includes(Pallets.RmrkCore)) this.skip();
+ requirePallets(this, api, [Pallets.RmrkCore]);
});
const alice = '//Alice';
tests/src/util/helpers.tsdiffbeforeafterboth--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -28,6 +28,7 @@
import {hexToStr, strToUTF16, utf16ToStr} from './util';
import {UpDataStructsRpcCollection, UpDataStructsCreateItemData, UpDataStructsProperty} from '@polkadot/types/lookup';
import {UpDataStructsTokenChild} from '../interfaces';
+import { Context } from 'mocha';
chai.use(chaiAsPromised);
const expect = chai.expect;
@@ -42,6 +43,7 @@
export enum Pallets {
Inflation = 'inflation',
RmrkCore = 'rmrkcore',
+ RmrkEquip = 'rmrkequip',
ReFungible = 'refungible',
Fungible = 'fungible',
NFT = 'nonfungible',
@@ -70,6 +72,16 @@
return modulesNames;
}
+export function requirePallets(mocha: Context, api: ApiPromise, requiredPallets: string[]) {
+ const pallets = getModuleNames(api);
+
+ const isAllPalletsPresent = requiredPallets.every(p => pallets.includes(p));
+
+ if (!isAllPalletsPresent) {
+ mocha.skip();
+ }
+}
+
export function normalizeAccountId(input: string | AccountId | CrossAccountId | IKeyringPair): CrossAccountId {
if (typeof input === 'string') {
if (input.length >= 47) {