git.delta.rocks / unique-network / refs/commits / 558ad526f431

difftreelog

test add+remove a property doesn't change consumed space

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

2 files changed

modifiedtests/src/nesting/collectionProperties.test.tsdiffbeforeafterboth
--- a/tests/src/nesting/collectionProperties.test.ts
+++ b/tests/src/nesting/collectionProperties.test.ts
@@ -165,6 +165,28 @@
         expect(consumedSpace).to.be.equal(originalSpace);
       }
     }));
+
+  [
+    {mode: 'nft' as const, requiredPallets: []},
+    {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]}, 
+  ].map(testCase =>
+    itSub.ifWithPallets(`Adding then removing a collection property doesn't change the consumed space (${testCase.mode})`, testCase.requiredPallets, async({helper}) => {
+      const propKey = 'tok-prop';
+
+      const collection = await helper[testCase.mode].mintCollection(alice);
+      const originalSpace = await collection.getPropertiesConsumedSpace();
+
+      const propDataSize = 4096;
+      const propData = 'a'.repeat(propDataSize);
+
+      await collection.setProperties(alice, [{key: propKey, value: propData}]);
+      let consumedSpace = await collection.getPropertiesConsumedSpace();
+      expect(consumedSpace).to.be.equal(propDataSize);
+
+      await collection.deleteProperties(alice, [propKey]);
+      consumedSpace = await collection.getPropertiesConsumedSpace();
+      expect(consumedSpace).to.be.equal(originalSpace);
+    }));
 });
   
 describe('Negative Integration Test: Collection Properties', () => {
modifiedtests/src/nesting/tokenProperties.test.tsdiffbeforeafterboth
368 }368 }
369 }));369 }));
370
371 [
372 {mode: 'nft' as const, pieces: undefined, requiredPallets: []},
373 {mode: 'rft' as const, pieces: 100n, requiredPallets: [Pallets.ReFungible]},
374 ].map(testCase =>
375 itSub.ifWithPallets(`Adding then removing a token property doesn't change the consumed space (${testCase.mode})`, testCase.requiredPallets, async({helper}) => {
376 const propKey = 'tok-prop';
377
378 const collection = await helper[testCase.mode].mintCollection(alice, {
379 tokenPropertyPermissions: [
380 {
381 key: propKey,
382 permission: {mutable: true, tokenOwner: true},
383 },
384 ],
385 });
386 const token = await (
387 testCase.pieces
388 ? collection.mintToken(alice, testCase.pieces)
389 : collection.mintToken(alice)
390 );
391 const originalSpace = await token.getTokenPropertiesConsumedSpace();
392
393 const propDataSize = 4096;
394 const propData = 'a'.repeat(propDataSize);
395
396 await token.setProperties(alice, [{key: propKey, value: propData}]);
397 let consumedSpace = await token.getTokenPropertiesConsumedSpace();
398 expect(consumedSpace).to.be.equal(propDataSize);
399
400 await token.deleteProperties(alice, [propKey]);
401 consumedSpace = await token.getTokenPropertiesConsumedSpace();
402 expect(consumedSpace).to.be.equal(originalSpace);
403 }));
370});404});
371405
372describe('Negative Integration Test: Token Properties', () => {406describe('Negative Integration Test: Token Properties', () => {