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

difftreelog

CreateItem* tests fixes

kryadinskii2022-05-19parent: #69adc40.patch.diff
in: master

4 files changed

modifiedtests/src/createItem.test.tsdiffbeforeafterboth
--- a/tests/src/createItem.test.ts
+++ b/tests/src/createItem.test.ts
@@ -23,13 +23,14 @@
   createItemExpectSuccess,
   addCollectionAdminExpectSuccess,
   createCollectionWithPropsExpectSuccess,
+  createItemWithPropsExpectSuccess,
 } from './util/helpers';
 
 const expect = chai.expect;
 let alice: IKeyringPair;
 let bob: IKeyringPair;
 
-describe('integration test: ext. createItem():', () => {
+describe('integration test: ext. ():', () => {
   before(async () => {
     await usingApi(async () => {
       const keyring = new Keyring({type: 'sr25519'});
@@ -75,28 +76,25 @@
   it('Set property Admin', async () => {
     const createMode = 'NFT';
     const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 
-      properties: [{key: 'key1', value: 'val1'}], 
-      propPerm:   [{key: 'key1', mutable: true, collectionAdmin: true, tokenOwner: false}]});
+      propPerm:   [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});
     
-    await createItemExpectSuccess(alice, newCollectionID, createMode);
+    await createItemWithPropsExpectSuccess(alice, newCollectionID, createMode, [{key: 'k', value: 't2'}]);
   });
 
   it('Set property AdminConst', async () => {
     const createMode = 'NFT';
     const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 
-      properties: [{key: 'key1', value: 'val1'}], 
-      propPerm:   [{key: 'key1', mutable: false, collectionAdmin: true, tokenOwner: false}]});
+      propPerm:   [{key: 'key1', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]});
     
-    await createItemExpectSuccess(alice, newCollectionID, createMode);
+    await createItemWithPropsExpectSuccess(alice, newCollectionID, createMode, [{key: 'key1', value: 'val1'}]);
   });
 
   it('Set property itemOwnerOrAdmin', async () => {
     const createMode = 'NFT';
-    const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 
-      properties: [{key: 'key1', value: 'val1'}], 
-      propPerm:   [{key: 'key1', mutable: true, collectionAdmin: true, tokenOwner: true}]});
+    const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode},
+      propPerm:   [{key: 'key1', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});
     
-    await createItemExpectSuccess(alice, newCollectionID, createMode);
+    await createItemWithPropsExpectSuccess(alice, newCollectionID, createMode, [{key: 'key1', value: 'val1'}]);
   });
 });
 
@@ -129,7 +127,7 @@
     await usingApi(async api => {
       const createMode = 'NFT';
       const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 
-        propPerm:   [{key: 'key1', mutable: false, collectionAdmin: false, tokenOwner: false}]});
+        propPerm:   [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});
 
       const token = await createItemExpectSuccess(alice, newCollectionID, 'NFT');
       await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);
