git.delta.rocks / unique-network / refs/commits / 4d135e3fe0d2

difftreelog

source

tests/src/nesting/rules-smoke.test.ts3.1 KiBsourcehistory
1import {expect} from 'chai';2import {tokenIdToAddress} from '../eth/util/helpers';3import privateKey from '../substrate/privateKey';4import usingApi, {executeTransaction} from '../substrate/substrate-api';5import {createCollectionExpectSuccess, createFungibleItemExpectSuccess, createItemExpectSuccess, CrossAccountId, getCreateCollectionResult} from '../util/helpers';6import {IKeyringPair} from '@polkadot/types/types';78describe('nesting check', () => {9  let alice!: IKeyringPair;10  let nestTarget!: CrossAccountId;11  before(async() => {12    await usingApi(async api => {13      alice = privateKey('//Alice');14      const bob = privateKey('//Bob');15      const events = await executeTransaction(api, alice, api.tx.unique.createCollectionEx({16        mode: 'NFT',17        permissions: {18          nesting: {OwnerRestricted: []},19        },20      }));21      const collection = getCreateCollectionResult(events).collectionId;22      const token = await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: bob.address});23      nestTarget = {Ethereum: tokenIdToAddress(collection, token)};24    });25  });2627  it('called for fungible', async () => {28    await usingApi(async api => {29      const collection = await createCollectionExpectSuccess({mode: {type: 'Fungible',decimalPoints:0}});30      await expect(executeTransaction(api, alice, api.tx.unique.createItem(collection, nestTarget, {Fungible: {Value: 1}})))31        .to.be.rejectedWith(/^common\.SourceCollectionIsNotAllowedToNest$/);3233      await createFungibleItemExpectSuccess(alice, collection, {Value:1n}, {Substrate: alice.address});34      await expect(executeTransaction(api, alice, api.tx.unique.transfer(nestTarget, collection, 0, 1n)))35        .to.be.rejectedWith(/^common\.SourceCollectionIsNotAllowedToNest$/);36    });37  });3839  it('called for nonfungible', async () => {40    await usingApi(async api => {41      const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});42      await expect(executeTransaction(api, alice, api.tx.unique.createItem(collection, nestTarget, {NFT: {properties: []}})))43        .to.be.rejectedWith(/^common\.SourceCollectionIsNotAllowedToNest$/);4445      const token = await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});46      await expect(executeTransaction(api, alice, api.tx.unique.transfer(nestTarget, collection, token, 1n)))47        .to.be.rejectedWith(/^common\.SourceCollectionIsNotAllowedToNest$/);48    });49  });5051  it('called for refungible', async () => {52    await usingApi(async api => {53      const collection = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});54      await expect(executeTransaction(api, alice, api.tx.unique.createItem(collection, nestTarget, {ReFungible: {}})))55        .to.be.rejectedWith(/^common\.SourceCollectionIsNotAllowedToNest$/);5657      const token = await createItemExpectSuccess(alice, collection, 'ReFungible', {Substrate: alice.address});58      await expect(executeTransaction(api, alice, api.tx.unique.transfer(nestTarget, collection, token, 1n)))59        .to.be.rejectedWith(/^common\.SourceCollectionIsNotAllowedToNest$/);60    });61  });62});