1234567891011121314151617import {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 24 before(async () => {25 await usingPlaygrounds(async (helper, privateKey) => {26 superuser = await privateKey('//Alice');27 const donor = await privateKey({filename: __filename});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 39 await usingPlaygrounds(async helper => {40 requirePalletsOrSkip(this, helper, testSuite.requiredPallets);41 });42 });43 44 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 = ' '.repeat(4096);52 await collection.setProperties(alice, [{key: 'space', value: newProperty}]);53 const originalSpace = await collection.getPropertiesConsumedSpace();54 expect(originalSpace).to.be.equal(properties[0].value.length + properties[1].value.length + newProperty.length);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});