@@ -144,7 +142,7 @@
 
   it('User doesnt have editing rights', async () => {
     await usingApi(async api => {
-      const newCollectionID = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'key1', mutable: true, collectionAdmin: false, tokenOwner: false}]});
+      const newCollectionID = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});
       const token = await createItemExpectSuccess(alice, newCollectionID, 'NFT');
 
       await expect(executeTransaction(
modifiedtests/src/createMultipleItems.test.tsdiffbeforeafterboth
before · tests/src/createMultipleItems.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 {ApiPromise} from '@polkadot/api';18import {IKeyringPair} from '@polkadot/types/types';19import chai from 'chai';20import chaiAsPromised from 'chai-as-promised';21import privateKey from './substrate/privateKey';22import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync, executeTransaction} from './substrate/substrate-api';23import {24  createCollectionExpectSuccess,25  destroyCollectionExpectSuccess,26  getGenericResult,27  normalizeAccountId,28  setCollectionLimitsExpectSuccess,29  addCollectionAdminExpectSuccess,30  getBalance,31  getTokenOwner,32  getLastTokenId,33  getConstMetadata,34  getCreatedCollectionCount,35  createCollectionWithPropsExpectSuccess,36  getCreateItemsResult,37} from './util/helpers';3839chai.use(chaiAsPromised);40const expect = chai.expect;4142describe('Integration Test createMultipleItems(collection_id, owner, items_data):', () => {43  it('Create  0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {44    await usingApi(async (api: ApiPromise) => {45      const collectionId = await createCollectionExpectSuccess();46      const itemsListIndexBefore = await getLastTokenId(api, collectionId);47      expect(itemsListIndexBefore).to.be.equal(0);48      const alice = privateKey('//Alice');49      const args = [{Nft: {const_data: '0x31'}},50        {Nft: {const_data: '0x32'}},51        {Nft: {const_data: '0x33'}}];52      const createMultipleItemsTx = api.tx.unique53        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);54      await submitTransactionAsync(alice, createMultipleItemsTx);55      const itemsListIndexAfter = await getLastTokenId(api, collectionId);56      expect(itemsListIndexAfter).to.be.equal(3);5758      expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address));59      expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));60      expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));6162      expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);63      expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);64      expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);65    });66  });6768  it('Create  0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {69    await usingApi(async (api: ApiPromise) => {70      const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});71      const itemsListIndexBefore = await getLastTokenId(api, collectionId);72      expect(itemsListIndexBefore).to.be.equal(0);73      const alice = privateKey('//Alice');74      const args = [75        {Fungible: {value: 1}},76        {Fungible: {value: 2}},77        {Fungible: {value: 3}},78      ];79      const createMultipleItemsTx = api.tx.unique80        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);81      await submitTransactionAsync(alice, createMultipleItemsTx);82      const token1Data = await getBalance(api, collectionId, alice.address, 0);8384      expect(token1Data).to.be.equal(6n); // 1 + 2 + 385    });86  });8788  it('Create  0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async () => {89    await usingApi(async (api: ApiPromise) => {90      const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});91      const itemsListIndexBefore = await getLastTokenId(api, collectionId);92      expect(itemsListIndexBefore).to.be.equal(0);93      const alice = privateKey('//Alice');94      const args = [95        {ReFungible: {const_data: [0x31], pieces: 1}},96        {ReFungible: {const_data: [0x32], pieces: 1}},97        {ReFungible: {const_data: [0x33], pieces: 1}},98      ];99      const createMultipleItemsTx = api.tx.unique100        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);101      await submitTransactionAsync(alice, createMultipleItemsTx);102      const itemsListIndexAfter = await getLastTokenId(api, collectionId);103      expect(itemsListIndexAfter).to.be.equal(3);104105      expect(await getBalance(api, collectionId, alice.address, 1)).to.be.equal(1n);106      expect(await getBalance(api, collectionId, alice.address, 2)).to.be.equal(1n);107      expect(await getBalance(api, collectionId, alice.address, 3)).to.be.equal(1n);108109      expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);110      expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);111      expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);112    });113  });114115  it('Can mint amount of items equals to collection limits', async () => {116    await usingApi(async (api) => {117      const alice = privateKey('//Alice');118119      const collectionId = await createCollectionExpectSuccess();120      await setCollectionLimitsExpectSuccess(alice, collectionId, {121        tokenLimit: 2,122      });123      const args = [124        {NFT: {const_data: 'A'}},125        {NFT: {const_data: 'B'}},126      ];127      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);128      const events = await submitTransactionAsync(alice, createMultipleItemsTx);129      const result = getGenericResult(events);130      expect(result.success).to.be.true;131    });132  });133134  it('Create  0x31, 0x32, 0x33 items in active NFT with property Admin', async () => {135    await usingApi(async (api: ApiPromise) => {136      const collectionId = await createCollectionExpectSuccess();137      const itemsListIndexBefore = await getLastTokenId(api, collectionId);138      expect(itemsListIndexBefore).to.be.equal(0);139      const alice = privateKey('//Alice');140      const bob = privateKey('//Bob');141      const args = [{Nft: {const_data: '0x31'}},142        {Nft: {const_data: '0x32'}},143        {Nft: {const_data: '0x33'}}];144      const createMultipleItemsTx = api.tx.unique145        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);146      await submitTransactionAsync(alice, createMultipleItemsTx);147      const itemsListIndexAfter = await getLastTokenId(api, collectionId);148      expect(itemsListIndexAfter).to.be.equal(3);149150      await expect(executeTransaction(151        api,152        alice,153        api.tx.unique.setPropertyPermissions(collectionId, [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]),154      )).to.not.be.rejected;155156      expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address));157      expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));158      expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));159160      expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);161      expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);162      expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);163    });164  });165166  it('Create  0x31, 0x32, 0x33 items in active NFT with property AdminConst', async () => {167    await usingApi(async (api: ApiPromise) => {168      const collectionId = await createCollectionExpectSuccess();169      const itemsListIndexBefore = await getLastTokenId(api, collectionId);170      expect(itemsListIndexBefore).to.be.equal(0);171      const alice = privateKey('//Alice');172      const bob = privateKey('//Bob');173      const args = [{Nft: {const_data: '0x31'}},174        {Nft: {const_data: '0x32'}},175        {Nft: {const_data: '0x33'}}];176      const createMultipleItemsTx = api.tx.unique177        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);178      await submitTransactionAsync(alice, createMultipleItemsTx);179      const itemsListIndexAfter = await getLastTokenId(api, collectionId);180      expect(itemsListIndexAfter).to.be.equal(3);181182      await expect(executeTransaction(183        api,184        alice,185        api.tx.unique.setPropertyPermissions(collectionId, [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]),186      )).to.not.be.rejected;187188      expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address));189      expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));190      expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));191192      expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);193      expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);194      expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);195    });196  });197198  it('Create  0x31, 0x32, 0x33 items in active NFT with property itemOwnerOrAdmin', async () => {199    await usingApi(async (api: ApiPromise) => {200      const collectionId = await createCollectionExpectSuccess();201      const itemsListIndexBefore = await getLastTokenId(api, collectionId);202      expect(itemsListIndexBefore).to.be.equal(0);203      const alice = privateKey('//Alice');204      const bob = privateKey('//Bob');205      const args = [{Nft: {const_data: '0x31'}},206        {Nft: {const_data: '0x32'}},207        {Nft: {const_data: '0x33'}}];208      const createMultipleItemsTx = api.tx.unique209        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);210      await submitTransactionAsync(alice, createMultipleItemsTx);211      const itemsListIndexAfter = await getLastTokenId(api, collectionId);212      expect(itemsListIndexAfter).to.be.equal(3);213214      await expect(executeTransaction(215        api,216        alice,217        api.tx.unique.setPropertyPermissions(collectionId, [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]),218      )).to.not.be.rejected;219220      expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address));221      expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));222      expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));223224      expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);225      expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);226      expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);227    });228  });229});230231describe('Integration Test createMultipleItems(collection_id, owner, items_data) with collection admin permissions:', () => {232233  let alice: IKeyringPair;234  let bob: IKeyringPair;235236  before(async () => {237    await usingApi(async () => {238      alice = privateKey('//Alice');239      bob = privateKey('//Bob');240    });241  });242243  it('Create  0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {244    await usingApi(async (api: ApiPromise) => {245      const collectionId = await createCollectionExpectSuccess();246      const itemsListIndexBefore = await getLastTokenId(api, collectionId);247      expect(itemsListIndexBefore).to.be.equal(0);248      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);249      const args = [{Nft: {const_data: '0x31'}},250        {Nft: {const_data: '0x32'}},251        {Nft: {const_data: '0x33'}}];252      const createMultipleItemsTx = api.tx.unique253        .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);254      await submitTransactionAsync(bob, createMultipleItemsTx);255      const itemsListIndexAfter = await getLastTokenId(api, collectionId);256      expect(itemsListIndexAfter).to.be.equal(3);257258      expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(bob.address));259      expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(bob.address));260      expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(bob.address));261262      expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);263      expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);264      expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);265    });266  });267268  it('Create  0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {269    await usingApi(async (api: ApiPromise) => {270      const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});271      const itemsListIndexBefore = await getLastTokenId(api, collectionId);272      expect(itemsListIndexBefore).to.be.equal(0);273      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);274      const args = [275        {Fungible: {value: 1}},276        {Fungible: {value: 2}},277        {Fungible: {value: 3}},278      ];279      const createMultipleItemsTx = api.tx.unique280        .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);281      await submitTransactionAsync(bob, createMultipleItemsTx);282      const token1Data = await getBalance(api, collectionId, bob.address, 0);283284      expect(token1Data).to.be.equal(6n); // 1 + 2 + 3285    });286  });287288  it('Create  0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async () => {289    await usingApi(async (api: ApiPromise) => {290      const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});291      const itemsListIndexBefore = await getLastTokenId(api, collectionId);292      expect(itemsListIndexBefore).to.be.equal(0);293      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);294      const args = [295        {ReFungible: {const_data: [0x31], pieces: 1}},296        {ReFungible: {const_data: [0x32], pieces: 1}},297        {ReFungible: {const_data: [0x33], pieces: 1}},298      ];299      const createMultipleItemsTx = api.tx.unique300        .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);301      await submitTransactionAsync(bob, createMultipleItemsTx);302      const itemsListIndexAfter = await getLastTokenId(api, collectionId);303      expect(itemsListIndexAfter).to.be.equal(3);304305      expect(await getBalance(api, collectionId, bob.address, 1)).to.be.equal(1n);306      expect(await getBalance(api, collectionId, bob.address, 2)).to.be.equal(1n);307      expect(await getBalance(api, collectionId, bob.address, 3)).to.be.equal(1n);308309      expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);310      expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);311      expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);312    });313  });314});315316describe('Negative Integration Test createMultipleItems(collection_id, owner, items_data):', () => {317318  let alice: IKeyringPair;319  let bob: IKeyringPair;320321  before(async () => {322    await usingApi(async () => {323      alice = privateKey('//Alice');324      bob = privateKey('//Bob');325    });326  });327328  it('Regular user cannot create items in active NFT collection', async () => {329    await usingApi(async (api: ApiPromise) => {330      const collectionId = await createCollectionExpectSuccess();331      const itemsListIndexBefore = await getLastTokenId(api, collectionId);332      expect(itemsListIndexBefore).to.be.equal(0);333      const args = [{Nft: {const_data: '0x31'}},334        {Nft: {const_data: '0x32'}},335        {Nft: {const_data: '0x33'}}];336      const createMultipleItemsTx = api.tx.unique337        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);338      await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;339    });340  });341342  it('Regular user cannot create items in active Fungible collection', async () => {343    await usingApi(async (api: ApiPromise) => {344      const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});345      const itemsListIndexBefore = await getLastTokenId(api, collectionId);346      expect(itemsListIndexBefore).to.be.equal(0);347      const args = [348        {Fungible: {value: 1}},349        {Fungible: {value: 2}},350        {Fungible: {value: 3}},351      ];352      const createMultipleItemsTx = api.tx.unique353        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);354      await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;355    });356  });357358  it('Regular user cannot create items in active ReFungible collection', async () => {359    await usingApi(async (api: ApiPromise) => {360      const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});361      const itemsListIndexBefore = await getLastTokenId(api, collectionId);362      expect(itemsListIndexBefore).to.be.equal(0);363      const args = [364        {ReFungible: {const_data: [0x31], pieces: 1}},365        {ReFungible: {const_data: [0x32], pieces: 1}},366        {ReFungible: {const_data: [0x33], pieces: 1}},367      ];368      const createMultipleItemsTx = api.tx.unique369        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);370      await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;371    });372  });373374  it('Create token in not existing collection', async () => {375    await usingApi(async (api: ApiPromise) => {376      const collectionId = await getCreatedCollectionCount(api) + 1;377      const createMultipleItemsTx = api.tx.unique378        .createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'NFT', 'NFT']);379      await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;380    });381  });382383  it('Create NFT and Re-fungible tokens that has reached the maximum data limit', async () => {384    await usingApi(async (api: ApiPromise) => {385      // NFT386      const collectionId = await createCollectionExpectSuccess();387      const alice = privateKey('//Alice');388      const args = [389        {NFT: {const_data: 'A'.repeat(2049)}},390        {NFT: {const_data: 'B'.repeat(2049)}},391        {NFT: {const_data: 'C'.repeat(2049)}},392      ];393      const createMultipleItemsTx = api.tx.unique394        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);395      await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;396397      // ReFungible398      const collectionIdReFungible =399        await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});400      const argsReFungible = [401        {ReFungible: ['1'.repeat(2049), 10]},402        {ReFungible: ['2'.repeat(2049), 10]},403        {ReFungible: ['3'.repeat(2049), 10]},404      ];405      const createMultipleItemsTxFungible = api.tx.unique406        .createMultipleItems(collectionIdReFungible, normalizeAccountId(alice.address), argsReFungible);407      await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTxFungible)).to.be.rejected;408    });409  });410411  it('Create tokens with different types', async () => {412    await usingApi(async (api: ApiPromise) => {413      const collectionId = await createCollectionExpectSuccess();414      const createMultipleItemsTx = api.tx.unique415        .createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'Fungible', 'ReFungible']);416      await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;417      // garbage collection :-D418      await destroyCollectionExpectSuccess(collectionId);419    });420  });421422  it('Create tokens with different data limits <> maximum data limit', async () => {423    await usingApi(async (api: ApiPromise) => {424      const collectionId = await createCollectionExpectSuccess();425      const args = [426        {NFT: {const_data: 'A'}},427        {NFT: {const_data: 'B'.repeat(2049)}},428      ];429      const createMultipleItemsTx = await api.tx.unique430        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);431      await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;432    });433  });434435  it('Fails when minting tokens exceeds collectionLimits amount', async () => {436    await usingApi(async (api) => {437438      const collectionId = await createCollectionExpectSuccess();439      await setCollectionLimitsExpectSuccess(alice, collectionId, {440        tokenLimit: 1,441      });442      const args = [443        {NFT: {const_data: 'A'}},444        {NFT: {const_data: 'B'}},445      ];446      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);447      await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;448    });449  });450451  it('No editing rights', async () => {452    await usingApi(async (api: ApiPromise) => {453      const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],454        propPerm:   [{key: 'key1', mutable: true, collectionAdmin: false, tokenOwner: false}]});455      const itemsListIndexBefore = await getLastTokenId(api, collectionId);456      expect(itemsListIndexBefore).to.be.equal(0);457      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);458      const args = [{Nft: {const_data: '0x31'}},459        {Nft: {const_data: '0x32'}},460        {Nft: {const_data: '0x33'}}];461462      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);463464      const events = await submitTransactionAsync(alice, createMultipleItemsTx);465      const result = getCreateItemsResult(events);466467      for (const elem of result) {468        await expect(executeTransaction(469          api,470          bob,471          api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]),472        )).to.be.rejected;473      }474475      // await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;476    });477  });478479  it('User doesnt have editing rights', async () => {480    await usingApi(async (api: ApiPromise) => {481      const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],482        propPerm:   [{key: 'key1', mutable: false, collectionAdmin: false, tokenOwner: false}]});483      const itemsListIndexBefore = await getLastTokenId(api, collectionId);484      expect(itemsListIndexBefore).to.be.equal(0);485      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);486      const args = [{Nft: {const_data: '0x31'}},487        {Nft: {const_data: '0x32'}},488        {Nft: {const_data: '0x33'}}];489490      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);491492      const events = await submitTransactionAsync(alice, createMultipleItemsTx);493      const result = getCreateItemsResult(events);494495      for (const elem of result) {496        await expect(executeTransaction(497          api,498          bob,499          api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]),500        )).to.be.rejected;501      }502    });503  });504505  it('Adding property without access rights', async () => {506    await usingApi(async (api: ApiPromise) => {507      const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}]});508      const itemsListIndexBefore = await getLastTokenId(api, collectionId);509      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);510      expect(itemsListIndexBefore).to.be.equal(0);511      const args = [{Nft: {const_data: '0x31'}},512        {Nft: {const_data: '0x32'}},513        {Nft: {const_data: '0x33'}}];514515      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);516517      const events = await submitTransactionAsync(alice, createMultipleItemsTx);518      const result = getCreateItemsResult(events);519520      for (const elem of result) {521        await expect(executeTransaction(522          api,523          bob,524          api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]),525        )).to.be.rejected;526      }527    });528  });529530  it('Adding more than 64 prps', async () => {531    await usingApi(async (api: ApiPromise) => {532      const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],533        propPerm:   [{key: 'key1', mutable: true, collectionAdmin: true, tokenOwner: false}]});534      const itemsListIndexBefore = await getLastTokenId(api, collectionId);535      expect(itemsListIndexBefore).to.be.equal(0);536      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);537538      const args = [{Nft: {const_data: '0x31'}},539        {Nft: {const_data: '0x32'}},540        {Nft: {const_data: '0x33'}}];541542      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);543      const events = await submitTransactionAsync(alice, createMultipleItemsTx);544545      const result = getCreateItemsResult(events);546547      const prps = [];548549      for (let i = 0; i < 65; i++) {550        prps.push({key: `key${i}`, value: `value${i}`});551      }552553      await expect(executeTransaction(api, bob, api.tx.unique.setCollectionProperties(collectionId, prps))).to.be.rejectedWith(/common\.PropertyLimitReached/);554555      for (const elem of result) {556        await expect(executeTransaction(557          api,558          bob,559          api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, prps),560        )).to.be.rejected;561      }562    });563  });564565  it('Trying to add bigger property than allowed', async () => {566    await usingApi(async (api: ApiPromise) => {567      const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],568        propPerm:   [{key: 'key1', mutable: true, collectionAdmin: false, tokenOwner: false}]});569      const itemsListIndexBefore = await getLastTokenId(api, collectionId);570      expect(itemsListIndexBefore).to.be.equal(0);571      const args = [{Nft: {const_data: '0x31'}},572        {Nft: {const_data: '0x32'}},573        {Nft: {const_data: '0x33'}}];574575      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);576577      const events = await submitTransactionAsync(alice, createMultipleItemsTx);578      const result = getCreateItemsResult(events);579580581      await expect(executeTransaction(api, alice, api.tx.unique.setCollectionProperties(collectionId, [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]))).to.be.rejectedWith(/common\.NoSpaceForProperty/);582583      for (const elem of result) {584        await expect(executeTransaction(585          api,586          bob,587          api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]),588        )).to.be.rejected;589      }590    });591  });592});
after · tests/src/createMultipleItems.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 {ApiPromise} from '@polkadot/api';18import {IKeyringPair} from '@polkadot/types/types';19import chai from 'chai';20import chaiAsPromised from 'chai-as-promised';21import privateKey from './substrate/privateKey';22import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync, executeTransaction} from './substrate/substrate-api';23import {24  createCollectionExpectSuccess,25  destroyCollectionExpectSuccess,26  getGenericResult,27  normalizeAccountId,28  setCollectionLimitsExpectSuccess,29  addCollectionAdminExpectSuccess,30  getBalance,31  getTokenOwner,32  getLastTokenId,33  getConstMetadata,34  getCreatedCollectionCount,35  createCollectionWithPropsExpectSuccess,36  getCreateItemsResult,37  createMultipleItemsWithPropsExpectSuccess38} from './util/helpers';3940chai.use(chaiAsPromised);41const expect = chai.expect;4243describe('Integration Test createMultipleItems(collection_id, owner, items_data):', () => {44  it('Create  0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {45    await usingApi(async (api: ApiPromise) => {46      const collectionId = await createCollectionExpectSuccess();47      const itemsListIndexBefore = await getLastTokenId(api, collectionId);48      expect(itemsListIndexBefore).to.be.equal(0);49      const alice = privateKey('//Alice');50      const args = [{Nft: {const_data: '0x31'}},51        {Nft: {const_data: '0x32'}},52        {Nft: {const_data: '0x33'}}];53      const createMultipleItemsTx = api.tx.unique54        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);55      await submitTransactionAsync(alice, createMultipleItemsTx);56      const itemsListIndexAfter = await getLastTokenId(api, collectionId);57      expect(itemsListIndexAfter).to.be.equal(3);5859      expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address));60      expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));61      expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));6263      expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);64      expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);65      expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);66    });67  });6869  it('Create  0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {70    await usingApi(async (api: ApiPromise) => {71      const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});72      const itemsListIndexBefore = await getLastTokenId(api, collectionId);73      expect(itemsListIndexBefore).to.be.equal(0);74      const alice = privateKey('//Alice');75      const args = [76        {Fungible: {value: 1}},77        {Fungible: {value: 2}},78        {Fungible: {value: 3}},79      ];80      const createMultipleItemsTx = api.tx.unique81        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);82      await submitTransactionAsync(alice, createMultipleItemsTx);83      const token1Data = await getBalance(api, collectionId, alice.address, 0);8485      expect(token1Data).to.be.equal(6n); // 1 + 2 + 386    });87  });8889  it('Create  0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async () => {90    await usingApi(async (api: ApiPromise) => {91      const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});92      const itemsListIndexBefore = await getLastTokenId(api, collectionId);93      expect(itemsListIndexBefore).to.be.equal(0);94      const alice = privateKey('//Alice');95      const args = [96        {ReFungible: {const_data: [0x31], pieces: 1}},97        {ReFungible: {const_data: [0x32], pieces: 1}},98        {ReFungible: {const_data: [0x33], pieces: 1}},99      ];100      const createMultipleItemsTx = api.tx.unique101        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);102      await submitTransactionAsync(alice, createMultipleItemsTx);103      const itemsListIndexAfter = await getLastTokenId(api, collectionId);104      expect(itemsListIndexAfter).to.be.equal(3);105106      expect(await getBalance(api, collectionId, alice.address, 1)).to.be.equal(1n);107      expect(await getBalance(api, collectionId, alice.address, 2)).to.be.equal(1n);108      expect(await getBalance(api, collectionId, alice.address, 3)).to.be.equal(1n);109110      expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);111      expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);112      expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);113    });114  });115116  it('Can mint amount of items equals to collection limits', async () => {117    await usingApi(async (api) => {118      const alice = privateKey('//Alice');119120      const collectionId = await createCollectionExpectSuccess();121      await setCollectionLimitsExpectSuccess(alice, collectionId, {122        tokenLimit: 2,123      });124      const args = [125        {NFT: {const_data: 'A'}},126        {NFT: {const_data: 'B'}},127      ];128      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);129      const events = await submitTransactionAsync(alice, createMultipleItemsTx);130      const result = getGenericResult(events);131      expect(result.success).to.be.true;132    });133  });134135  it('Create  0x31, 0x32, 0x33 items in active NFT with property Admin', async () => {136    await usingApi(async (api: ApiPromise) => {137      const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});138      const itemsListIndexBefore = await getLastTokenId(api, collectionId);139      expect(itemsListIndexBefore).to.be.equal(0);140      const alice = privateKey('//Alice');141      const bob = privateKey('//Bob');142      const args = [{Nft: {const_data: '0x31', properties: [{key: 'k', value: 'v1'}]}},143        {Nft: {const_data: '0x32', properties: [{key: 'k', value: 'v2'}]}},144        {Nft: {const_data: '0x33', properties: [{key: 'k', value: 'v3'}]}}];145146      await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);147      const itemsListIndexAfter = await getLastTokenId(api, collectionId);148      expect(itemsListIndexAfter).to.be.equal(3);149150      expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address));151      expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));152      expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));153154      expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);155      expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);156      expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);157    });158  });159160  it('Create  0x31, 0x32, 0x33 items in active NFT with property AdminConst', async () => {161    await usingApi(async (api: ApiPromise) => {162      const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]});163      const itemsListIndexBefore = await getLastTokenId(api, collectionId);164      expect(itemsListIndexBefore).to.be.equal(0);165      const alice = privateKey('//Alice');166      const bob = privateKey('//Bob');167      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);168      const args = [{Nft: {const_data: '0x31', properties: [{key: 'k', value: 'v1'}]}},169        {Nft: {const_data: '0x32', properties: [{key: 'k', value: 'v2'}]}},170        {Nft: {const_data: '0x33', properties: [{key: 'k', value: 'v3'}]}}];171172      await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);173      const itemsListIndexAfter = await getLastTokenId(api, collectionId);174      expect(itemsListIndexAfter).to.be.equal(3);175176      expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address));177      expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));178      expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));179180      expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);181      expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);182      expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);183    });184  });185186  it('Create  0x31, 0x32, 0x33 items in active NFT with property itemOwnerOrAdmin', async () => {187    await usingApi(async (api: ApiPromise) => {188      const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});189      const itemsListIndexBefore = await getLastTokenId(api, collectionId);190      expect(itemsListIndexBefore).to.be.equal(0);191      const alice = privateKey('//Alice');192      const bob = privateKey('//Bob');193      const args = [{Nft: {const_data: '0x31', properties: [{key: 'k', value: 'v1'}]}},194        {Nft: {const_data: '0x32', properties: [{key: 'k', value: 'v2'}]}},195        {Nft: {const_data: '0x33', properties: [{key: 'k', value: 'v3'}]}}];196197      await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);198      const itemsListIndexAfter = await getLastTokenId(api, collectionId);199      expect(itemsListIndexAfter).to.be.equal(3);200201      expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address));202      expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));203      expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));204205      expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);206      expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);207      expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);208    });209  });210});211212describe('Integration Test createMultipleItems(collection_id, owner, items_data) with collection admin permissions:', () => {213214  let alice: IKeyringPair;215  let bob: IKeyringPair;216217  before(async () => {218    await usingApi(async () => {219      alice = privateKey('//Alice');220      bob = privateKey('//Bob');221    });222  });223224  it('Create  0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {225    await usingApi(async (api: ApiPromise) => {226      const collectionId = await createCollectionExpectSuccess();227      const itemsListIndexBefore = await getLastTokenId(api, collectionId);228      expect(itemsListIndexBefore).to.be.equal(0);229      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);230      const args = [{Nft: {const_data: '0x31'}},231        {Nft: {const_data: '0x32'}},232        {Nft: {const_data: '0x33'}}];233      const createMultipleItemsTx = api.tx.unique234        .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);235      await submitTransactionAsync(bob, createMultipleItemsTx);236      const itemsListIndexAfter = await getLastTokenId(api, collectionId);237      expect(itemsListIndexAfter).to.be.equal(3);238239      expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(bob.address));240      expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(bob.address));241      expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(bob.address));242243      expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);244      expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);245      expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);246    });247  });248249  it('Create  0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {250    await usingApi(async (api: ApiPromise) => {251      const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});252      const itemsListIndexBefore = await getLastTokenId(api, collectionId);253      expect(itemsListIndexBefore).to.be.equal(0);254      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);255      const args = [256        {Fungible: {value: 1}},257        {Fungible: {value: 2}},258        {Fungible: {value: 3}},259      ];260      const createMultipleItemsTx = api.tx.unique261        .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);262      await submitTransactionAsync(bob, createMultipleItemsTx);263      const token1Data = await getBalance(api, collectionId, bob.address, 0);264265      expect(token1Data).to.be.equal(6n); // 1 + 2 + 3266    });267  });268269  it('Create  0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async () => {270    await usingApi(async (api: ApiPromise) => {271      const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});272      const itemsListIndexBefore = await getLastTokenId(api, collectionId);273      expect(itemsListIndexBefore).to.be.equal(0);274      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);275      const args = [276        {ReFungible: {const_data: [0x31], pieces: 1}},277        {ReFungible: {const_data: [0x32], pieces: 1}},278        {ReFungible: {const_data: [0x33], pieces: 1}},279      ];280      const createMultipleItemsTx = api.tx.unique281        .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);282      await submitTransactionAsync(bob, createMultipleItemsTx);283      const itemsListIndexAfter = await getLastTokenId(api, collectionId);284      expect(itemsListIndexAfter).to.be.equal(3);285286      expect(await getBalance(api, collectionId, bob.address, 1)).to.be.equal(1n);287      expect(await getBalance(api, collectionId, bob.address, 2)).to.be.equal(1n);288      expect(await getBalance(api, collectionId, bob.address, 3)).to.be.equal(1n);289290      expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);291      expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);292      expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);293    });294  });295});296297describe('Negative Integration Test createMultipleItems(collection_id, owner, items_data):', () => {298299  let alice: IKeyringPair;300  let bob: IKeyringPair;301302  before(async () => {303    await usingApi(async () => {304      alice = privateKey('//Alice');305      bob = privateKey('//Bob');306    });307  });308309  it('Regular user cannot create items in active NFT collection', async () => {310    await usingApi(async (api: ApiPromise) => {311      const collectionId = await createCollectionExpectSuccess();312      const itemsListIndexBefore = await getLastTokenId(api, collectionId);313      expect(itemsListIndexBefore).to.be.equal(0);314      const args = [{Nft: {const_data: '0x31'}},315        {Nft: {const_data: '0x32'}},316        {Nft: {const_data: '0x33'}}];317      const createMultipleItemsTx = api.tx.unique318        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);319      await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;320    });321  });322323  it('Regular user cannot create items in active Fungible collection', async () => {324    await usingApi(async (api: ApiPromise) => {325      const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});326      const itemsListIndexBefore = await getLastTokenId(api, collectionId);327      expect(itemsListIndexBefore).to.be.equal(0);328      const args = [329        {Fungible: {value: 1}},330        {Fungible: {value: 2}},331        {Fungible: {value: 3}},332      ];333      const createMultipleItemsTx = api.tx.unique334        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);335      await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;336    });337  });338339  it('Regular user cannot create items in active ReFungible collection', async () => {340    await usingApi(async (api: ApiPromise) => {341      const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});342      const itemsListIndexBefore = await getLastTokenId(api, collectionId);343      expect(itemsListIndexBefore).to.be.equal(0);344      const args = [345        {ReFungible: {const_data: [0x31], pieces: 1}},346        {ReFungible: {const_data: [0x32], pieces: 1}},347        {ReFungible: {const_data: [0x33], pieces: 1}},348      ];349      const createMultipleItemsTx = api.tx.unique350        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);351      await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;352    });353  });354355  it('Create token in not existing collection', async () => {356    await usingApi(async (api: ApiPromise) => {357      const collectionId = await getCreatedCollectionCount(api) + 1;358      const createMultipleItemsTx = api.tx.unique359        .createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'NFT', 'NFT']);360      await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;361    });362  });363364  it('Create NFT and Re-fungible tokens that has reached the maximum data limit', async () => {365    await usingApi(async (api: ApiPromise) => {366      // NFT367      const collectionId = await createCollectionExpectSuccess();368      const alice = privateKey('//Alice');369      const args = [370        {NFT: {const_data: 'A'.repeat(2049)}},371        {NFT: {const_data: 'B'.repeat(2049)}},372        {NFT: {const_data: 'C'.repeat(2049)}},373      ];374      const createMultipleItemsTx = api.tx.unique375        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);376      await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;377378      // ReFungible379      const collectionIdReFungible =380        await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});381      const argsReFungible = [382        {ReFungible: ['1'.repeat(2049), 10]},383        {ReFungible: ['2'.repeat(2049), 10]},384        {ReFungible: ['3'.repeat(2049), 10]},385      ];386      const createMultipleItemsTxFungible = api.tx.unique387        .createMultipleItems(collectionIdReFungible, normalizeAccountId(alice.address), argsReFungible);388      await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTxFungible)).to.be.rejected;389    });390  });391392  it('Create tokens with different types', async () => {393    await usingApi(async (api: ApiPromise) => {394      const collectionId = await createCollectionExpectSuccess();395      const createMultipleItemsTx = api.tx.unique396        .createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'Fungible', 'ReFungible']);397      await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;398      // garbage collection :-D399      await destroyCollectionExpectSuccess(collectionId);400    });401  });402403  it('Create tokens with different data limits <> maximum data limit', async () => {404    await usingApi(async (api: ApiPromise) => {405      const collectionId = await createCollectionExpectSuccess();406      const args = [407        {NFT: {const_data: 'A'}},408        {NFT: {const_data: 'B'.repeat(2049)}},409      ];410      const createMultipleItemsTx = await api.tx.unique411        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);412      await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;413    });414  });415416  it('Fails when minting tokens exceeds collectionLimits amount', async () => {417    await usingApi(async (api) => {418419      const collectionId = await createCollectionExpectSuccess();420      await setCollectionLimitsExpectSuccess(alice, collectionId, {421        tokenLimit: 1,422      });423      const args = [424        {NFT: {const_data: 'A'}},425        {NFT: {const_data: 'B'}},426      ];427      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);428      await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;429    });430  });431432  it('No editing rights', async () => {433    await usingApi(async (api: ApiPromise) => {434      const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],435        propPerm:   [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});436      const itemsListIndexBefore = await getLastTokenId(api, collectionId);437      expect(itemsListIndexBefore).to.be.equal(0);438      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);439      const args = [{Nft: {const_data: '0x31'}},440        {Nft: {const_data: '0x32'}},441        {Nft: {const_data: '0x33'}}];442443      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);444445      const events = await submitTransactionAsync(alice, createMultipleItemsTx);446      const result = getCreateItemsResult(events);447448      for (const elem of result) {449        await expect(executeTransaction(450          api,451          bob,452          api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]),453        )).to.be.rejected;454      }455456      // await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;457    });458  });459460  it('User doesnt have editing rights', async () => {461    await usingApi(async (api: ApiPromise) => {462      const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],463        propPerm:   [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});464      const itemsListIndexBefore = await getLastTokenId(api, collectionId);465      expect(itemsListIndexBefore).to.be.equal(0);466      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);467      const args = [{Nft: {const_data: '0x31'}},468        {Nft: {const_data: '0x32'}},469        {Nft: {const_data: '0x33'}}];470471      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);472473      const events = await submitTransactionAsync(alice, createMultipleItemsTx);474      const result = getCreateItemsResult(events);475476      for (const elem of result) {477        await expect(executeTransaction(478          api,479          bob,480          api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]),481        )).to.be.rejected;482      }483    });484  });485486  it('Adding property without access rights', async () => {487    await usingApi(async (api: ApiPromise) => {488      const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}]});489      const itemsListIndexBefore = await getLastTokenId(api, collectionId);490      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);491      expect(itemsListIndexBefore).to.be.equal(0);492      const args = [{Nft: {const_data: '0x31'}},493        {Nft: {const_data: '0x32'}},494        {Nft: {const_data: '0x33'}}];495496      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);497498      const events = await submitTransactionAsync(alice, createMultipleItemsTx);499      const result = getCreateItemsResult(events);500501      for (const elem of result) {502        await expect(executeTransaction(503          api,504          bob,505          api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'key1', value: 'v2'}]),506        )).to.be.rejected;507      }508    });509  });510511  it('Adding more than 64 prps', async () => {512    await usingApi(async (api: ApiPromise) => {513      const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],514        propPerm:   [{key: 'key1', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});515      const itemsListIndexBefore = await getLastTokenId(api, collectionId);516      expect(itemsListIndexBefore).to.be.equal(0);517      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);518519      const args = [{Nft: {const_data: '0x31'}},520        {Nft: {const_data: '0x32'}},521        {Nft: {const_data: '0x33'}}];522523      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);524      const events = await submitTransactionAsync(alice, createMultipleItemsTx);525526      const result = getCreateItemsResult(events);527528      const prps = [];529530      for (let i = 0; i < 65; i++) {531        prps.push({key: `key${i}`, value: `value${i}`});532      }533534      await expect(executeTransaction(api, bob, api.tx.unique.setCollectionProperties(collectionId, prps))).to.be.rejectedWith(/common\.PropertyLimitReached/);535536      for (const elem of result) {537        await expect(executeTransaction(538          api,539          bob,540          api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, prps),541        )).to.be.rejected;542      }543    });544  });545546  it('Trying to add bigger property than allowed', async () => {547    await usingApi(async (api: ApiPromise) => {548      const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],549        propPerm:   [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});550      const itemsListIndexBefore = await getLastTokenId(api, collectionId);551      expect(itemsListIndexBefore).to.be.equal(0);552      const args = [{Nft: {const_data: '0x31'}},553        {Nft: {const_data: '0x32'}},554        {Nft: {const_data: '0x33'}}];555556      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);557558      const events = await submitTransactionAsync(alice, createMultipleItemsTx);559      const result = getCreateItemsResult(events);560561562      await expect(executeTransaction(api, alice, api.tx.unique.setCollectionProperties(collectionId, [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]))).to.be.rejectedWith(/common\.NoSpaceForProperty/);563564      for (const elem of result) {565        await expect(executeTransaction(566          api,567          bob,568          api.tx.unique.setTokenProperties(elem.collectionId, elem.itemId, [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]),569        )).to.be.rejected;570      }571    });572  });573});
modifiedtests/src/createMultipleItemsEx.test.tsdiffbeforeafterboth
--- a/tests/src/createMultipleItemsEx.test.ts
+++ b/tests/src/createMultipleItemsEx.test.ts
@@ -48,8 +48,8 @@
     });
   });
 
-  it('createMultipleItemsEx with property Admin', async () => {
-    const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+  it.only('createMultipleItemsEx with property Admin', async () => {
+    const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});
     const alice = privateKey('//Alice');
     const bob = privateKey('//Bob');
     const charlie = privateKey('//Charlie');
@@ -57,33 +57,30 @@
       const data = [
         {
           owner: {substrate: alice.address},
-          constData: '0x0000',
+          constData: '0x1111',
+          properties: [{key: 'k', value: 'v1'}],
         }, {
           owner: {substrate: bob.address},
           constData: '0x2222',
+          properties: [{key: 'k', value: 'v2'}],
         }, {
           owner: {substrate: charlie.address},
           constData: '0x4444',
+          properties: [{key: 'k', value: 'v3'}],
         },
       ];
-
-      await expect(executeTransaction(
-        api,
-        alice,
-        api.tx.unique.setPropertyPermissions(collection, [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]),
-      )).to.not.be.rejected;
 
       await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {
         NFT: data,
       }));
-      const tokens = await api.query.nonfungible.tokenData.entries(collection);
-      const json = tokens.map(([, token]) => token.toJSON());
-      expect(json).to.be.deep.equal(data);
+      for (let i = 1; i < 4; i++) {
+        expect(await api.rpc.unique.tokenProperties(collection, i)).not.to.be.empty;
+      }
     });
   });
 
   it('createMultipleItemsEx with property AdminConst', async () => {
-    const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+    const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]});
     const alice = privateKey('//Alice');
     const bob = privateKey('//Bob');
     const charlie = privateKey('//Charlie');
