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

difftreelog

tests(repair): displace sudo tests into seqtests

Fahrrader2022-12-16parent: #2a4f1af.patch.diff
in: master

5 files changed

modifiedtests/package.jsondiffbeforeafterboth
--- a/tests/package.json
+++ b/tests/package.json
@@ -44,9 +44,9 @@
     "testEvmCoder": "mocha --timeout 9999999 -r ts-node/register './**/eth/evmCoder.test.ts'",
     "testNesting": "mocha --timeout 9999999 -r ts-node/register ./**/nest.test.ts",
     "testUnnesting": "mocha --timeout 9999999 -r ts-node/register ./**/unnest.test.ts",
-    "testProperties": "mocha --timeout 9999999 -r ts-node/register ./**/collectionProperties.test.ts ./**/tokenProperties.test.ts ./**/getPropertiesRpc.test.ts",
-    "testCollectionProperties": "mocha --timeout 9999999 -r ts-node/register ./**/collectionProperties.test.ts",
-    "testTokenProperties": "mocha --timeout 9999999 -r ts-node/register ./**/tokenProperties.test.ts",
+    "testProperties": "mocha --timeout 9999999 -r ts-node/register ./**/collectionProperties.*test.ts ./**/tokenProperties.*test.ts ./**/getPropertiesRpc.test.ts",
+    "testCollectionProperties": "mocha --timeout 9999999 -r ts-node/register ./**/collectionProperties.*test.ts",
+    "testTokenProperties": "mocha --timeout 9999999 -r ts-node/register ./**/tokenProperties.*test.ts",
     "testMigration": "mocha --timeout 9999999 -r ts-node/register ./**/nesting/migration-check.test.ts",
     "testAddCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/addCollectionAdmin.test.ts",
     "testSetCollectionLimits": "mocha --timeout 9999999 -r ts-node/register ./**/setCollectionLimits.test.ts",
