1234567891011121314151617import type {IKeyringPair} from '@polkadot/types/types';18import {itSub, Pallets, usingPlaygrounds, expect, requirePalletsOrSkip, sizeOfProperty} from '../../util/index.js';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 39 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});