@@ -92,33 +89,29 @@
         {
           owner: {substrate: alice.address},
           constData: '0x0000',
+          properties: [{key: 'k', value: 'v1'}],
         }, {
           owner: {substrate: bob.address},
           constData: '0x2222',
+          properties: [{key: 'k', value: 'v2'}],
         }, {
           owner: {substrate: charlie.address},
           constData: '0x4444',
+          properties: [{key: 'k', value: 'v3'}],
         },
       ];
-      await expect(executeTransaction(
-        api,
-        alice,
-        api.tx.unique.setPropertyPermissions(collection, [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]),
-      )).to.not.be.rejected;
 
       await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {
         NFT: data,
       }));
-
-
-      const tokens = await api.query.nonfungible.tokenData.entries(collection);
-      const json = tokens.map(([, token]) => token.toJSON());
-      expect(json).to.be.deep.equal(data);
+      for (let i = 1; i < 4; i++) {
+        expect(await api.rpc.unique.tokenProperties(collection, i)).not.to.be.empty;
+      }
     });
   });
 
   it('createMultipleItemsEx with property itemOwnerOrAdmin', async () => {
-    const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+    const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: true}}]});
     const alice = privateKey('//Alice');
     const bob = privateKey('//Bob');
     const charlie = privateKey('//Charlie');
