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

difftreelog

test multiple modifies of collection properties

Daniel Shiposha2022-12-14parent: #c1245b0.patch.diff
in: master

1 file changed

modifiedtests/src/nesting/collectionProperties.test.tsdiffbeforeafterboth
132 await testDeleteProperties(await helper.rft.mintCollection(alice));132 await testDeleteProperties(await helper.rft.mintCollection(alice));
133 });133 });
134
135 [
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';
141
142 const collection = await helper[testCase.mode].mintCollection(alice);
143
144 const maxCollectionPropertiesSize = 40960;
145
146 const propDataSize = 4096;
147
148 let propDataChar = 'a';
149 const makeNewPropData = () => {
150 propDataChar = String.fromCharCode(propDataChar.charCodeAt(0) + 1);
151 return `${propDataChar}`.repeat(propDataSize);
152 };
153
154 const getConsumedSpace = async () => {
155 const props = (await helper.getApi().query.common.collectionProperties(collection.collectionId)).toJSON();
156
157 return (props! as any).consumedSpace;
158 };
159
160 await collection.setProperties(alice, [{key: propKey, value: makeNewPropData()}]);
161 const originalSpace = await getConsumedSpace();
162 expect(originalSpace).to.be.equal(propDataSize);
163
164 const sameSizePropertiesPossibleNum = maxCollectionPropertiesSize / propDataSize;
165
166 // 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', () => {