addedtests/src/nesting/collectionProperties.seqtest.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/nesting/collectionProperties.seqtest.ts
@@ -0,0 +1,61 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+import {IKeyringPair} from '@polkadot/types/types';
+import {itSub, Pallets, usingPlaygrounds, expect, requirePalletsOrSkip} from '../util';
+
+describe('Integration Test: Collection Properties', () => {
+  let superuser: IKeyringPair;
+  let alice: IKeyringPair;
+  
+  before(async () => {
+    await usingPlaygrounds(async (helper, privateKey) => {
+      superuser = await privateKey('//Alice');
+      const donor = await privateKey({filename: __filename});
+      [alice] = await helper.arrange.createAccounts([100n], donor);
+    });
+  });
+
+  [
+    {mode: 'nft' as const, requiredPallets: []},
+    {mode: 'ft' as const, requiredPallets: []},
+    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]}, 
+  ].map(testSuite => describe(`${testSuite.mode.toUpperCase()}`, () => {
+    before(async function() {
+      // eslint-disable-next-line require-await
+      await usingPlaygrounds(async helper => {
+        requirePalletsOrSkip(this, helper, testSuite.requiredPallets);
+      });
+    });
+    
+    itSub('Repairing an unbroken collection\'s properties preserves the consumed space', async({helper}) => {
+      const properties = [
+        {key: 'sea-creatures', value: 'mermaids'},
+        {key: 'goldenratio', value: '1.6180339887498948482045868343656381177203091798057628621354486227052604628189'},
+      ];
+      const collection = await helper[testSuite.mode].mintCollection(alice, {properties});
+
+      const newProperty = ' '.repeat(4096);
+      await collection.setProperties(alice, [{key: 'space', value: newProperty}]);
+      const originalSpace = await collection.getPropertiesConsumedSpace();
+      expect(originalSpace).to.be.equal(properties[0].value.length + properties[1].value.length + newProperty.length);
+
+      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.unique.forceRepairCollection', [collection.collectionId], true);
+      const recomputedSpace = await collection.getPropertiesConsumedSpace();
+      expect(recomputedSpace).to.be.equal(originalSpace);
+    });
+  }));
+});
\ No newline at end of file
modifiedtests/src/nesting/collectionProperties.test.tsdiffbeforeafterboth
before · tests/src/nesting/collectionProperties.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 {IKeyringPair} from '@polkadot/types/types';18import {itSub, Pallets, usingPlaygrounds, expect, requirePalletsOrSkip} from '../util';1920describe('Integration Test: Collection Properties', () => {21  let superuser: IKeyringPair;22  let alice: IKeyringPair;23  let bob: IKeyringPair;24  25  before(async () => {26    await usingPlaygrounds(async (helper, privateKey) => {27      superuser = await privateKey('//Alice');28      const donor = await privateKey({filename: __filename});29      [alice, bob] = await helper.arrange.createAccounts([200n, 10n], donor);30    });31  });32  33  itSub('Properties are initially empty', async ({helper}) => {34    const collection = await helper.nft.mintCollection(alice);35    expect(await collection.getProperties()).to.be.empty;36  });3738  [39    {mode: 'nft' as const, requiredPallets: []},40    {mode: 'ft' as const, requiredPallets: []},41    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]}, 42  ].map(testSuite => describe(`${testSuite.mode.toUpperCase()}`, () => {43    before(async function() {44      // eslint-disable-next-line require-await45      await usingPlaygrounds(async helper => {46        requirePalletsOrSkip(this, helper, testSuite.requiredPallets);47      });48    });4950    itSub('Sets properties for a collection', async ({helper}) =>  {51      const collection = await helper[testSuite.mode].mintCollection(alice);5253      // As owner54      await expect(collection.setProperties(alice, [{key: 'electron', value: 'come bond'}])).to.be.fulfilled;55    56      await collection.addAdmin(alice, {Substrate: bob.address});57    58      // As administrator59      await expect(collection.setProperties(bob, [{key: 'black_hole'}])).to.be.fulfilled;60    61      const properties = await collection.getProperties();62      expect(properties).to.include.deep.members([63        {key: 'electron', value: 'come bond'},64        {key: 'black_hole', value: ''},65      ]);66    });67    68    itSub('Check valid names for collection properties keys', async ({helper}) =>  {69      const collection = await helper[testSuite.mode].mintCollection(alice);7071      // alpha symbols72      await expect(collection.setProperties(alice, [{key: 'answer'}])).to.be.fulfilled;73    74      // numeric symbols75      await expect(collection.setProperties(alice, [{key: '451'}])).to.be.fulfilled;76    77      // underscore symbol78      await expect(collection.setProperties(alice, [{key: 'black_hole'}])).to.be.fulfilled;79    80      // dash symbol81      await expect(collection.setProperties(alice, [{key: '-'}])).to.be.fulfilled;82    83      // dot symbol84      await expect(collection.setProperties(alice, [{key: 'once.in.a.long.long.while...', value: 'you get a little lost'}])).to.be.fulfilled;85    86      const properties = await collection.getProperties();87      expect(properties).to.include.deep.members([88        {key: 'answer', value: ''},89        {key: '451', value: ''},90        {key: 'black_hole', value: ''},91        {key: '-', value: ''},92        {key: 'once.in.a.long.long.while...', value: 'you get a little lost'},93      ]);94    });95  96    itSub('Changes properties of a collection', async ({helper}) =>  {97      const collection = await helper[testSuite.mode].mintCollection(alice);9899      await expect(collection.setProperties(alice, [{key: 'electron', value: 'come bond'}, {key: 'black_hole', value: ''}])).to.be.fulfilled;100    101      // Mutate the properties102      await expect(collection.setProperties(alice, [{key: 'black_hole', value: 'LIGO'}])).to.be.fulfilled;103    104      const properties = await collection.getProperties();105      expect(properties).to.include.deep.members([106        {key: 'electron', value: 'come bond'},107        {key: 'black_hole', value: 'LIGO'},108      ]);109    });110  111    itSub('Deletes properties of a collection', async ({helper}) =>  {112      const collection = await helper[testSuite.mode].mintCollection(alice);113114      await expect(collection.setProperties(alice, [{key: 'electron', value: 'come bond'}, {key: 'black_hole', value: 'LIGO'}])).to.be.fulfilled;115    116      await expect(collection.deleteProperties(alice, ['electron'])).to.be.fulfilled;117    118      const properties = await collection.getProperties(['black_hole', 'electron']);119      expect(properties).to.be.deep.equal([120        {key: 'black_hole', value: 'LIGO'},121      ]);122    });123124    itSub('Allows modifying a collection property multiple times with the same size', async({helper}) => {125      const propKey = 'tok-prop';126127      const collection = await helper[testSuite.mode].mintCollection(alice);128129      const maxCollectionPropertiesSize = 40960;130131      const propDataSize = 4096;132133      let propDataChar = 'a';134      const makeNewPropData = () => {135        propDataChar = String.fromCharCode(propDataChar.charCodeAt(0) + 1);136        return `${propDataChar}`.repeat(propDataSize);137      };138139      await collection.setProperties(alice, [{key: propKey, value: makeNewPropData()}]);140      const originalSpace = await collection.getPropertiesConsumedSpace();141      expect(originalSpace).to.be.equal(propDataSize);142143      const sameSizePropertiesPossibleNum = maxCollectionPropertiesSize / propDataSize;144145      // It is possible to modify a property as many times as needed.146      // It will not consume any additional space.147      for (let i = 0; i < sameSizePropertiesPossibleNum + 1; i++) {148        await collection.setProperties(alice, [{key: propKey, value: makeNewPropData()}]);149        const consumedSpace = await collection.getPropertiesConsumedSpace();150        expect(consumedSpace).to.be.equal(originalSpace);151      }152    });153154    itSub('Adding then removing a collection property doesn\'t change the consumed space', async({helper}) => {155      const propKey = 'tok-prop';156157      const collection = await helper[testSuite.mode].mintCollection(alice);158      const originalSpace = await collection.getPropertiesConsumedSpace();159160      const propDataSize = 4096;161      const propData = 'a'.repeat(propDataSize);162163      await collection.setProperties(alice, [{key: propKey, value: propData}]);164      let consumedSpace = await collection.getPropertiesConsumedSpace();165      expect(consumedSpace).to.be.equal(propDataSize);166167      await collection.deleteProperties(alice, [propKey]);168      consumedSpace = await collection.getPropertiesConsumedSpace();169      expect(consumedSpace).to.be.equal(originalSpace);170    });171172    itSub('Modifying a collection property with different sizes correctly changes the consumed space', async({helper}) => {173      const propKey = 'tok-prop';174175      const collection = await helper[testSuite.mode].mintCollection(alice);176      const originalSpace = await collection.getPropertiesConsumedSpace();177178      const initPropDataSize = 4096;179      const biggerPropDataSize = 5000;180      const smallerPropDataSize = 4000;181182      const initPropData = 'a'.repeat(initPropDataSize);183      const biggerPropData = 'b'.repeat(biggerPropDataSize);184      const smallerPropData = 'c'.repeat(smallerPropDataSize);185186      let consumedSpace;187      let expectedConsumedSpaceDiff;188189      await collection.setProperties(alice, [{key: propKey, value: initPropData}]);190      consumedSpace = await collection.getPropertiesConsumedSpace();191      expectedConsumedSpaceDiff = initPropDataSize - originalSpace;192      expect(consumedSpace).to.be.equal(originalSpace + expectedConsumedSpaceDiff);193194      await collection.setProperties(alice, [{key: propKey, value: biggerPropData}]);195      consumedSpace = await collection.getPropertiesConsumedSpace();196      expectedConsumedSpaceDiff = biggerPropDataSize - initPropDataSize;197      expect(consumedSpace).to.be.equal(initPropDataSize + expectedConsumedSpaceDiff);198199      await collection.setProperties(alice, [{key: propKey, value: smallerPropData}]);200      consumedSpace = await collection.getPropertiesConsumedSpace();201      expectedConsumedSpaceDiff = biggerPropDataSize - smallerPropDataSize;202      expect(consumedSpace).to.be.equal(biggerPropDataSize - expectedConsumedSpaceDiff);203    });204205    itSub('Modifying a collection property with different sizes correctly changes the consumed space', async({helper}) => {206      const properties = [207        {key: 'sea-creatures', value: 'mermaids'},208        {key: 'goldenratio', value: '1.6180339887498948482045868343656381177203091798057628621354486227052604628189'},209      ];210      const collection = await helper[testSuite.mode].mintCollection(alice, {properties});211212      const newProperty = ' '.repeat(4096);213      await collection.setProperties(alice, [{key: 'space', value: newProperty}]);214      const originalSpace = await collection.getPropertiesConsumedSpace();215      expect(originalSpace).to.be.equal(properties[0].value.length + properties[1].value.length + newProperty.length);216217      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.unique.forceRepairCollection', [collection.collectionId], true);218      const recomputedSpace = await collection.getPropertiesConsumedSpace();219      expect(recomputedSpace).to.be.equal(originalSpace);220    });221  }));222});223  224describe('Negative Integration Test: Collection Properties', () => {225  let alice: IKeyringPair;226  let bob: IKeyringPair;227  228  before(async () => {229    await usingPlaygrounds(async (helper, privateKey) => {230      const donor = await privateKey({filename: __filename});231      [alice, bob] = await helper.arrange.createAccounts([100n, 10n], donor);232    });233  });234235  [236    {mode: 'nft' as const, requiredPallets: []},237    {mode: 'ft' as const, requiredPallets: []},238    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]}, 239  ].map(testSuite => describe(`${testSuite.mode.toUpperCase()}`, () => {240    before(async function() {241      // eslint-disable-next-line require-await242      await usingPlaygrounds(async helper => {243        requirePalletsOrSkip(this, helper, testSuite.requiredPallets);244      });245    });246    247    itSub('Fails to set properties in a collection if not its onwer/administrator', async ({helper}) =>  {248      const collection = await helper[testSuite.mode].mintCollection(alice);249250      await expect(collection.setProperties(bob, [{key: 'electron', value: 'come bond'}, {key: 'black_hole', value: 'LIGO'}]))251        .to.be.rejectedWith(/common\.NoPermission/);252    253      expect(await collection.getProperties()).to.be.empty;254    });255    256    itSub('Fails to set properties that exceed the limits', async ({helper}) =>  {257      const collection = await helper[testSuite.mode].mintCollection(alice);258259      const spaceLimit = (await (collection.helper!.api! as any).query.common.collectionProperties(collection.collectionId)).spaceLimit.toNumber();260      261      // Mute the general tx parsing error, too many bytes to process262      {263        console.error = () => {};264        await expect(collection.setProperties(alice, [265          {key: 'electron', value: 'low high '.repeat(Math.ceil(spaceLimit! / 9))},266        ])).to.be.rejected;267      }268    269      expect(await collection.getProperties(['electron'])).to.be.empty;270    271      await expect(collection.setProperties(alice, [272        {key: 'electron', value: 'low high '.repeat(Math.ceil(spaceLimit! / 18))}, 273        {key: 'black_hole', value: '0'.repeat(Math.ceil(spaceLimit! / 2))}, 274      ])).to.be.rejectedWith(/common\.NoSpaceForProperty/);275    276      expect(await collection.getProperties(['electron', 'black_hole'])).to.be.empty;277    });278    279    itSub('Fails to set more properties than it is allowed', async ({helper}) =>  {280      const collection = await helper[testSuite.mode].mintCollection(alice);281282      const propertiesToBeSet = [];283      for (let i = 0; i < 65; i++) {284        propertiesToBeSet.push({285          key: 'electron_' + i,286          value: Math.random() > 0.5 ? 'high' : 'low',287        });288      }289    290      await expect(collection.setProperties(alice, propertiesToBeSet)).291        to.be.rejectedWith(/common\.PropertyLimitReached/);292    293      expect(await collection.getProperties()).to.be.empty;294    });295296    itSub('Fails to set properties with invalid names', async ({helper}) => {297      const collection = await helper[testSuite.mode].mintCollection(alice);298299      const invalidProperties = [300        [{key: 'electron', value: 'negative'}, {key: 'string theory', value: 'understandable'}],301        [{key: 'Mr/Sandman', value: 'Bring me a gene'}],302        [{key: 'déjà vu', value: 'hmm...'}],303      ];304    305      for (let i = 0; i < invalidProperties.length; i++) {306        await expect(307          collection.setProperties(alice, invalidProperties[i]), 308          `on rejecting the new badly-named property #${i}`,309        ).to.be.rejectedWith(/common\.InvalidCharacterInPropertyKey/);310      }311    312      await expect(313        collection.setProperties(alice, [{key: '', value: 'nothing must not exist'}]), 314        'on rejecting an unnamed property',315      ).to.be.rejectedWith(/common\.EmptyPropertyKey/);316    317      await expect(318        collection.setProperties(alice, [{key: 'CRISPR-Cas9', value: 'rewriting nature!'}]), 319        'on setting the correctly-but-still-badly-named property',320      ).to.be.fulfilled;321    322      const keys = invalidProperties.flatMap(propertySet => propertySet.map(property => property.key)).concat('CRISPR-Cas9').concat('');323    324      const properties = await collection.getProperties(keys);325      expect(properties).to.be.deep.equal([326        {key: 'CRISPR-Cas9', value: 'rewriting nature!'},327      ]);328    329      for (let i = 0; i < invalidProperties.length; i++) {330        await expect(331          collection.deleteProperties(alice, invalidProperties[i].map(propertySet => propertySet.key)), 332          `on trying to delete the non-existent badly-named property #${i}`,333        ).to.be.rejectedWith(/common\.InvalidCharacterInPropertyKey/);334      }335    });336337    itSub('Modifying a collection property with different sizes correctly changes the consumed space', async({helper}) => {338      const collection = await helper[testSuite.mode].mintCollection(alice, {properties: [339        {key: 'sea-creatures', value: 'mermaids'},340        {key: 'goldenratio', value: '1.6180339887498948482045868343656381177203091798057628621354486227052604628189'},341      ]});342343      await expect(helper.executeExtrinsic(alice, 'api.tx.unique.forceRepairCollection', [collection.collectionId], true))344        .to.be.rejectedWith(/BadOrigin/);345    });346  }));347});348  
after · tests/src/nesting/collectionProperties.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 {IKeyringPair} from '@polkadot/types/types';18import {itSub, Pallets, usingPlaygrounds, expect, requirePalletsOrSkip} from '../util';1920describe('Integration Test: Collection Properties', () => {21  let alice: IKeyringPair;22  let bob: IKeyringPair;23  24  before(async () => {25    await usingPlaygrounds(async (helper, privateKey) => {26      const donor = await privateKey({filename: __filename});27      [alice, bob] = await helper.arrange.createAccounts([200n, 10n], donor);28    });29  });30  31  itSub('Properties are initially empty', async ({helper}) => {32    const collection = await helper.nft.mintCollection(alice);33    expect(await collection.getProperties()).to.be.empty;34  });3536  [37    {mode: 'nft' as const, requiredPallets: []},38    {mode: 'ft' as const, requiredPallets: []},39    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]}, 40  ].map(testSuite => describe(`${testSuite.mode.toUpperCase()}`, () => {41    before(async function() {42      // eslint-disable-next-line require-await43      await usingPlaygrounds(async helper => {44        requirePalletsOrSkip(this, helper, testSuite.requiredPallets);45      });46    });4748    itSub('Sets properties for a collection', async ({helper}) =>  {49      const collection = await helper[testSuite.mode].mintCollection(alice);5051      // As owner52      await expect(collection.setProperties(alice, [{key: 'electron', value: 'come bond'}])).to.be.fulfilled;53    54      await collection.addAdmin(alice, {Substrate: bob.address});55    56      // As administrator57      await expect(collection.setProperties(bob, [{key: 'black_hole'}])).to.be.fulfilled;58    59      const properties = await collection.getProperties();60      expect(properties).to.include.deep.members([61        {key: 'electron', value: 'come bond'},62        {key: 'black_hole', value: ''},63      ]);64    });65    66    itSub('Check valid names for collection properties keys', async ({helper}) =>  {67      const collection = await helper[testSuite.mode].mintCollection(alice);6869      // alpha symbols70      await expect(collection.setProperties(alice, [{key: 'answer'}])).to.be.fulfilled;71    72      // numeric symbols73      await expect(collection.setProperties(alice, [{key: '451'}])).to.be.fulfilled;74    75      // underscore symbol76      await expect(collection.setProperties(alice, [{key: 'black_hole'}])).to.be.fulfilled;77    78      // dash symbol79      await expect(collection.setProperties(alice, [{key: '-'}])).to.be.fulfilled;80    81      // dot symbol82      await expect(collection.setProperties(alice, [{key: 'once.in.a.long.long.while...', value: 'you get a little lost'}])).to.be.fulfilled;83    84      const properties = await collection.getProperties();85      expect(properties).to.include.deep.members([86        {key: 'answer', value: ''},87        {key: '451', value: ''},88        {key: 'black_hole', value: ''},89        {key: '-', value: ''},90        {key: 'once.in.a.long.long.while...', value: 'you get a little lost'},91      ]);92    });93  94    itSub('Changes properties of a collection', async ({helper}) =>  {95      const collection = await helper[testSuite.mode].mintCollection(alice);9697      await expect(collection.setProperties(alice, [{key: 'electron', value: 'come bond'}, {key: 'black_hole', value: ''}])).to.be.fulfilled;98    99      // Mutate the properties100      await expect(collection.setProperties(alice, [{key: 'black_hole', value: 'LIGO'}])).to.be.fulfilled;101    102      const properties = await collection.getProperties();103      expect(properties).to.include.deep.members([104        {key: 'electron', value: 'come bond'},105        {key: 'black_hole', value: 'LIGO'},106      ]);107    });108  109    itSub('Deletes properties of a collection', async ({helper}) =>  {110      const collection = await helper[testSuite.mode].mintCollection(alice);111112      await expect(collection.setProperties(alice, [{key: 'electron', value: 'come bond'}, {key: 'black_hole', value: 'LIGO'}])).to.be.fulfilled;113    114      await expect(collection.deleteProperties(alice, ['electron'])).to.be.fulfilled;115    116      const properties = await collection.getProperties(['black_hole', 'electron']);117      expect(properties).to.be.deep.equal([118        {key: 'black_hole', value: 'LIGO'},119      ]);120    });121122    itSub('Allows modifying a collection property multiple times with the same size', async({helper}) => {123      const propKey = 'tok-prop';124125      const collection = await helper[testSuite.mode].mintCollection(alice);126127      const maxCollectionPropertiesSize = 40960;128129      const propDataSize = 4096;130131      let propDataChar = 'a';132      const makeNewPropData = () => {133        propDataChar = String.fromCharCode(propDataChar.charCodeAt(0) + 1);134        return `${propDataChar}`.repeat(propDataSize);135      };136137      await collection.setProperties(alice, [{key: propKey, value: makeNewPropData()}]);138      const originalSpace = await collection.getPropertiesConsumedSpace();139      expect(originalSpace).to.be.equal(propDataSize);140141      const sameSizePropertiesPossibleNum = maxCollectionPropertiesSize / propDataSize;142143      // It is possible to modify a property as many times as needed.144      // It will not consume any additional space.145      for (let i = 0; i < sameSizePropertiesPossibleNum + 1; i++) {146        await collection.setProperties(alice, [{key: propKey, value: makeNewPropData()}]);147        const consumedSpace = await collection.getPropertiesConsumedSpace();148        expect(consumedSpace).to.be.equal(originalSpace);149      }150    });151152    itSub('Adding then removing a collection property doesn\'t change the consumed space', async({helper}) => {153      const propKey = 'tok-prop';154155      const collection = await helper[testSuite.mode].mintCollection(alice);156      const originalSpace = await collection.getPropertiesConsumedSpace();157158      const propDataSize = 4096;159      const propData = 'a'.repeat(propDataSize);160161      await collection.setProperties(alice, [{key: propKey, value: propData}]);162      let consumedSpace = await collection.getPropertiesConsumedSpace();163      expect(consumedSpace).to.be.equal(propDataSize);164165      await collection.deleteProperties(alice, [propKey]);166      consumedSpace = await collection.getPropertiesConsumedSpace();167      expect(consumedSpace).to.be.equal(originalSpace);168    });169170    itSub('Modifying a collection property with different sizes correctly changes the consumed space', async({helper}) => {171      const propKey = 'tok-prop';172173      const collection = await helper[testSuite.mode].mintCollection(alice);174      const originalSpace = await collection.getPropertiesConsumedSpace();175176      const initPropDataSize = 4096;177      const biggerPropDataSize = 5000;178      const smallerPropDataSize = 4000;179180      const initPropData = 'a'.repeat(initPropDataSize);181      const biggerPropData = 'b'.repeat(biggerPropDataSize);182      const smallerPropData = 'c'.repeat(smallerPropDataSize);183184      let consumedSpace;185      let expectedConsumedSpaceDiff;186187      await collection.setProperties(alice, [{key: propKey, value: initPropData}]);188      consumedSpace = await collection.getPropertiesConsumedSpace();189      expectedConsumedSpaceDiff = initPropDataSize - originalSpace;190      expect(consumedSpace).to.be.equal(originalSpace + expectedConsumedSpaceDiff);191192      await collection.setProperties(alice, [{key: propKey, value: biggerPropData}]);193      consumedSpace = await collection.getPropertiesConsumedSpace();194      expectedConsumedSpaceDiff = biggerPropDataSize - initPropDataSize;195      expect(consumedSpace).to.be.equal(initPropDataSize + expectedConsumedSpaceDiff);196197      await collection.setProperties(alice, [{key: propKey, value: smallerPropData}]);198      consumedSpace = await collection.getPropertiesConsumedSpace();199      expectedConsumedSpaceDiff = biggerPropDataSize - smallerPropDataSize;200      expect(consumedSpace).to.be.equal(biggerPropDataSize - expectedConsumedSpaceDiff);201    });202  }));203});204  205describe('Negative Integration Test: Collection Properties', () => {206  let alice: IKeyringPair;207  let bob: IKeyringPair;208  209  before(async () => {210    await usingPlaygrounds(async (helper, privateKey) => {211      const donor = await privateKey({filename: __filename});212      [alice, bob] = await helper.arrange.createAccounts([100n, 10n], donor);213    });214  });215216  [217    {mode: 'nft' as const, requiredPallets: []},218    {mode: 'ft' as const, requiredPallets: []},219    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]}, 220  ].map(testSuite => describe(`${testSuite.mode.toUpperCase()}`, () => {221    before(async function() {222      // eslint-disable-next-line require-await223      await usingPlaygrounds(async helper => {224        requirePalletsOrSkip(this, helper, testSuite.requiredPallets);225      });226    });227    228    itSub('Fails to set properties in a collection if not its onwer/administrator', async ({helper}) =>  {229      const collection = await helper[testSuite.mode].mintCollection(alice);230231      await expect(collection.setProperties(bob, [{key: 'electron', value: 'come bond'}, {key: 'black_hole', value: 'LIGO'}]))232        .to.be.rejectedWith(/common\.NoPermission/);233    234      expect(await collection.getProperties()).to.be.empty;235    });236    237    itSub('Fails to set properties that exceed the limits', async ({helper}) =>  {238      const collection = await helper[testSuite.mode].mintCollection(alice);239240      const spaceLimit = (await (collection.helper!.api! as any).query.common.collectionProperties(collection.collectionId)).spaceLimit.toNumber();241      242      // Mute the general tx parsing error, too many bytes to process243      {244        console.error = () => {};245        await expect(collection.setProperties(alice, [246          {key: 'electron', value: 'low high '.repeat(Math.ceil(spaceLimit! / 9))},247        ])).to.be.rejected;248      }249    250      expect(await collection.getProperties(['electron'])).to.be.empty;251    252      await expect(collection.setProperties(alice, [253        {key: 'electron', value: 'low high '.repeat(Math.ceil(spaceLimit! / 18))}, 254        {key: 'black_hole', value: '0'.repeat(Math.ceil(spaceLimit! / 2))}, 255      ])).to.be.rejectedWith(/common\.NoSpaceForProperty/);256    257      expect(await collection.getProperties(['electron', 'black_hole'])).to.be.empty;258    });259    260    itSub('Fails to set more properties than it is allowed', async ({helper}) =>  {261      const collection = await helper[testSuite.mode].mintCollection(alice);262263      const propertiesToBeSet = [];264      for (let i = 0; i < 65; i++) {265        propertiesToBeSet.push({266          key: 'electron_' + i,267          value: Math.random() > 0.5 ? 'high' : 'low',268        });269      }270    271      await expect(collection.setProperties(alice, propertiesToBeSet)).272        to.be.rejectedWith(/common\.PropertyLimitReached/);273    274      expect(await collection.getProperties()).to.be.empty;275    });276277    itSub('Fails to set properties with invalid names', async ({helper}) => {278      const collection = await helper[testSuite.mode].mintCollection(alice);279280      const invalidProperties = [281        [{key: 'electron', value: 'negative'}, {key: 'string theory', value: 'understandable'}],282        [{key: 'Mr/Sandman', value: 'Bring me a gene'}],283        [{key: 'déjà vu', value: 'hmm...'}],284      ];285    286      for (let i = 0; i < invalidProperties.length; i++) {287        await expect(288          collection.setProperties(alice, invalidProperties[i]), 289          `on rejecting the new badly-named property #${i}`,290        ).to.be.rejectedWith(/common\.InvalidCharacterInPropertyKey/);291      }292    293      await expect(294        collection.setProperties(alice, [{key: '', value: 'nothing must not exist'}]), 295        'on rejecting an unnamed property',296      ).to.be.rejectedWith(/common\.EmptyPropertyKey/);297    298      await expect(299        collection.setProperties(alice, [{key: 'CRISPR-Cas9', value: 'rewriting nature!'}]), 300        'on setting the correctly-but-still-badly-named property',301      ).to.be.fulfilled;302    303      const keys = invalidProperties.flatMap(propertySet => propertySet.map(property => property.key)).concat('CRISPR-Cas9').concat('');304    305      const properties = await collection.getProperties(keys);306      expect(properties).to.be.deep.equal([307        {key: 'CRISPR-Cas9', value: 'rewriting nature!'},308      ]);309    310      for (let i = 0; i < invalidProperties.length; i++) {311        await expect(312          collection.deleteProperties(alice, invalidProperties[i].map(propertySet => propertySet.key)), 313          `on trying to delete the non-existent badly-named property #${i}`,314        ).to.be.rejectedWith(/common\.InvalidCharacterInPropertyKey/);315      }316    });317318    itSub('Modifying a collection property with different sizes correctly changes the consumed space', async({helper}) => {319      const collection = await helper[testSuite.mode].mintCollection(alice, {properties: [320        {key: 'sea-creatures', value: 'mermaids'},321        {key: 'goldenratio', value: '1.6180339887498948482045868343656381177203091798057628621354486227052604628189'},322      ]});323324      await expect(helper.executeExtrinsic(alice, 'api.tx.unique.forceRepairCollection', [collection.collectionId], true))325        .to.be.rejectedWith(/BadOrigin/);326    });327  }));328});329  
addedtests/src/nesting/tokenProperties.seqtest.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/nesting/tokenProperties.seqtest.ts
@@ -0,0 +1,72 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+import {IKeyringPair} from '@polkadot/types/types';
+import {itSub, Pallets, usingPlaygrounds, expect, requirePalletsOrSkip} from '../util';
+
+describe('Integration Test: Token Properties', () => {
+  let superuser: IKeyringPair;
+  let alice: IKeyringPair; // collection owner
+
+  before(async () => {
+    await usingPlaygrounds(async (helper, privateKey) => {
+      superuser = await privateKey('//Alice');
+      const donor = await privateKey({filename: __filename});
+      [alice] = await helper.arrange.createAccounts([100n], donor);
+    });
+  });
+
+  [
+    {mode: 'nft' as const, pieces: undefined, requiredPallets: []},
+    {mode: 'rft' as const, pieces: 100n, requiredPallets: [Pallets.ReFungible]}, 
+  ].map(testSuite => describe(`${testSuite.mode.toUpperCase()}`, () => {
+    before(async function() {
+      // eslint-disable-next-line require-await
+      await usingPlaygrounds(async helper => {
+        requirePalletsOrSkip(this, helper, testSuite.requiredPallets);
+      });
+    });
+    
+    itSub('force_repair_item preserves valid consumed space', async({helper}) => {
+      const propKey = 'tok-prop';
+
+      const collection = await helper[testSuite.mode].mintCollection(alice, {
+        tokenPropertyPermissions: [
+          {
+            key: propKey,
+            permission: {mutable: true, tokenOwner: true},
+          },
+        ],
+      });
+      const token = await (
+        testSuite.pieces
+          ? collection.mintToken(alice, testSuite.pieces)
+          : collection.mintToken(alice)
+      );
+
+      const propDataSize = 4096;
+      const propData = 'a'.repeat(propDataSize);
+
+      await token.setProperties(alice, [{key: propKey, value: propData}]);
+      const originalSpace = await token.getTokenPropertiesConsumedSpace();
+      expect(originalSpace).to.be.equal(propDataSize);
+
+      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.unique.forceRepairItem', [token.collectionId, token.tokenId], true);
+      const recomputedSpace = await token.getTokenPropertiesConsumedSpace();
+      expect(recomputedSpace).to.be.equal(originalSpace);
+    });
+  }));
+});
\ No newline at end of file
modifiedtests/src/nesting/tokenProperties.test.tsdiffbeforeafterboth
--- a/tests/src/nesting/tokenProperties.test.ts
+++ b/tests/src/nesting/tokenProperties.test.ts
@@ -19,7 +19,6 @@
 import {UniqueHelper, UniqueNFToken, UniqueRFToken} from '../util/playgrounds/unique';
 
 describe('Integration Test: Token Properties', () => {
-  let superuser: IKeyringPair;
   let alice: IKeyringPair; // collection owner
   let bob: IKeyringPair; // collection admin
   let charlie: IKeyringPair; // token owner
@@ -28,7 +27,6 @@
 
   before(async () => {
     await usingPlaygrounds(async (helper, privateKey) => {
-      superuser = await privateKey('//Alice');
       const donor = await privateKey({filename: __filename});
       [alice, bob, charlie] = await helper.arrange.createAccounts([200n, 100n, 100n], donor);
     });
@@ -402,39 +400,6 @@
       await token.deleteProperties(alice, [propKey]);
       consumedSpace = await token.getTokenPropertiesConsumedSpace();
       expect(consumedSpace).to.be.equal(originalSpace);
-    }));
-
-  [
-    {mode: 'nft' as const, pieces: undefined, requiredPallets: []},
-    {mode: 'rft' as const, pieces: 100n, requiredPallets: [Pallets.ReFungible]}, 
-  ].map(testCase =>
-    itSub.ifWithPallets(`force_repair_item preserves valid consumed space (${testCase.mode})`, testCase.requiredPallets, async({helper}) => {
-      const propKey = 'tok-prop';
-
-      const collection = await helper[testCase.mode].mintCollection(alice, {
-        tokenPropertyPermissions: [
-          {
-            key: propKey,
-            permission: {mutable: true, tokenOwner: true},
-          },
-        ],
-      });
-      const token = await (
-        testCase.pieces
-          ? collection.mintToken(alice, testCase.pieces)
-          : collection.mintToken(alice)
-      );
-
-      const propDataSize = 4096;
-      const propData = 'a'.repeat(propDataSize);
-
-      await token.setProperties(alice, [{key: propKey, value: propData}]);
-      const originalSpace = await token.getTokenPropertiesConsumedSpace();
-      expect(originalSpace).to.be.equal(propDataSize);
-
-      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.unique.forceRepairItem', [token.collectionId, token.tokenId], true);
-      const recomputedSpace = await token.getTokenPropertiesConsumedSpace();
-      expect(recomputedSpace).to.be.equal(originalSpace);
     }));
 
   [