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
166 }166 }
167 }));167 }));
168
169 [
170 {mode: 'nft' as const, requiredPallets: []},
171 {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},
172 ].map(testCase =>
173 itSub.ifWithPallets(`Adding then removing a collection property doesn't change the consumed space (${testCase.mode})`, testCase.requiredPallets, async({helper}) => {
174 const propKey = 'tok-prop';
175
176 const collection = await helper[testCase.mode].mintCollection(alice);
177 const originalSpace = await collection.getPropertiesConsumedSpace();
178
179 const propDataSize = 4096;
180 const propData = 'a'.repeat(propDataSize);
181
182 await collection.setProperties(alice, [{key: propKey, value: propData}]);
183 let consumedSpace = await collection.getPropertiesConsumedSpace();
184 expect(consumedSpace).to.be.equal(propDataSize);
185
186 await collection.deleteProperties(alice, [propKey]);
187 consumedSpace = await collection.getPropertiesConsumedSpace();
188 expect(consumedSpace).to.be.equal(originalSpace);
189 }));
168});190});
169 191
170describe('Negative Integration Test: Collection Properties', () => {192describe('Negative Integration Test: Collection Properties', () => {
modifiedtests/src/nesting/tokenProperties.test.tsdiffbeforeafterboth
--- a/tests/src/nesting/tokenProperties.test.ts
+++ b/tests/src/nesting/tokenProperties.test.ts
@@ -367,6 +367,40 @@
         expect(consumedSpace).to.be.equal(originalSpace);
       }
     }));
+
+  [
+    {mode: 'nft' as const, pieces: undefined, requiredPallets: []},
+    {mode: 'rft' as const, pieces: 100n, requiredPallets: [Pallets.ReFungible]}, 
+  ].map(testCase =>
+    itSub.ifWithPallets(`Adding then removing a token 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, {
+        tokenPropertyPermissions: [
+          {
+            key: propKey,
+            permission: {mutable: true, tokenOwner: true},
+          },
+        ],
+      });
+      const token = await (
+        testCase.pieces
+          ? collection.mintToken(alice, testCase.pieces)
+          : collection.mintToken(alice)
+      );
+      const originalSpace = await token.getTokenPropertiesConsumedSpace();
+
+      const propDataSize = 4096;
+      const propData = 'a'.repeat(propDataSize);
+
+      await token.setProperties(alice, [{key: propKey, value: propData}]);
+      let consumedSpace = await token.getTokenPropertiesConsumedSpace();
+      expect(consumedSpace).to.be.equal(propDataSize);
+
+      await token.deleteProperties(alice, [propKey]);
+      consumedSpace = await token.getTokenPropertiesConsumedSpace();
+      expect(consumedSpace).to.be.equal(originalSpace);
+    }));
 });
 
 describe('Negative Integration Test: Token Properties', () => {