difftreelog
tests fix
in: master
2 files changed
tests/package.jsondiffbeforeafterboth1{2 "name": "NftTests",3 "version": "1.0.0",4 "description": "Substrate Nft tests",5 "main": "",6 "devDependencies": {7 "@polkadot/dev": "^0.52.11",8 "@polkadot/ts": "^0.3.41",9 "@types/chai": "^4.2.12",10 "@types/chai-as-promised": "^7.1.3",11 "@types/mocha": "^8.0.3",12 "chai": "^4.2.0",13 "mocha": "^8.1.1",14 "ts-node": "^9.0.0",15 "tslint": "^5.20.1",16 "typescript": "^3.9.7"17 },18 "scripts": {19 "test": "mocha --timeout 9999999 -r ts-node/register ./**/*.test.ts",20 "load": "mocha --timeout 9999999 -r ts-node/register ./**/*.load.ts"21 },22 "author": "",23 "license": "Apache 2.0",24 "homepage": "",25 "dependencies": {26 "@polkadot/api": "^2.3.1",27 "@polkadot/api-contract": "^2.3.1",28 "@polkadot/types": "^2.3.1",29 "@polkadot/util": "^3.4.1",30 "bignumber.js": "^9.0.0",31 "chai-as-promised": "^7.1.1"32 },33 "standard": {34 "globals": [35 "it",36 "assert",37 "beforeEach",38 "afterEach",39 "describe",40 "contract",41 "artifacts"42 ]43 }44}tests/src/addCollectionAdmin.test.tsdiffbeforeafterboth--- a/tests/src/addCollectionAdmin.test.ts
+++ b/tests/src/addCollectionAdmin.test.ts
@@ -1,4 +1,6 @@
-import chai from 'chai';
+import { ApiPromise } from '@polkadot/api';
+import BN from 'bn.js';
+import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from './substrate/privateKey';
import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';
@@ -57,4 +59,36 @@
await createCollectionExpectSuccess();
});
});
+
+ it('Add an admin to a collection that has reached the maximum number of admins limit', async () => {
+ await usingApi(async (api: ApiPromise) => {
+ const Alice = privateKey('//Alice');
+ const accounts = [
+ 'GsvVmjr1CBHwQHw84pPHMDxgNY3iBLz6Qn7qS3CH8qPhrHz',
+ 'FoQJpPyadYccjavVdTWxpxU7rUEaYhfLCPwXgkfD6Zat9QP',
+ 'JKspFU6ohf1Grg3Phdzj2pSgWvsYWzSfKghhfzMbdhNBWs5',
+ 'JKspFU6ohf1Grg3Phdzj2pSgWvsYWzSfKghhfzMbdhNBWs5',
+ 'Fr4NzY1udSFFLzb2R3qxVQkwz9cZraWkyfH4h3mVVk7BK7P',
+ 'DfnTB4z7eUvYRqcGtTpFsLC69o6tvBSC1pEv8vWPZFtCkaK',
+ 'HnMAUz7r2G8G3hB27SYNyit5aJmh2a5P4eMdDtACtMFDbam',
+ 'DE14BzQ1bDXWPKeLoAqdLAm1GpyAWaWF1knF74cEZeomTBM',
+ ];
+ const collectionId = await createCollectionExpectSuccess();
+
+ const chainLimit = await api.query.nft.chainLimit() as unknown as { collections_admins_limit: BN };
+ const chainLimitNumber = chainLimit.collections_admins_limit.toNumber();
+ expect(chainLimitNumber).to.be.equal(5);
+
+ for (let i = 0; i < chainLimitNumber - 1; i++) {
+ const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, accounts[i]);
+ await submitTransactionAsync(Alice, changeAdminTx);
+ const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));
+ adminListAfterAddAdmin.map((item: any) => console.log(item.toString()));
+ expect(adminListAfterAddAdmin).to.be.contains(accounts[i]);
+ }
+
+ const tx = api.tx.nft.addCollectionAdmin(collectionId, accounts[chainLimitNumber - 1]);
+ await expect(submitTransactionExpectFailAsync(Alice, tx)).to.be.rejected;
+ });
+ });
});