difftreelog
test modifying a property with different sizes
in: master
2 files changed
tests/src/nesting/collectionProperties.test.tsdiffbeforeafterboth--- a/tests/src/nesting/collectionProperties.test.ts
+++ b/tests/src/nesting/collectionProperties.test.ts
@@ -25,7 +25,7 @@
before(async () => {
await usingPlaygrounds(async (helper, privateKey) => {
const donor = await privateKey({filename: __filename});
- [alice, bob] = await helper.arrange.createAccounts([100n, 10n], donor);
+ [alice, bob] = await helper.arrange.createAccounts([200n, 10n], donor);
});
});
@@ -138,7 +138,7 @@
{mode: 'nft' as const, requiredPallets: []},
{mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},
].map(testCase =>
- itSub.ifWithPallets(`Allows modifying a collection property multiple times (${testCase.mode})`, testCase.requiredPallets, async({helper}) => {
+ itSub.ifWithPallets(`Allows modifying a collection property multiple times with the same size (${testCase.mode})`, testCase.requiredPallets, async({helper}) => {
const propKey = 'tok-prop';
const collection = await helper[testCase.mode].mintCollection(alice);
@@ -191,6 +191,45 @@
consumedSpace = await collection.getPropertiesConsumedSpace();
expect(consumedSpace).to.be.equal(originalSpace);
}));
+
+ [
+ // TODO enable properties for FT collection in Substrate (release 040)
+ // {mode: 'ft' as const, requiredPallets: []},
+ {mode: 'nft' as const, requiredPallets: []},
+ {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},
+ ].map(testCase =>
+ itSub.ifWithPallets(`Modifying a collection property with different size correctly changes 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 initPropDataSize = 4096;
+ const biggerPropDataSize = 5000;
+ const smallerPropDataSize = 4000;
+
+ const initPropData = 'a'.repeat(initPropDataSize);
+ const biggerPropData = 'b'.repeat(biggerPropDataSize);
+ const smallerPropData = 'b'.repeat(smallerPropDataSize);
+
+ let consumedSpace;
+ let expectedConsumedSpaceDiff;
+
+ await collection.setProperties(alice, [{key: propKey, value: initPropData}]);
+ consumedSpace = await collection.getPropertiesConsumedSpace();
+ expectedConsumedSpaceDiff = initPropDataSize - originalSpace;
+ expect(consumedSpace).to.be.equal(originalSpace + expectedConsumedSpaceDiff);
+
+ await collection.setProperties(alice, [{key: propKey, value: biggerPropData}]);
+ consumedSpace = await collection.getPropertiesConsumedSpace();
+ expectedConsumedSpaceDiff = biggerPropDataSize - initPropDataSize;
+ expect(consumedSpace).to.be.equal(initPropDataSize + expectedConsumedSpaceDiff);
+
+ await collection.setProperties(alice, [{key: propKey, value: smallerPropData}]);
+ consumedSpace = await collection.getPropertiesConsumedSpace();
+ expectedConsumedSpaceDiff = biggerPropDataSize - smallerPropDataSize;
+ expect(consumedSpace).to.be.equal(biggerPropDataSize - expectedConsumedSpaceDiff);
+ }));
});
describe('Negative Integration Test: Collection Properties', () => {
tests/src/nesting/tokenProperties.test.tsdiffbeforeafterboth435 expect(recomputedSpace).to.be.equal(originalSpace);435 expect(recomputedSpace).to.be.equal(originalSpace);436 }));436 }));437438 [439 {mode: 'nft' as const, pieces: undefined, requiredPallets: []},440 {mode: 'rft' as const, pieces: 100n, requiredPallets: [Pallets.ReFungible]}, 441 ].map(testCase =>442 itSub.ifWithPallets(`Modifying a token property with different size correctly changes the consumed space (${testCase.mode})`, testCase.requiredPallets, async({helper}) => {443 const propKey = 'tok-prop';444445 const collection = await helper[testCase.mode].mintCollection(alice, {446 tokenPropertyPermissions: [447 {448 key: propKey,449 permission: {mutable: true, tokenOwner: true},450 },451 ],452 });453 const token = await (454 testCase.pieces455 ? collection.mintToken(alice, testCase.pieces)456 : collection.mintToken(alice)457 );458 const originalSpace = await token.getTokenPropertiesConsumedSpace();459460 const initPropDataSize = 4096;461 const biggerPropDataSize = 5000;462 const smallerPropDataSize = 4000;463464 const initPropData = 'a'.repeat(initPropDataSize);465 const biggerPropData = 'b'.repeat(biggerPropDataSize);466 const smallerPropData = 'b'.repeat(smallerPropDataSize);467468 let consumedSpace;469 let expectedConsumedSpaceDiff;470471 await token.setProperties(alice, [{key: propKey, value: initPropData}]);472 consumedSpace = await token.getTokenPropertiesConsumedSpace();473 expectedConsumedSpaceDiff = initPropDataSize - originalSpace;474 expect(consumedSpace).to.be.equal(originalSpace + expectedConsumedSpaceDiff);475476 await token.setProperties(alice, [{key: propKey, value: biggerPropData}]);477 consumedSpace = await token.getTokenPropertiesConsumedSpace();478 expectedConsumedSpaceDiff = biggerPropDataSize - initPropDataSize;479 expect(consumedSpace).to.be.equal(initPropDataSize + expectedConsumedSpaceDiff);480481 await token.setProperties(alice, [{key: propKey, value: smallerPropData}]);482 consumedSpace = await token.getTokenPropertiesConsumedSpace();483 expectedConsumedSpaceDiff = biggerPropDataSize - smallerPropDataSize;484 expect(consumedSpace).to.be.equal(biggerPropDataSize - expectedConsumedSpaceDiff);485 }));437});486});438487439describe('Negative Integration Test: Token Properties', () => {488describe('Negative Integration Test: Token Properties', () => {