difftreelog
fix add consumedSpace fns to playgrnds
in: master
3 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([50n, 10n], donor);
+ [alice, bob] = await helper.arrange.createAccounts([100n, 10n], donor);
});
});
@@ -149,16 +149,10 @@
const makeNewPropData = () => {
propDataChar = String.fromCharCode(propDataChar.charCodeAt(0) + 1);
return `${propDataChar}`.repeat(propDataSize);
- };
-
- const getConsumedSpace = async () => {
- const props = (await helper.getApi().query.common.collectionProperties(collection.collectionId)).toJSON();
-
- return (props! as any).consumedSpace;
};
await collection.setProperties(alice, [{key: propKey, value: makeNewPropData()}]);
- const originalSpace = await getConsumedSpace();
+ const originalSpace = await collection.getPropertiesConsumedSpace();
expect(originalSpace).to.be.equal(propDataSize);
const sameSizePropertiesPossibleNum = maxCollectionPropertiesSize / propDataSize;
@@ -167,7 +161,7 @@
// It will not consume any additional space.
for (let i = 0; i < sameSizePropertiesPossibleNum + 1; i++) {
await collection.setProperties(alice, [{key: propKey, value: makeNewPropData()}]);
- const consumedSpace = await getConsumedSpace();
+ const consumedSpace = await collection.getPropertiesConsumedSpace();
expect(consumedSpace).to.be.equal(originalSpace);
}
}));
tests/src/nesting/tokenProperties.test.tsdiffbeforeafterboth--- a/tests/src/nesting/tokenProperties.test.ts
+++ b/tests/src/nesting/tokenProperties.test.ts
@@ -353,14 +353,8 @@
: collection.mintToken(alice)
);
- const getConsumedSpace = async () => {
- const props = (await helper.getApi().query[testCase.storage].tokenProperties(token.collectionId, token.tokenId)).toJSON();
-
- return (props! as any).consumedSpace;
- };
-
await token.setProperties(alice, [{key: propKey, value: makeNewPropData()}]);
- const originalSpace = await getConsumedSpace();
+ const originalSpace = await token.getTokenPropertiesConsumedSpace();
expect(originalSpace).to.be.equal(propDataSize);
const sameSizePropertiesPossibleNum = maxTokenPropertiesSize / propDataSize;
@@ -369,7 +363,7 @@
// It will not consume any additional space.
for (let i = 0; i < sameSizePropertiesPossibleNum + 1; i++) {
await token.setProperties(alice, [{key: propKey, value: makeNewPropData()}]);
- const consumedSpace = await getConsumedSpace();
+ const consumedSpace = await token.getTokenPropertiesConsumedSpace();
expect(consumedSpace).to.be.equal(originalSpace);
}
}));
tests/src/util/playgrounds/unique.tsdiffbeforeafterboth1100 return (await this.helper.callRpc('api.rpc.unique.collectionProperties', [collectionId, propertyKeys])).toHuman();1100 return (await this.helper.callRpc('api.rpc.unique.collectionProperties', [collectionId, propertyKeys])).toHuman();1101 }1101 }11021103 async getPropertiesConsumedSpace(collectionId: number): Promise<number> {1104 const api = this.helper.getApi();1105 const props = (await api.query.common.collectionProperties(collectionId)).toJSON();1106 1107 return (props! as any).consumedSpace;1108 }110211091103 async getCollectionOptions(collectionId: number) {1110 async getCollectionOptions(collectionId: number) {1104 return (await this.helper.callRpc('api.rpc.unique.collectionById', [collectionId])).toHuman();1111 return (await this.helper.callRpc('api.rpc.unique.collectionById', [collectionId])).toHuman();3035 return await this.helper.collection.getProperties(this.collectionId, propertyKeys);3042 return await this.helper.collection.getProperties(this.collectionId, propertyKeys);3036 }3043 }30443045 async getPropertiesConsumedSpace() {3046 return await this.helper.collection.getPropertiesConsumedSpace(this.collectionId);3047 }303730483038 async getTokenNextSponsored(tokenId: number, addressObj: ICrossAccountId) {3049 async getTokenNextSponsored(tokenId: number, addressObj: ICrossAccountId) {3039 return await this.helper.collection.getTokenNextSponsored(this.collectionId, tokenId, addressObj);3050 return await this.helper.collection.getTokenNextSponsored(this.collectionId, tokenId, addressObj);3158 return await this.helper.nft.getTokenProperties(this.collectionId, tokenId, propertyKeys);3169 return await this.helper.nft.getTokenProperties(this.collectionId, tokenId, propertyKeys);3159 }3170 }31713172 async getTokenPropertiesConsumedSpace(tokenId: number): Promise<number> {3173 const api = this.helper.getApi();3174 const props = (await api.query.nonfungible.tokenProperties(this.collectionId, tokenId)).toJSON();3175 3176 return (props! as any).consumedSpace;3177 }316031783161 async transferToken(signer: TSigner, tokenId: number, addressObj: ICrossAccountId) {3179 async transferToken(signer: TSigner, tokenId: number, addressObj: ICrossAccountId) {3162 return await this.helper.nft.transferToken(signer, this.collectionId, tokenId, addressObj);3180 return await this.helper.nft.transferToken(signer, this.collectionId, tokenId, addressObj);3269 return await this.helper.rft.getTokenProperties(this.collectionId, tokenId, propertyKeys);3287 return await this.helper.rft.getTokenProperties(this.collectionId, tokenId, propertyKeys);3270 }3288 }32893290 async getTokenPropertiesConsumedSpace(tokenId: number): Promise<number> {3291 const api = this.helper.getApi();3292 const props = (await api.query.refungible.tokenProperties(this.collectionId, tokenId)).toJSON();3293 3294 return (props! as any).consumedSpace;3295 }327132963272 async transferToken(signer: TSigner, tokenId: number, addressObj: ICrossAccountId, amount=1n) {3297 async transferToken(signer: TSigner, tokenId: number, addressObj: ICrossAccountId, amount=1n) {3273 return await this.helper.rft.transferToken(signer, this.collectionId, tokenId, addressObj, amount);3298 return await this.helper.rft.transferToken(signer, this.collectionId, tokenId, addressObj, amount);3421 return await this.collection.getTokenProperties(this.tokenId, propertyKeys);3446 return await this.collection.getTokenProperties(this.tokenId, propertyKeys);3422 }3447 }34483449 async getTokenPropertiesConsumedSpace() {3450 return await this.collection.getTokenPropertiesConsumedSpace(this.tokenId);3451 }342334523424 async setProperties(signer: TSigner, properties: IProperty[]) {3453 async setProperties(signer: TSigner, properties: IProperty[]) {3425 return await this.collection.setTokenProperties(signer, this.tokenId, properties);3454 return await this.collection.setTokenProperties(signer, this.tokenId, properties);