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

difftreelog

test fix eslint warnings

Yaroslav Bolyukin2022-05-30parent: #5e512fa.patch.diff
in: master

2 files changed

modifiedtests/src/burnItem.test.tsdiffbeforeafterboth
--- a/tests/src/burnItem.test.ts
+++ b/tests/src/burnItem.test.ts
@@ -21,7 +21,6 @@
   createCollectionExpectSuccess,
   createItemExpectSuccess,
   getGenericResult,
-  destroyCollectionExpectSuccess,
   normalizeAccountId,
   addCollectionAdminExpectSuccess,
   getBalance,
modifiedtests/src/createCollection.test.tsdiffbeforeafterboth
before · tests/src/createCollection.test.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {expect} from 'chai';18import privateKey from './substrate/privateKey';19import usingApi, {executeTransaction, submitTransactionAsync} from './substrate/substrate-api';20import {createCollectionWithPropsExpectFailure, createCollectionExpectFailure, createCollectionExpectSuccess, getCreateCollectionResult, getDetailedCollectionInfo, createCollectionWithPropsExpectSuccess} from './util/helpers';2122describe('integration test: ext. createCollection():', () => {23  it('Create new NFT collection', async () => {24    await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}});25  });26  it('Create new NFT collection whith collection_name of maximum length (64 bytes)', async () => {27    await createCollectionExpectSuccess({name: 'A'.repeat(64)});28  });29  it('Create new NFT collection whith collection_description of maximum length (256 bytes)', async () => {30    await createCollectionExpectSuccess({description: 'A'.repeat(256)});31  });32  it('Create new NFT collection whith token_prefix of maximum length (16 bytes)', async () => {33    await createCollectionExpectSuccess({tokenPrefix: 'A'.repeat(16)});34  });35  it('Create new Fungible collection', async () => {36    await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});37  });38  it('Create new ReFungible collection', async () => {39    await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});40  });4142  it('create new collection with properties #1', async () => {43    await createCollectionWithPropsExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'},44      properties: [{key: 'key1', value: 'val1'}],45      propPerm:   [{key: 'key1', permission: {tokenOwner: true, mutable: false, collectionAdmin: true}}]});46  });4748  it('create new collection with properties #2', async () => {49    await createCollectionWithPropsExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'},50      properties: [{key: 'key1', value: 'val1'}],51      propPerm:   [{key: 'key1', permission: {tokenOwner: true, mutable: false, collectionAdmin: true}}]});52  });5354  it('create new collection with properties #3', async () => {55    await createCollectionWithPropsExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'},56      properties: [{key: 'key1', value: 'val1'}],57      propPerm:   [{key: 'key1', permission: {tokenOwner: true, mutable: false, collectionAdmin: true}}]});58  });5960  it('Create new collection with extra fields', async () => {61    await usingApi(async api => {62      const alice = privateKey('//Alice');63      const bob = privateKey('//Bob');64      const tx = api.tx.unique.createCollectionEx({65        mode: {Fungible: 8},66        permissions: {67          access: 'AllowList'68        },69        name: [1],70        description: [2],71        tokenPrefix: '0x000000',72        pendingSponsor: bob.address,73        limits: {74          accountTokenOwnershipLimit: 3,75        },76      });77      const events = await submitTransactionAsync(alice, tx);78      const result = getCreateCollectionResult(events);7980      const collection = (await getDetailedCollectionInfo(api, result.collectionId))!;81      expect(collection.owner.toString()).to.equal(alice.address);82      expect(collection.mode.asFungible.toNumber()).to.equal(8);83      expect(collection.permissions.access.toHuman()).to.equal('AllowList');84      expect(collection.name.map(v => v.toNumber())).to.deep.equal([1]);85      expect(collection.description.map(v => v.toNumber())).to.deep.equal([2]);86      expect(collection.tokenPrefix.toString()).to.equal('0x000000');87      expect(collection.sponsorship.asUnconfirmed.toString()).to.equal(bob.address);88      expect(collection.limits.accountTokenOwnershipLimit.unwrap().toNumber()).to.equal(3);89    });90  });91});9293describe('(!negative test!) integration test: ext. createCollection():', () => {94  it('(!negative test!) create new NFT collection whith incorrect data (collection_name)', async () => {95    await createCollectionExpectFailure({name: 'A'.repeat(65), mode: {type: 'NFT'}});96  });97  it('(!negative test!) create new NFT collection whith incorrect data (collection_description)', async () => {98    await createCollectionExpectFailure({description: 'A'.repeat(257), mode: {type: 'NFT'}});99  });100  it('(!negative test!) create new NFT collection whith incorrect data (token_prefix)', async () => {101    await createCollectionExpectFailure({tokenPrefix: 'A'.repeat(17), mode: {type: 'NFT'}});102  });103  it('fails when bad limits are set', async () => {104    await usingApi(async api => {105      const alice = privateKey('//Alice');106      const tx = api.tx.unique.createCollectionEx({mode: 'NFT', limits: {tokenLimit: 0}});107      await expect(executeTransaction(api, alice, tx)).to.be.rejectedWith(/^common.CollectionTokenLimitExceeded$/);108    });109  });110111  it('(!negative test!) create collection with incorrect property limit (64 elements)', async () => {112    const props = [];113114    for (let i = 0; i < 65; i++) {115      props.push({key: `key${i}`, value: `value${i}`});116    }117118    await createCollectionWithPropsExpectFailure({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}, properties: props});119  });120121  it('(!negative test!) create collection with incorrect property limit (40 kb)', async () => {122    const props = [];123124    for (let i = 0; i < 32; i++) {125      props.push({key: `key${i}`.repeat(80), value: `value${i}`.repeat(80)});126    }127128    await createCollectionWithPropsExpectFailure({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}, properties: props});129  });130});