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

difftreelog

source

tests/src/nesting/collectionProperties.seqtest.ts2.7 KiBsourcehistory
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, sizeOfProperty} from '../util';1920describe('Integration Test: Collection Properties with sudo', () => {21  let superuser: IKeyringPair;22  let alice: IKeyringPair;2324  before(async () => {25    await usingPlaygrounds(async (helper, privateKey) => {26      superuser = await privateKey('//Alice');27      const donor = await privateKey({url: import.meta.url});28      [alice] = await helper.arrange.createAccounts([100n], donor);29    });30  });3132  [33    {mode: 'nft' as const, requiredPallets: []},34    {mode: 'ft' as const, requiredPallets: []},35    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},36  ].map(testSuite => describe(`${testSuite.mode.toUpperCase()}`, () => {37    before(async function() {38      // eslint-disable-next-line require-await39      await usingPlaygrounds(async helper => {40        requirePalletsOrSkip(this, helper, testSuite.requiredPallets);41      });42    });4344    itSub('Repairing an unbroken collection\'s properties preserves the consumed space', async({helper}) => {45      const properties = [46        {key: 'sea-creatures', value: 'mermaids'},47        {key: 'goldenratio', value: '1.6180339887498948482045868343656381177203091798057628621354486227052604628189'},48      ];49      const collection = await helper[testSuite.mode].mintCollection(alice, {properties});5051      const newProperty = {key: 'space', value: ' '.repeat(4096)};52      await collection.setProperties(alice, [newProperty]);53      const originalSpace = await collection.getPropertiesConsumedSpace();54      expect(originalSpace).to.be.equal(sizeOfProperty(properties[0]) + sizeOfProperty(properties[1]) + sizeOfProperty(newProperty));5556      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.unique.forceRepairCollection', [collection.collectionId], true);57      const recomputedSpace = await collection.getPropertiesConsumedSpace();58      expect(recomputedSpace).to.be.equal(originalSpace);59    });60  }));61});