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

difftreelog

source

tests/src/nesting/nest.test.ts24.9 KiBsourcehistory
1import {expect} from 'chai';2import {tokenIdToAddress} from '../eth/util/helpers';3import privateKey from '../substrate/privateKey';4import usingApi, {executeTransaction} from '../substrate/substrate-api';5import {6  addToAllowListExpectSuccess,7  createCollectionExpectSuccess,8  createItemExpectFailure, 9  createItemExpectSuccess,10  enableAllowListExpectSuccess,11  enablePublicMintingExpectSuccess,12  getTokenOwner, 13  getTopmostTokenOwner, 14  setCollectionLimitsExpectSuccess, 15  transferExpectFailure, 16  transferExpectSuccess, 17  transferFromExpectSuccess,18} from '../util/helpers';19import {IKeyringPair} from '@polkadot/types/types';2021let alice: IKeyringPair;22let bob: IKeyringPair;2324describe('Integration Test: Nesting', () => {25  before(async () => {26    alice = privateKey('//Alice');27    bob = privateKey('//Bob');28  });2930  // ---------- Non-Fungible ----------3132  // todo refactor names33  // todo remove excessive bundling, leave it for a single test34  it('NFT: allows to nest/unnest token if nesting rule is Owner', async () => {35    await usingApi(async api => {36      const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});37      await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: 'Owner'});38      const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');3940      // Create a nested token41      const nestedToken = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, targetToken)});42      expect(await getTopmostTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Substrate: alice.address});43      expect(await getTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Ethereum: tokenIdToAddress(collection, targetToken).toLowerCase()});4445      // Create a token to be nested46      const newToken = await createItemExpectSuccess(alice, collection, 'NFT');47      48      // Nest49      await transferExpectSuccess(collection, newToken, alice, {Ethereum: tokenIdToAddress(collection, targetToken)});50      expect(await getTopmostTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Substrate: alice.address});51      expect(await getTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Ethereum: tokenIdToAddress(collection, targetToken).toLowerCase()});5253      // Move bundle to different user54      await transferExpectSuccess(collection, targetToken, alice, {Substrate: bob.address});55      expect(await getTopmostTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Substrate: bob.address});56      expect(await getTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Ethereum: tokenIdToAddress(collection, targetToken).toLowerCase()});5758      // Unnest59      await transferFromExpectSuccess(collection, newToken, bob, {Ethereum: tokenIdToAddress(collection, targetToken)}, {Substrate: bob.address});60      expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: bob.address});61    });62  });6364  it('NFT: allows to nest/unnest token if Owner-Restricted', async () => {65    await usingApi(async api => {66      const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});67      await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: {OwnerRestricted:[collection]}});68      const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');6970      // Create a nested token71      const nestedToken = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, targetToken)});72      expect(await getTopmostTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Substrate: alice.address});73      expect(await getTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Ethereum: tokenIdToAddress(collection, targetToken).toLowerCase()});7475      // Create a token to be nested76      const newToken = await createItemExpectSuccess(alice, collection, 'NFT');77      78      // Nest79      await transferExpectSuccess(collection, newToken, alice, {Ethereum: tokenIdToAddress(collection, targetToken)});80      expect(await getTopmostTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Substrate: alice.address});81      expect(await getTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Ethereum: tokenIdToAddress(collection, targetToken).toLowerCase()});8283      // Move bundle to different user84      await transferExpectSuccess(collection, targetToken, alice, {Substrate: bob.address});85      expect(await getTopmostTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Substrate: bob.address});86      expect(await getTokenOwner(api, collection, nestedToken)).to.be.deep.equal({Ethereum: tokenIdToAddress(collection, targetToken).toLowerCase()});87      88      // Unnest89      await transferFromExpectSuccess(collection, newToken, bob, {Ethereum: tokenIdToAddress(collection, targetToken)}, {Substrate: bob.address});90      expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: bob.address});91    });92  });9394  // ---------- Fungible ----------9596  it('Fungible: allows to nest/unnest token if Owner', async () => {97    await usingApi(async api => {98      const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});99      await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: 'Owner'});100      const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT', {Substrate: alice.address});101      const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};102103      const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});104105      // Create a nested token106      await expect(executeTransaction(api, alice, api.tx.unique.createItem(107        collectionFT, 108        targetAddress, 109        {Fungible: {Value: 10}},110      ))).to.not.be.rejected;111112      // Create a token to be nested113      const newToken = await createItemExpectSuccess(alice, collectionFT, 'Fungible');114      // Nest115      await transferExpectSuccess(collectionFT, newToken, alice, targetAddress, 1, 'Fungible');116      // Move bundle to different user117      await transferExpectSuccess(collectionNFT, targetToken, alice, {Substrate: bob.address});118      // Unnest119      await transferFromExpectSuccess(collectionFT, newToken, bob, targetAddress, {Substrate: bob.address}, 1, 'Fungible');120    });121  });122123  it('Fungible: allows to nest/unnest token if Owner-Restricted', async () => {124    await usingApi(async api => {125      const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});126      const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT', {Substrate: alice.address});127      const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};128129      const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});130131      await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: {OwnerRestricted:[collectionFT]}});132133      // Create a nested token134      await expect(executeTransaction(api, alice, api.tx.unique.createItem(135        collectionFT, 136        targetAddress, 137        {Fungible: {Value: 10}},138      ))).to.not.be.rejected;139140      // Create a token to be nested141      const newToken = await createItemExpectSuccess(alice, collectionFT, 'Fungible');142      // Nest143      await transferExpectSuccess(collectionFT, newToken, alice, targetAddress, 1, 'Fungible');144      // Move bundle to different user145      await transferExpectSuccess(collectionNFT, targetToken, alice, {Substrate: bob.address});146      // Unnest147      await transferFromExpectSuccess(collectionFT, newToken, bob, targetAddress, {Substrate: bob.address}, 1, 'Fungible');148    });149  });150151  // ---------- Re-Fungible ----------152153  it('ReFungible: allows to nest/unnest token if Owner', async () => {154    await usingApi(async api => {155      const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});156      await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: 'Owner'});157      const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT', {Substrate: alice.address});158      const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};159160      const collectionRFT = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});161162      // Create a nested token163      await expect(executeTransaction(api, alice, api.tx.unique.createItem(164        collectionRFT, 165        targetAddress, 166        {ReFungible: {const_data: [], variable_data: [], pieces: 100}},167      ))).to.not.be.rejected;168169      // Create a token to be nested170      const newToken = await createItemExpectSuccess(alice, collectionRFT, 'ReFungible');171      // Nest172      await transferExpectSuccess(collectionRFT, newToken, alice, targetAddress, 100, 'ReFungible');173      // Move bundle to different user174      await transferExpectSuccess(collectionNFT, targetToken, alice, {Substrate: bob.address});175      // Unnest176      await transferFromExpectSuccess(collectionRFT, newToken, bob, targetAddress, {Substrate: bob.address}, 100, 'ReFungible');177    });178  });179180  it('ReFungible: allows to nest/unnest token if Owner-Restricted', async () => {181    await usingApi(async api => {182      const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});183      const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT', {Substrate: alice.address});184      const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};185186      const collectionRFT = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});187188      await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: {OwnerRestricted:[collectionRFT]}});189190      // Create a nested token191      await expect(executeTransaction(api, alice, api.tx.unique.createItem(192        collectionRFT, 193        targetAddress,194        {ReFungible: {const_data: [], variable_data: [], pieces: 100}},195      ))).to.not.be.rejected;196197      // Create a token to be nested198      const newToken = await createItemExpectSuccess(alice, collectionRFT, 'ReFungible');199      // Nest200      await transferExpectSuccess(collectionRFT, newToken, alice, targetAddress, 100, 'ReFungible');201      // Move bundle to different user202      await transferExpectSuccess(collectionNFT, targetToken, alice, {Substrate: bob.address});203      // Unnest204      await transferFromExpectSuccess(collectionRFT, newToken, bob, targetAddress, {Substrate: bob.address}, 100, 'ReFungible');205    });206  });207});208209describe('Negative Test: Nesting', async() => {210  before(async () => {211    alice = privateKey('//Alice');212    bob = privateKey('//Bob');213  });214215  // ---------- Non-Fungible ----------216217  it('NFT: disallows to nest token if nesting is disabled', async () => {218    await usingApi(async api => {219      const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});220      await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: 'Disabled'});221      const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');222223      // Try to create a nested token224      await expect(executeTransaction(api, alice, api.tx.unique.createItem(225        collection, 226        {Ethereum: tokenIdToAddress(collection, targetToken)}, 227        {nft: {const_data: [], variable_data: []}} as any,228      ))).to.be.rejectedWith(/^common\.NestingIsDisabled$/);229230      // Create a token to be nested231      const newToken = await createItemExpectSuccess(alice, collection, 'NFT');232      // Try to nest233      await transferExpectFailure(collection, newToken, alice, {Ethereum: tokenIdToAddress(collection, targetToken)}); // todo to.be.rejected234      expect(await getTopmostTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: alice.address});235      expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: alice.address});236    });237  });238239  it('NFT: disallows to nest token if not Owner', async () => {240    await usingApi(async api => {241      const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});242      await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: 'Owner'});243244      await addToAllowListExpectSuccess(alice, collection, bob.address);245      await enableAllowListExpectSuccess(alice, collection);246      await enablePublicMintingExpectSuccess(alice, collection);247248      // Create a token to attempt to be nested into249      const targetToken = await createItemExpectSuccess(bob, collection, 'NFT');250251      // Try to create a nested token in the wrong collection252      await createItemExpectFailure(alice, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, targetToken)});253254      // Try to create and nest a token in the wrong collection255      const newToken = await createItemExpectSuccess(alice, collection, 'NFT');256      await transferExpectFailure(collection, newToken, alice, {Ethereum: tokenIdToAddress(collection, targetToken)});257      expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: alice.address});258    });259  });260261  it('NFT: disallows to nest token if not Owner (Restricted nesting)', async () => {262    await usingApi(async api => {263      const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});264      await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: {OwnerRestricted:[collection]}});265266      await addToAllowListExpectSuccess(alice, collection, bob.address);267      await enableAllowListExpectSuccess(alice, collection);268      await enablePublicMintingExpectSuccess(alice, collection);269270      // Create a token to attempt to be nested into271      const targetToken = await createItemExpectSuccess(bob, collection, 'NFT');272273      // Try to create a nested token in the wrong collection274      await createItemExpectFailure(alice, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, targetToken)});275276      // Try to create and nest a token in the wrong collection277      const newToken = await createItemExpectSuccess(alice, collection, 'NFT');278      await transferExpectFailure(collection, newToken, alice, {Ethereum: tokenIdToAddress(collection, targetToken)});279      expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: alice.address});280    });281  });282283  it('NFT: disallows to nest token to an unlisted collection', async () => {284    await usingApi(async api => {285      const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});286      await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: {OwnerRestricted:[]}});287288      // Create a token to attempt to be nested into289      const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');290291      // Try to create a nested token in the wrong collection292      await createItemExpectFailure(alice, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, targetToken)});293294      // Try to create and nest a token in the wrong collection295      const newToken = await createItemExpectSuccess(alice, collection, 'NFT');296      await transferExpectFailure(collection, newToken, alice, {Ethereum: tokenIdToAddress(collection, targetToken)});297      expect(await getTokenOwner(api, collection, newToken)).to.be.deep.equal({Substrate: alice.address});298    });299  });300301  // ---------- Fungible ----------302303  it('Fungible: disallows to nest token if nesting is disabled', async () => {304    await usingApi(async api => {305      const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});306      await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: 'Disabled'});307      const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT');308      const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};309310      const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});311312      // Try to create a nested token313      await expect(executeTransaction(api, alice, api.tx.unique.createItem(314        collectionFT, 315        targetAddress, 316        {Fungible: {Value: 10}},317      ))).to.be.rejectedWith(/^common\.NestingIsDisabled$/);318319      // Create a token to be nested320      const newToken = await createItemExpectSuccess(alice, collectionFT, 'Fungible');321      // Try to nest322      await transferExpectFailure(collectionFT, newToken, alice, targetAddress, 1);323    });324  });325326  it('Fungible: disallows to nest token if not Owner', async () => {327    await usingApi(async api => {328      const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});329      await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: 'Owner'});330331      await addToAllowListExpectSuccess(alice, collectionNFT, bob.address);332      await enableAllowListExpectSuccess(alice, collectionNFT);333      await enablePublicMintingExpectSuccess(alice, collectionNFT);334335      // Create a token to attempt to be nested into336      const targetToken = await createItemExpectSuccess(bob, collectionNFT, 'NFT');337      const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};338339      const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});340341      // Try to create a nested token in the wrong collection342      await expect(executeTransaction(api, alice, api.tx.unique.createItem(343        collectionFT, 344        targetAddress, 345        {Fungible: {Value: 10}},346      ))).to.be.rejected;347348      // Try to create and nest a token in the wrong collection349      const newToken = await createItemExpectSuccess(alice, collectionFT, 'Fungible');350      await transferExpectFailure(collectionFT, newToken, alice, targetAddress, 1);351    });352  });353354  it('Fungible: disallows to nest token if not Owner (Restricted nesting)', async () => {355    await usingApi(async api => {356      const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});357      await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: {OwnerRestricted:[collectionNFT]}}); // todo clear redundant restrictions358359      await addToAllowListExpectSuccess(alice, collectionNFT, bob.address);360      await enableAllowListExpectSuccess(alice, collectionNFT);361      await enablePublicMintingExpectSuccess(alice, collectionNFT);362363      // Create a token to attempt to be nested into364      const targetToken = await createItemExpectSuccess(bob, collectionNFT, 'NFT');365      const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};366367      const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});368369      // Try to create a nested token in the wrong collection370      await expect(executeTransaction(api, alice, api.tx.unique.createItem(371        collectionFT, 372        targetAddress, 373        {Fungible: {Value: 10}},374      ))).to.be.rejected;375376      // Try to create and nest a token in the wrong collection377      const newToken = await createItemExpectSuccess(alice, collectionFT, 'Fungible');378      await transferExpectFailure(collectionFT, newToken, alice, targetAddress, 1);379    });380  });381382  it('Fungible: disallows to nest token to an unlisted collection', async () => {383    await usingApi(async api => {384      const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});385      await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: {OwnerRestricted:[]}});386387      // Create a token to attempt to be nested into388      const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT');389      const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};390391      const collectionFT = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});392393      // Try to create a nested token in the wrong collection394      await expect(executeTransaction(api, alice, api.tx.unique.createItem(395        collectionFT, 396        targetAddress, 397        {Fungible: {Value: 10}},398      ))).to.be.rejected;399400      // Try to create and nest a token in the wrong collection401      const newToken = await createItemExpectSuccess(alice, collectionFT, 'Fungible');402      await transferExpectFailure(collectionFT, newToken, alice, targetAddress, 1);403    });404  });405406  // ---------- Re-Fungible ----------407408  it('ReFungible: disallows to nest token if nesting is disabled', async () => {409    await usingApi(async api => {410      const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});411      await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: 'Disabled'});412      const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT');413      const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};414415      const collectionRFT = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});416417      // Create a nested token418      await expect(executeTransaction(api, alice, api.tx.unique.createItem(419        collectionRFT, 420        targetAddress, 421        {ReFungible: {const_data: [], variable_data: [], pieces: 100}},422      ))).to.be.rejectedWith(/^common\.NestingIsDisabled$/);423424      // Create a token to be nested425      const newToken = await createItemExpectSuccess(alice, collectionRFT, 'ReFungible');426      // Try to nest427      await transferExpectFailure(collectionRFT, newToken, alice, targetAddress, 100);428    });429  });430431  it('ReFungible: disallows to nest token if not Owner', async () => {432    await usingApi(async api => {433      const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});434      await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: 'Owner'});435436      await addToAllowListExpectSuccess(alice, collectionNFT, bob.address);437      await enableAllowListExpectSuccess(alice, collectionNFT);438      await enablePublicMintingExpectSuccess(alice, collectionNFT);439440      // Create a token to attempt to be nested into441      const targetToken = await createItemExpectSuccess(bob, collectionNFT, 'NFT');442      const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};443444      const collectionRFT = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});445446      // Try to create a nested token in the wrong collection447      await expect(executeTransaction(api, alice, api.tx.unique.createItem(448        collectionRFT, 449        targetAddress, 450        {ReFungible: {const_data: [], variable_data: [], pieces: 100}},451      ))).to.be.rejected;452453      // Try to create and nest a token in the wrong collection454      const newToken = await createItemExpectSuccess(alice, collectionRFT, 'ReFungible');455      await transferExpectFailure(collectionRFT, newToken, alice, targetAddress, 100);456    });457  });458459  it('ReFungible: disallows to nest token if not Owner (Restricted nesting)', async () => {460    await usingApi(async api => {461      const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});462      await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: {OwnerRestricted:[collectionNFT]}});463464      await addToAllowListExpectSuccess(alice, collectionNFT, bob.address);465      await enableAllowListExpectSuccess(alice, collectionNFT);466      await enablePublicMintingExpectSuccess(alice, collectionNFT);467468      // Create a token to attempt to be nested into469      const targetToken = await createItemExpectSuccess(bob, collectionNFT, 'NFT');470      const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};471472      const collectionRFT = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});473474      // Try to create a nested token in the wrong collection475      await expect(executeTransaction(api, alice, api.tx.unique.createItem(476        collectionRFT, 477        targetAddress, 478        {ReFungible: {const_data: [], variable_data: [], pieces: 100}},479      ))).to.be.rejected;480481      // Try to create and nest a token in the wrong collection482      const newToken = await createItemExpectSuccess(alice, collectionRFT, 'ReFungible');483      await transferExpectFailure(collectionRFT, newToken, alice, targetAddress, 100);484    });485  });486487  it('ReFungible: disallows to nest token to an unlisted collection', async () => {488    await usingApi(async api => {489      const collectionNFT = await createCollectionExpectSuccess({mode: {type: 'NFT'}});490      await setCollectionLimitsExpectSuccess(alice, collectionNFT, {nestingRule: {OwnerRestricted:[]}});491492      // Create a token to attempt to be nested into493      const targetToken = await createItemExpectSuccess(alice, collectionNFT, 'NFT');494      const targetAddress = {Ethereum: tokenIdToAddress(collectionNFT, targetToken)};495496      const collectionRFT = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});497498      // Try to create a nested token in the wrong collection499      await expect(executeTransaction(api, alice, api.tx.unique.createItem(500        collectionRFT, 501        targetAddress, 502        {ReFungible: {const_data: [], variable_data: [], pieces: 100}},503      ))).to.be.rejected;504505      // Try to create and nest a token in the wrong collection506      const newToken = await createItemExpectSuccess(alice, collectionRFT, 'ReFungible');507      await transferExpectFailure(collectionRFT, newToken, alice, targetAddress, 100);508    });509  });510});