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

difftreelog

source

tests/src/rmrk/rmrk.test.ts2.2 KiBsourcehistory
1import {expect} from 'chai';2import privateKey from '../substrate/privateKey';3import usingApi, {executeTransaction} from '../substrate/substrate-api';4import {5  getCreateCollectionResult,6  getDetailedCollectionInfo,7  getGenericResult,8} from '../util/helpers';9import {IKeyringPair} from '@polkadot/types/types';1011let alice: IKeyringPair;12let bob: IKeyringPair;1314describe('RMRK External Integration Test', () => {15  before(async () => {16    await usingApi(async () => {17      alice = privateKey('//Alice');18      bob = privateKey('//Bob');19    });20  });2122  it('Creates a new RMRK collection that is tagged as external', async () => {23    await usingApi(async api => {24      const tx = api.tx.rmrkCore.createCollection('no-limit-metadata', null, 'no-limit-symbol');25      const events = await executeTransaction(api, alice, tx);26      const result = getCreateCollectionResult(events);2728      const collection = (await getDetailedCollectionInfo(api, result.collectionId))!;29      expect(collection.readOnly.toHuman()).to.be.true;30    });31  });3233  it('[Negative] Forbids NFT operations with an external collection', async () => {34    await usingApi(async api => {35      const tx1 = api.tx.rmrkCore.createCollection('metadata', null, 'symbol');36      const events1 = await executeTransaction(api, alice, tx1);3738      const resultUnique1 = getCreateCollectionResult(events1);39      const uniqueCollectionId = resultUnique1.collectionId;4041      const resultRmrk1 = getGenericResult(events1, 'rmrkCore', 'CollectionCreated', (data) => {42        return parseInt(data[1].toString(), 10);43      });44      const rmrkCollectionId: number = resultRmrk1.data!;4546      const tx2 = api.tx.rmrkCore.mintNft(47        alice.address,48        rmrkCollectionId,49        alice.address,50        null,51        'nft-metadata',52        true,53      );54      const events2 = await executeTransaction(api, alice, tx2);55      const result2 = getGenericResult(events2, 'rmrkCore', 'NftMinted', (data) => {56        return parseInt(data[2].toString(), 10);57      });58      const rmrkNftId: number = result2.data!;5960      const tx3 = api.tx.unique.burnItem(uniqueCollectionId, rmrkNftId, 1);61      await expect(executeTransaction(api, alice, tx3)).to.be.rejectedWith(/common\.CollectionIsExternal/);62    });63  });64});