@@ -127,34 +120,30 @@
         {
           owner: {substrate: alice.address},
           constData: '0x0000',
+          properties: [{key: 'k', value: 'v1'}],
         }, {
           owner: {substrate: bob.address},
           constData: '0x2222',
+          properties: [{key: 'k', value: 'v2'}],
         }, {
           owner: {substrate: charlie.address},
           constData: '0x4444',
+          properties: [{key: 'k', value: 'v3'}],
         },
       ];
-      await expect(executeTransaction(
-        api,
-        alice,
-        api.tx.unique.setPropertyPermissions(collection, [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]),
-      )).to.not.be.rejected;
 
       await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {
         NFT: data,
       }));
-
-
-      const tokens = await api.query.nonfungible.tokenData.entries(collection);
-      const json = tokens.map(([, token]) => token.toJSON());
-      expect(json).to.be.deep.equal(data);
+      for (let i = 1; i < 4; i++) {
+        expect(await api.rpc.unique.tokenProperties(collection, i)).not.to.be.empty;
+      }
     });
   });
 
   it('No editing rights', async () => {
     const collection = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],
-      propPerm:   [{key: 'key1', mutable: true, collectionAdmin: false, tokenOwner: false}]});
+      propPerm:   [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});
     const alice = privateKey('//Alice');
     const bob = privateKey('//Bob');
     const charlie = privateKey('//Charlie');
