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

difftreelog

source

js-packages/tests/sub/nesting/tokenProperties.seqtest.ts2.8 KiBsourcehistory
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import type {IKeyringPair} from '@polkadot/types/types';18import {itSub, Pallets, usingPlaygrounds, expect, requirePalletsOrSkip, sizeOfProperty} from '@unique/test-utils/util.js';1920describe('Integration Test: Token Properties with sudo', () => {21  let superuser: IKeyringPair;22  let alice: IKeyringPair; // collection owner2324  before(async () => {25    await usingPlaygrounds(async (helper, privateKey) => {26      superuser = await privateKey('//Alice');27      const donor = await privateKey({url: import.meta.url});28      [alice] = await helper.arrange.createAccounts([100n], donor);29    });30  });3132  [33    {mode: 'nft' as const, pieces: undefined, requiredPallets: []} as const,34    {mode: 'rft' as const, pieces: 100n, requiredPallets: [Pallets.ReFungible]} as const,35  ].map(testSuite => describe(`${testSuite.mode.toUpperCase()}`, () => {36    before(async function() {37      // eslint-disable-next-line require-await38      await usingPlaygrounds(async helper => {39        requirePalletsOrSkip(this, helper, testSuite.requiredPallets);40      });41    });4243    itSub('force_repair_item preserves valid consumed space', async({helper}) => {44      const propKey = 'tok-prop';4546      const collection = await helper[testSuite.mode].mintCollection(alice, {47        tokenPropertyPermissions: [48          {49            key: propKey,50            permission: {mutable: true, tokenOwner: true},51          },52        ],53      });54      const token = await (55        testSuite.pieces56          ? collection.mintToken(alice, testSuite.pieces as any)57          : collection.mintToken(alice)58      );5960      const prop = {key: propKey, value: 'a'.repeat(4096)};6162      await token.setProperties(alice, [prop]);63      const originalSpace = await token.getTokenPropertiesConsumedSpace();64      expect(originalSpace).to.be.equal(sizeOfProperty(prop));6566      await helper.getSudo().executeExtrinsic(superuser, 'api.tx.unique.forceRepairItem', [token.collectionId, token.tokenId], true);67      const recomputedSpace = await token.getTokenPropertiesConsumedSpace();68      expect(recomputedSpace).to.be.equal(originalSpace);69    });70  }));71});