difftreelog
test multiple modifies of collection properties
in: master
1 file changed
tests/src/nesting/collectionProperties.test.tsdiffbeforeafterboth132 await testDeleteProperties(await helper.rft.mintCollection(alice));132 await testDeleteProperties(await helper.rft.mintCollection(alice));133 });133 });134135 [136 {mode: 'nft' as const, requiredPallets: []},137 {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]}, 138 ].map(testCase =>139 itSub.ifWithPallets(`Allows modifying a collection property multiple times (${testCase.mode})`, testCase.requiredPallets, async({helper}) => {140 const propKey = 'tok-prop';141142 const collection = await helper[testCase.mode].mintCollection(alice);143144 const maxCollectionPropertiesSize = 40960;145146 const propDataSize = 4096;147148 let propDataChar = 'a';149 const makeNewPropData = () => {150 propDataChar = String.fromCharCode(propDataChar.charCodeAt(0) + 1);151 return `${propDataChar}`.repeat(propDataSize);152 };153154 const getConsumedSpace = async () => {155 const props = (await helper.getApi().query.common.collectionProperties(collection.collectionId)).toJSON();156 157 return (props! as any).consumedSpace;158 };159160 await collection.setProperties(alice, [{key: propKey, value: makeNewPropData()}]);161 const originalSpace = await getConsumedSpace();162 expect(originalSpace).to.be.equal(propDataSize);163164 const sameSizePropertiesPossibleNum = maxCollectionPropertiesSize / propDataSize;165166 // It is possible to modify a property as many times as needed.167 // It will not consume any additional space.168 for (let i = 0; i < sameSizePropertiesPossibleNum + 1; i++) {169 await collection.setProperties(alice, [{key: propKey, value: makeNewPropData()}]);170 const consumedSpace = await getConsumedSpace();171 expect(consumedSpace).to.be.equal(originalSpace);172 }173 }));134});174});135 175 136describe('Negative Integration Test: Collection Properties', () => {176describe('Negative Integration Test: Collection Properties', () => {