@@ -188,7 +177,7 @@
 
   it('User doesnt have editing rights', async () => {
     const collection = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],
-      propPerm:   [{key: 'key1', mutable: false, collectionAdmin: false, tokenOwner: false}]});
+      propPerm:   [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});
     const alice = privateKey('//Alice');
     const bob = privateKey('//Bob');
     const charlie = privateKey('//Charlie');
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -27,7 +27,7 @@
 import privateKey from '../substrate/privateKey';
 import {default as usingApi, executeTransaction, submitTransactionAsync, submitTransactionExpectFailAsync} from '../substrate/substrate-api';
 import {hexToStr, strToUTF16, utf16ToStr} from './util';
-import {UpDataStructsRpcCollection} from '@polkadot/types/lookup';
+import {UpDataStructsRpcCollection, UpDataStructsCreateItemData} from '@polkadot/types/lookup';
 
 chai.use(chaiAsPromised);
 const expect = chai.expect;
@@ -295,13 +295,17 @@
   value: any,
 };
 
-type PropertyPermission = {
-  key: any,
+type Permission = {
   mutable: boolean;
   collectionAdmin: boolean;
   tokenOwner: boolean;
 }
 
+type PropertyPermission = {
+  key: any;
+  permission: Permission;
+}
+
 export type CreateCollectionParams = {
   mode: CollectionMode,
   name: string,
@@ -1123,6 +1127,65 @@
   });
 }
 
+export async function createMultipleItemsWithPropsExpectSuccess(sender: IKeyringPair, collectionId: number, itemsData: any, owner: CrossAccountId | string = sender.address) {
+  await usingApi(async (api) => {
+    const to = normalizeAccountId(owner);
+    const tx = api.tx.unique.createMultipleItems(collectionId, to, itemsData);
+
+    const events = await submitTransactionAsync(sender, tx);
+    const result = getCreateItemsResult(events);
+
+    for (let res of result) {
+      expect(await api.rpc.unique.tokenProperties(collectionId, res.itemId)).not.to.be.empty;
+    }
+  });
+}
+
+export async function createItemWithPropsExpectSuccess(sender: IKeyringPair, collectionId: number, createMode: string, props:  Array<Property>, owner: CrossAccountId | string = sender.address) {
+  let newItemId = 0;
+  await usingApi(async (api) => {
+    const to = normalizeAccountId(owner);
+    const itemCountBefore = await getLastTokenId(api, collectionId);
+    const itemBalanceBefore = await getBalance(api, collectionId, to, newItemId);
+
+    let tx;
+    if (createMode === 'Fungible') {
+      const createData = {fungible: {value: 10}};
+      tx = api.tx.unique.createItem(collectionId, to, createData as any);
+    } else if (createMode === 'ReFungible') {
+      const createData = {refungible: {const_data: [], pieces: 100}};
+      tx = api.tx.unique.createItem(collectionId, to, createData as any);
+    } else {
+      const data = api.createType('UpDataStructsCreateItemData', { NFT: { constData: 'test', properties: props}});
+      tx = api.tx.unique.createItem(collectionId, to, data as UpDataStructsCreateItemData);
+    }
+
+    const events = await submitTransactionAsync(sender, tx);
+    const result = getCreateItemResult(events);
+
+    const itemCountAfter = await getLastTokenId(api, collectionId);
+    const itemBalanceAfter = await getBalance(api, collectionId, to, newItemId);
+
+    if (createMode === 'NFT') {
+      expect(await api.rpc.unique.tokenProperties(collectionId, result.itemId)).not.to.be.empty;
+    }
+
+    // What to expect
+    // tslint:disable-next-line:no-unused-expression
+    expect(result.success).to.be.true;
+    if (createMode === 'Fungible') {
+      expect(itemBalanceAfter - itemBalanceBefore).to.be.equal(10n);
+    } else {
+      expect(itemCountAfter).to.be.equal(itemCountBefore + 1);
+    }
+    expect(collectionId).to.be.equal(result.collectionId);
+    expect(itemCountAfter.toString()).to.be.equal(result.itemId.toString());
+    expect(to).to.be.deep.equal(result.recipient);
+    newItemId = result.itemId;
+  });
+  return newItemId;
+}
+
 export async function createItemExpectSuccess(sender: IKeyringPair, collectionId: number, createMode: string, owner: CrossAccountId | string = sender.address) {
   let newItemId = 0;
   await usingApi(async (api) => {