git.delta.rocks / unique-network / refs/commits / 3f7f6aa6cd8e

difftreelog

tests: displace chai-expect header copypasta

Fahrrader2022-09-09parent: #e1baaf9.patch.diff
in: master

15 files changed

modifiedtests/src/addCollectionAdmin.test.tsdiffbeforeafterboth
--- a/tests/src/addCollectionAdmin.test.ts
+++ b/tests/src/addCollectionAdmin.test.ts
@@ -15,12 +15,7 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 import {IKeyringPair} from '@polkadot/types/types';
-import chai from 'chai';
-import chaiAsPromised from 'chai-as-promised';
-import {itSub, usingPlaygrounds} from './util/playgrounds';
-
-chai.use(chaiAsPromised);
-const expect = chai.expect;
+import {itSub, usingPlaygrounds, expect} from './util/playgrounds';
 
 describe('Integration Test addCollectionAdmin(collection_id, new_admin_id):', () => {
   let donor: IKeyringPair;
modifiedtests/src/fungible.test.tsdiffbeforeafterboth
--- a/tests/src/fungible.test.ts
+++ b/tests/src/fungible.test.ts
@@ -16,13 +16,9 @@
 
 import {IKeyringPair} from '@polkadot/types/types';
 import {U128_MAX} from './util/helpers';
-import {itSub, usingPlaygrounds} from './util/playgrounds';
-import chai from 'chai';
-import chaiAsPromised from 'chai-as-promised';
+import {itSub, usingPlaygrounds, expect} from './util/playgrounds';
 
-chai.use(chaiAsPromised);
-const expect = chai.expect;
-
+// todo:playgrounds get rid of globals
 let alice: IKeyringPair;
 let bob: IKeyringPair;
 
modifiedtests/src/pallet-presence.test.tsdiffbeforeafterboth
--- a/tests/src/pallet-presence.test.ts
+++ b/tests/src/pallet-presence.test.ts
@@ -14,8 +14,7 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-import {expect} from 'chai';
-import {itSub, usingPlaygrounds} from './util/playgrounds';
+import {itSub, usingPlaygrounds, expect} from './util/playgrounds';
 
 // Pallets that must always be present
 const requiredPallets = [
modifiedtests/src/refungible.test.tsdiffbeforeafterboth
--- a/tests/src/refungible.test.ts
+++ b/tests/src/refungible.test.ts
@@ -15,12 +15,7 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 import {IKeyringPair} from '@polkadot/types/types';
-import {itSub, Pallets, requirePalletsOrSkip, usingPlaygrounds} from './util/playgrounds';
-
-import chai from 'chai';
-import chaiAsPromised from 'chai-as-promised';
-chai.use(chaiAsPromised);
-const expect = chai.expect;
+import {itSub, Pallets, requirePalletsOrSkip, usingPlaygrounds, expect} from './util/playgrounds';
 
 let alice: IKeyringPair;
 let bob: IKeyringPair;
modifiedtests/src/removeCollectionAdmin.test.tsdiffbeforeafterboth
--- a/tests/src/removeCollectionAdmin.test.ts
+++ b/tests/src/removeCollectionAdmin.test.ts
@@ -14,13 +14,8 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-import chai from 'chai';
-import chaiAsPromised from 'chai-as-promised';
 import {IKeyringPair} from '@polkadot/types/types';
-import {itSub, usingPlaygrounds} from './util/playgrounds';
-
-chai.use(chaiAsPromised);
-const expect = chai.expect;
+import {itSub, usingPlaygrounds, expect} from './util/playgrounds';
 
 describe('Integration Test removeCollectionAdmin(collection_id, account_id):', () => {
   let alice: IKeyringPair;
modifiedtests/src/removeCollectionSponsor.test.tsdiffbeforeafterboth
--- a/tests/src/removeCollectionSponsor.test.ts
+++ b/tests/src/removeCollectionSponsor.test.ts
@@ -14,13 +14,8 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-import chai from 'chai';
-import chaiAsPromised from 'chai-as-promised';
 import {IKeyringPair} from '@polkadot/types/types';
-import {itSub, usingPlaygrounds} from './util/playgrounds';
-
-chai.use(chaiAsPromised);
-const expect = chai.expect;
+import {itSub, usingPlaygrounds, expect} from './util/playgrounds';
 
 describe('integration test: ext. removeCollectionSponsor():', () => {
   let donor: IKeyringPair;
modifiedtests/src/removeFromAllowList.test.tsdiffbeforeafterboth
--- a/tests/src/removeFromAllowList.test.ts
+++ b/tests/src/removeFromAllowList.test.ts
@@ -14,13 +14,8 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-import chai from 'chai';
-import chaiAsPromised from 'chai-as-promised';
 import {IKeyringPair} from '@polkadot/types/types';
-import {itSub, usingPlaygrounds} from './util/playgrounds';
-
-chai.use(chaiAsPromised);
-const expect = chai.expect;
+import {itSub, usingPlaygrounds, expect} from './util/playgrounds';
 
 describe('Integration Test removeFromAllowList', () => {
   let alice: IKeyringPair;
modifiedtests/src/rpc.test.tsdiffbeforeafterboth
--- a/tests/src/rpc.test.ts
+++ b/tests/src/rpc.test.ts
@@ -1,11 +1,22 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
 import {IKeyringPair} from '@polkadot/types/types';
-import chai from 'chai';
-import chaiAsPromised from 'chai-as-promised';
-import {usingPlaygrounds, itSub} from './util/playgrounds';
+import {usingPlaygrounds, itSub, expect} from './util/playgrounds';
 import {crossAccountIdFromLower} from './util/playgrounds/unique';
-
-chai.use(chaiAsPromised);
-const expect = chai.expect;
 
 describe('integration test: RPC methods', () => {
   let donor: IKeyringPair;
modifiedtests/src/setCollectionLimits.test.tsdiffbeforeafterboth
--- a/tests/src/setCollectionLimits.test.ts
+++ b/tests/src/setCollectionLimits.test.ts
@@ -16,12 +16,7 @@
 
 // https://unique-network.readthedocs.io/en/latest/jsapi.html#setchainlimits
 import {IKeyringPair} from '@polkadot/types/types';
-import chai from 'chai';
-import chaiAsPromised from 'chai-as-promised';
-import {itSub, usingPlaygrounds} from './util/playgrounds';
-
-chai.use(chaiAsPromised);
-const expect = chai.expect;
+import {itSub, usingPlaygrounds, expect} from './util/playgrounds';
 
 const accountTokenOwnershipLimit = 0;
 const sponsoredDataSize = 0;
modifiedtests/src/setCollectionSponsor.test.tsdiffbeforeafterboth
--- a/tests/src/setCollectionSponsor.test.ts
+++ b/tests/src/setCollectionSponsor.test.ts
@@ -14,13 +14,8 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-import chai from 'chai';
-import chaiAsPromised from 'chai-as-promised';
 import {IKeyringPair} from '@polkadot/types/types';
-import {itSub, usingPlaygrounds, Pallets} from './util/playgrounds';
-
-chai.use(chaiAsPromised);
-const expect = chai.expect;
+import {itSub, usingPlaygrounds, expect, Pallets} from './util/playgrounds';
 
 describe('integration test: ext. setCollectionSponsor():', () => {
   let alice: IKeyringPair;
modifiedtests/src/setMintPermission.test.tsdiffbeforeafterboth
--- a/tests/src/setMintPermission.test.ts
+++ b/tests/src/setMintPermission.test.ts
@@ -15,12 +15,7 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 import {IKeyringPair} from '@polkadot/types/types';
-import chai from 'chai';
-import chaiAsPromised from 'chai-as-promised';
-import {itSub, usingPlaygrounds} from './util/playgrounds';
-
-chai.use(chaiAsPromised);
-const expect = chai.expect;
+import {itSub, usingPlaygrounds, expect} from './util/playgrounds';
 
 describe('Integration Test setMintPermission', () => {
   let alice: IKeyringPair;
modifiedtests/src/setPublicAccessMode.test.tsdiffbeforeafterboth
--- a/tests/src/setPublicAccessMode.test.ts
+++ b/tests/src/setPublicAccessMode.test.ts
@@ -16,12 +16,7 @@
 
 // https://unique-network.readthedocs.io/en/latest/jsapi.html#setschemaversion
 import {IKeyringPair} from '@polkadot/types/types';
-import chai from 'chai';
-import chaiAsPromised from 'chai-as-promised';
-import {itSub, usingPlaygrounds} from './util/playgrounds';
-
-chai.use(chaiAsPromised);
-const expect = chai.expect;
+import {itSub, usingPlaygrounds, expect} from './util/playgrounds';
 
 describe('Integration Test setPublicAccessMode(): ', () => {
   let alice: IKeyringPair;
modifiedtests/src/transfer.test.tsdiffbeforeafterboth
--- a/tests/src/transfer.test.ts
+++ b/tests/src/transfer.test.ts
@@ -15,13 +15,8 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 import {IKeyringPair} from '@polkadot/types/types';
-import chai from 'chai';
-import chaiAsPromised from 'chai-as-promised';
 import {itEth, usingEthPlaygrounds} from './eth/util/playgrounds';
-import {itSub, Pallets, usingPlaygrounds} from './util/playgrounds';
-
-chai.use(chaiAsPromised);
-const expect = chai.expect;
+import {itSub, Pallets, usingPlaygrounds, expect} from './util/playgrounds';
 
 describe('Integration Test Transfer(recipient, collection_id, item_id, value)', () => {
   let alice: IKeyringPair;
modifiedtests/src/transferFrom.test.tsdiffbeforeafterboth
before · tests/src/transferFrom.test.ts
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 {IKeyringPair} from '@polkadot/types/types';18import chai from 'chai';19import chaiAsPromised from 'chai-as-promised';20import {itSub, Pallets, usingPlaygrounds} from './util/playgrounds';2122chai.use(chaiAsPromised);23const expect = chai.expect;2425describe('Integration Test transferFrom(from, recipient, collection_id, item_id, value):', () => {26  let alice: IKeyringPair;27  let bob: IKeyringPair;28  let charlie: IKeyringPair;2930  before(async () => {31    await usingPlaygrounds(async (helper, privateKey) => {32      const donor = privateKey('//Alice');33      [alice, bob, charlie] = await helper.arrange.createAccounts([20n, 10n, 10n], donor);34    });35  });3637  itSub('[nft] Execute the extrinsic and check nftItemList - owner of token', async ({helper}) => {38    const collection = await helper.nft.mintCollection(alice, {name: 'TransferFrom-1', description: '', tokenPrefix: 'TF'});39    const nft = await collection.mintToken(alice, {Substrate: alice.address});40    await nft.approve(alice, {Substrate: bob.address});41    expect(await nft.isApproved({Substrate: bob.address})).to.be.true;4243    await nft.transferFrom(bob, {Substrate: alice.address}, {Substrate: charlie.address});44    expect(await nft.getOwner()).to.be.deep.equal({Substrate: charlie.address});45  });4647  itSub('[fungible] Execute the extrinsic and check nftItemList - owner of token', async ({helper}) => {48    const collection = await helper.ft.mintCollection(alice, {name: 'TransferFrom-2', description: '', tokenPrefix: 'TF'});49    await collection.mint(alice, {Substrate: alice.address}, 10n);50    await collection.approveTokens(alice, {Substrate: bob.address}, 7n);51    expect(await collection.getApprovedTokens({Substrate: alice.address}, {Substrate: bob.address})).to.be.equal(7n);52    53    await collection.transferFrom(bob, {Substrate: alice.address}, {Substrate: charlie.address}, 6n);54    expect(await collection.getBalance({Substrate: charlie.address})).to.be.equal(6n);55    expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(4n);56    expect(await collection.getApprovedTokens({Substrate: alice.address}, {Substrate: bob.address})).to.be.equal(1n);57  });5859  itSub.ifWithPallets('[refungible] Execute the extrinsic and check nftItemList - owner of token', [Pallets.ReFungible], async ({helper}) => {60    const collection = await helper.rft.mintCollection(alice, {name: 'TransferFrom-3', description: '', tokenPrefix: 'TF'});61    const rft = await collection.mintToken(alice, {Substrate: alice.address}, 10n);62    await rft.approve(alice, {Substrate: bob.address}, 7n);63    expect(await rft.getApprovedPieces({Substrate: alice.address}, {Substrate: bob.address})).to.be.equal(7n);64    65    await rft.transferFrom(bob, {Substrate: alice.address}, {Substrate: charlie.address}, 6n);66    expect(await rft.getBalance({Substrate: charlie.address})).to.be.equal(6n);67    expect(await rft.getBalance({Substrate: alice.address})).to.be.equal(4n);68    expect(await rft.getApprovedPieces({Substrate: alice.address}, {Substrate: bob.address})).to.be.equal(1n);69  });7071  itSub('Should reduce allowance if value is big', async ({helper}) => {72    // fungible73    const collection = await helper.ft.mintCollection(alice, {name: 'TransferFrom-4', description: '', tokenPrefix: 'TF'});74    await collection.mint(alice, {Substrate: alice.address}, 500000n);7576    await collection.approveTokens(alice, {Substrate: bob.address}, 500000n);77    expect(await collection.getApprovedTokens({Substrate: alice.address}, {Substrate: bob.address})).to.be.equal(500000n);78    await collection.transferFrom(bob, {Substrate: alice.address}, {Substrate: charlie.address}, 500000n);79    expect(await collection.getApprovedTokens({Substrate: alice.address}, {Substrate: bob.address})).to.be.equal(0n);80  });8182  itSub('can be called by collection owner on non-owned item when OwnerCanTransfer == true', async ({helper}) => {83    const collection = await helper.nft.mintCollection(alice, {name: 'TransferFrom-5', description: '', tokenPrefix: 'TF'});84    await collection.setLimits(alice, {ownerCanTransfer: true});8586    const nft = await collection.mintToken(alice, {Substrate: bob.address});87    await nft.transferFrom(alice, {Substrate: bob.address}, {Substrate: charlie.address});88    expect(await nft.getOwner()).to.be.deep.equal({Substrate: charlie.address});89  });90});9192describe('Negative Integration Test transferFrom(from, recipient, collection_id, item_id, value):', () => {93  let alice: IKeyringPair;94  let bob: IKeyringPair;95  let charlie: IKeyringPair;9697  before(async () => {98    await usingPlaygrounds(async (helper, privateKey) => {99      const donor = privateKey('//Alice');100      [alice, bob, charlie] = await helper.arrange.createAccounts([50n, 10n, 10n], donor);101    });102  });103104  itSub('transferFrom for a collection that does not exist', async ({helper}) => {105    const collectionId = (1 << 32) - 1;106    await expect(helper.collection.approveToken(alice, collectionId, 0, {Substrate: bob.address}, 1n))107      .to.be.rejectedWith(/common\.CollectionNotFound/);108    await expect(helper.collection.transferTokenFrom(bob, collectionId, 0, {Substrate: alice.address}, {Substrate: bob.address}, 1n))109      .to.be.rejectedWith(/common\.CollectionNotFound/);110  });111112  /* itSub('transferFrom for a collection that was destroyed', async ({helper}) => {113      this test copies approve negative test114  }); */115116  /* itSub('transferFrom a token that does not exist', async ({helper}) => {117    this test copies approve negative test118  }); */119120  /* itSub('transferFrom a token that was deleted', async ({helper}) => {121    this test copies approve negative test122  }); */123124  itSub('[nft] transferFrom for not approved address', async ({helper}) => {125    const collection = await helper.nft.mintCollection(alice, {name: 'TransferFrom-Neg-1', description: '', tokenPrefix: 'TF'});126    const nft = await collection.mintToken(alice, {Substrate: alice.address});127128    await expect(nft.transferFrom(bob, {Substrate: alice.address}, {Substrate: charlie.address}))129      .to.be.rejectedWith(/common\.ApprovedValueTooLow/);130    expect(await nft.getOwner()).to.be.deep.equal({Substrate: alice.address});131  });132133  itSub('[fungible] transferFrom for not approved address', async ({helper}) => {134    const collection = await helper.ft.mintCollection(alice, {name: 'TransferFrom-Neg-1', description: '', tokenPrefix: 'TF'});135    await collection.mint(alice, {Substrate: alice.address}, 10n);136137    await expect(collection.transferFrom(bob, {Substrate: alice.address}, {Substrate: charlie.address}, 5n))138      .to.be.rejectedWith(/common\.ApprovedValueTooLow/);139    expect(await collection.getBalance({Substrate: alice.address})).to.be.deep.equal(10n);140    expect(await collection.getBalance({Substrate: bob.address})).to.be.deep.equal(0n);141    expect(await collection.getBalance({Substrate: charlie.address})).to.be.deep.equal(0n);142  });143144  itSub.ifWithPallets('[refungible] transferFrom for not approved address', [Pallets.ReFungible], async({helper}) => {145    const collection = await helper.rft.mintCollection(alice, {name: 'TransferFrom-Neg-3', description: '', tokenPrefix: 'TF'});146    const rft = await collection.mintToken(alice, {Substrate: alice.address}, 10n);147148    await expect(rft.transferFrom(bob, {Substrate: alice.address}, {Substrate: charlie.address}))149      .to.be.rejectedWith(/common\.ApprovedValueTooLow/);150    expect(await rft.getBalance({Substrate: alice.address})).to.be.deep.equal(10n);151    expect(await rft.getBalance({Substrate: bob.address})).to.be.deep.equal(0n);152    expect(await rft.getBalance({Substrate: charlie.address})).to.be.deep.equal(0n);153  });154155  itSub('[nft] transferFrom incorrect token count', async ({helper}) => {156    const collection = await helper.nft.mintCollection(alice, {name: 'TransferFrom-Neg-4', description: '', tokenPrefix: 'TF'});157    const nft = await collection.mintToken(alice, {Substrate: alice.address});158159    await nft.approve(alice, {Substrate: bob.address});160    expect(await nft.isApproved({Substrate: bob.address})).to.be.true;161162    await expect(helper.collection.transferTokenFrom(163      bob, 164      collection.collectionId, 165      nft.tokenId, 166      {Substrate: alice.address}, 167      {Substrate: charlie.address}, 168      2n,169    )).to.be.rejectedWith(/nonfungible\.NonfungibleItemsHaveNoAmount/);170    expect(await nft.getOwner()).to.be.deep.equal({Substrate: alice.address});171  });172173  itSub('[fungible] transferFrom incorrect token count', async ({helper}) => {174    const collection = await helper.ft.mintCollection(alice, {name: 'TransferFrom-Neg-5', description: '', tokenPrefix: 'TF'});175    await collection.mint(alice, {Substrate: alice.address}, 10n);176177    await collection.approveTokens(alice, {Substrate: bob.address}, 2n);178    expect(await collection.getApprovedTokens({Substrate: alice.address}, {Substrate: bob.address})).to.be.eq(2n);179180    await expect(collection.transferFrom(bob, {Substrate: alice.address}, {Substrate: charlie.address}, 5n))181      .to.be.rejectedWith(/common\.ApprovedValueTooLow/);182    expect(await collection.getBalance({Substrate: alice.address})).to.be.deep.equal(10n);183    expect(await collection.getBalance({Substrate: bob.address})).to.be.deep.equal(0n);184    expect(await collection.getBalance({Substrate: charlie.address})).to.be.deep.equal(0n);185  });186187  itSub.ifWithPallets('[refungible] transferFrom incorrect token count', [Pallets.ReFungible], async ({helper}) => {188    const collection = await helper.rft.mintCollection(alice, {name: 'TransferFrom-Neg-6', description: '', tokenPrefix: 'TF'});189    const rft = await collection.mintToken(alice, {Substrate: alice.address}, 10n);190191    await rft.approve(alice, {Substrate: bob.address}, 5n);192    expect(await rft.getApprovedPieces({Substrate: alice.address}, {Substrate: bob.address})).to.be.eq(5n);193194    await expect(rft.transferFrom(bob, {Substrate: alice.address}, {Substrate: charlie.address}, 7n))195      .to.be.rejectedWith(/common\.ApprovedValueTooLow/);196    expect(await rft.getBalance({Substrate: alice.address})).to.be.deep.equal(10n);197    expect(await rft.getBalance({Substrate: bob.address})).to.be.deep.equal(0n);198    expect(await rft.getBalance({Substrate: charlie.address})).to.be.deep.equal(0n);199  });200201  itSub('[nft] execute transferFrom from account that is not owner of collection', async ({helper}) => {202    const collection = await helper.nft.mintCollection(alice, {name: 'TransferFrom-Neg-7', description: '', tokenPrefix: 'TF'});203    const nft = await collection.mintToken(alice, {Substrate: alice.address});204205    await expect(nft.approve(charlie, {Substrate: bob.address})).to.be.rejectedWith(/common\.CantApproveMoreThanOwned/);206    expect(await nft.isApproved({Substrate: bob.address})).to.be.false;207208    await expect(nft.transferFrom(209      charlie,210      {Substrate: alice.address}, 211      {Substrate: charlie.address},212    )).to.be.rejectedWith(/common\.ApprovedValueTooLow/);213    expect(await nft.getOwner()).to.be.deep.equal({Substrate: alice.address});214  });215216  itSub('[fungible] execute transferFrom from account that is not owner of collection', async ({helper}) => {217    const collection = await helper.ft.mintCollection(alice, {name: 'TransferFrom-Neg-8', description: '', tokenPrefix: 'TF'});218    await collection.mint(alice, {Substrate: alice.address}, 10000n);219220    await expect(collection.approveTokens(charlie, {Substrate: bob.address}, 1n)).to.be.rejectedWith(/common\.CantApproveMoreThanOwned/);221    expect(await collection.getApprovedTokens({Substrate: alice.address}, {Substrate: bob.address})).to.be.eq(0n);222    expect(await collection.getApprovedTokens({Substrate: charlie.address}, {Substrate: bob.address})).to.be.eq(0n);223224    await expect(collection.transferFrom(225      charlie,226      {Substrate: alice.address}, 227      {Substrate: charlie.address},228    )).to.be.rejectedWith(/common\.ApprovedValueTooLow/);229    expect(await collection.getBalance({Substrate: alice.address})).to.be.deep.equal(10000n);230    expect(await collection.getBalance({Substrate: bob.address})).to.be.deep.equal(0n);231    expect(await collection.getBalance({Substrate: charlie.address})).to.be.deep.equal(0n);232  });233234  itSub.ifWithPallets('[refungible] execute transferFrom from account that is not owner of collection', [Pallets.ReFungible], async ({helper}) => {235    const collection = await helper.rft.mintCollection(alice, {name: 'TransferFrom-Neg-9', description: '', tokenPrefix: 'TF'});236    const rft = await collection.mintToken(alice, {Substrate: alice.address}, 10000n);237238    await expect(rft.approve(charlie, {Substrate: bob.address}, 1n)).to.be.rejectedWith(/common\.CantApproveMoreThanOwned/);239    expect(await rft.getApprovedPieces({Substrate: alice.address}, {Substrate: bob.address})).to.be.eq(0n);240    expect(await rft.getApprovedPieces({Substrate: charlie.address}, {Substrate: bob.address})).to.be.eq(0n);241242    await expect(rft.transferFrom(243      charlie,244      {Substrate: alice.address}, 245      {Substrate: charlie.address},246    )).to.be.rejectedWith(/common\.ApprovedValueTooLow/);247    expect(await rft.getBalance({Substrate: alice.address})).to.be.deep.equal(10000n);248    expect(await rft.getBalance({Substrate: bob.address})).to.be.deep.equal(0n);249    expect(await rft.getBalance({Substrate: charlie.address})).to.be.deep.equal(0n);250  });251252  itSub('transferFrom burnt token before approve NFT', async ({helper}) => {253    const collection = await helper.nft.mintCollection(alice, {name: 'TransferFrom-Neg-10', description: '', tokenPrefix: 'TF'});254    await collection.setLimits(alice, {ownerCanTransfer: true});255    const nft = await collection.mintToken(alice, {Substrate: alice.address});256257    await nft.burn(alice);258    await expect(nft.approve(alice, {Substrate: bob.address})).to.be.rejectedWith(/common\.TokenNotFound/);259260    await expect(nft.transferFrom(261      bob,262      {Substrate: alice.address}, 263      {Substrate: charlie.address},264    )).to.be.rejectedWith(/common\.ApprovedValueTooLow/);265  });266267  itSub('transferFrom burnt token before approve Fungible', async ({helper}) => {268    const collection = await helper.ft.mintCollection(alice, {name: 'TransferFrom-Neg-11', description: '', tokenPrefix: 'TF'});269    await collection.setLimits(alice, {ownerCanTransfer: true});270    await collection.mint(alice, {Substrate: alice.address}, 10n);271272    await collection.burnTokens(alice, 10n);273    await expect(collection.approveTokens(alice, {Substrate: bob.address})).to.be.not.rejected;274275    await expect(collection.transferFrom(276      alice,277      {Substrate: alice.address}, 278      {Substrate: charlie.address},279    )).to.be.rejectedWith(/common\.TokenValueTooLow/);280  });281282  itSub.ifWithPallets('transferFrom burnt token before approve ReFungible', [Pallets.ReFungible], async ({helper}) => {283    const collection = await helper.rft.mintCollection(alice, {name: 'TransferFrom-Neg-12', description: '', tokenPrefix: 'TF'});284    await collection.setLimits(alice, {ownerCanTransfer: true});285    const rft = await collection.mintToken(alice, {Substrate: alice.address}, 10n);286287    await rft.burn(alice, 10n);288    await expect(rft.approve(alice, {Substrate: bob.address})).to.be.rejectedWith(/common\.CantApproveMoreThanOwned/);289290    await expect(rft.transferFrom(291      alice,292      {Substrate: alice.address}, 293      {Substrate: charlie.address},294    )).to.be.rejectedWith(/common\.TokenValueTooLow/);295  });296297  itSub('transferFrom burnt token after approve NFT', async ({helper}) => {298    const collection = await helper.nft.mintCollection(alice, {name: 'TransferFrom-Neg-13', description: '', tokenPrefix: 'TF'});299    const nft = await collection.mintToken(alice, {Substrate: alice.address});300301    await nft.approve(alice, {Substrate: bob.address});302    expect(await nft.isApproved({Substrate: bob.address})).to.be.true;303304    await nft.burn(alice);305306    await expect(nft.transferFrom(307      bob,308      {Substrate: alice.address}, 309      {Substrate: charlie.address},310    )).to.be.rejectedWith(/common\.ApprovedValueTooLow/);311  });312313  itSub('transferFrom burnt token after approve Fungible', async ({helper}) => {314    const collection = await helper.ft.mintCollection(alice, {name: 'TransferFrom-Neg-14', description: '', tokenPrefix: 'TF'});315    await collection.mint(alice, {Substrate: alice.address}, 10n);316317    await collection.approveTokens(alice, {Substrate: bob.address});318    expect(await collection.getApprovedTokens({Substrate: alice.address}, {Substrate: bob.address})).to.be.eq(1n);319320    await collection.burnTokens(alice, 10n);321322    await expect(collection.transferFrom(323      bob,324      {Substrate: alice.address}, 325      {Substrate: charlie.address},326    )).to.be.rejectedWith(/common\.TokenValueTooLow/);327  });328329  itSub.ifWithPallets('transferFrom burnt token after approve ReFungible', [Pallets.ReFungible], async ({helper}) => {330    const collection = await helper.rft.mintCollection(alice, {name: 'TransferFrom-Neg-15', description: '', tokenPrefix: 'TF'});331    const rft = await collection.mintToken(alice, {Substrate: alice.address}, 10n);332333    await rft.approve(alice, {Substrate: bob.address}, 10n);334    expect(await rft.getApprovedPieces({Substrate: alice.address}, {Substrate: bob.address})).to.be.eq(10n);335336    await rft.burn(alice, 10n);337338    await expect(rft.transferFrom(339      bob,340      {Substrate: alice.address}, 341      {Substrate: charlie.address},342    )).to.be.rejectedWith(/common\.ApprovedValueTooLow/);343  });344345  itSub('fails when called by collection owner on non-owned item when OwnerCanTransfer == false', async ({helper}) => {346    const collection = await helper.nft.mintCollection(alice, {name: 'TransferFrom-Neg-16', description: '', tokenPrefix: 'TF'});347    const nft = await collection.mintToken(alice, {Substrate: bob.address});348349    await collection.setLimits(alice, {ownerCanTransfer: false});350351    await expect(nft.transferFrom(352      alice,353      {Substrate: bob.address}, 354      {Substrate: charlie.address},355    )).to.be.rejectedWith(/common\.ApprovedValueTooLow/);356  });357});
after · tests/src/transferFrom.test.ts
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 {IKeyringPair} from '@polkadot/types/types';18import {itSub, Pallets, usingPlaygrounds, expect} from './util/playgrounds';1920describe('Integration Test transferFrom(from, recipient, collection_id, item_id, value):', () => {21  let alice: IKeyringPair;22  let bob: IKeyringPair;23  let charlie: IKeyringPair;2425  before(async () => {26    await usingPlaygrounds(async (helper, privateKey) => {27      const donor = privateKey('//Alice');28      [alice, bob, charlie] = await helper.arrange.createAccounts([20n, 10n, 10n], donor);29    });30  });3132  itSub('[nft] Execute the extrinsic and check nftItemList - owner of token', async ({helper}) => {33    const collection = await helper.nft.mintCollection(alice, {name: 'TransferFrom-1', description: '', tokenPrefix: 'TF'});34    const nft = await collection.mintToken(alice, {Substrate: alice.address});35    await nft.approve(alice, {Substrate: bob.address});36    expect(await nft.isApproved({Substrate: bob.address})).to.be.true;3738    await nft.transferFrom(bob, {Substrate: alice.address}, {Substrate: charlie.address});39    expect(await nft.getOwner()).to.be.deep.equal({Substrate: charlie.address});40  });4142  itSub('[fungible] Execute the extrinsic and check nftItemList - owner of token', async ({helper}) => {43    const collection = await helper.ft.mintCollection(alice, {name: 'TransferFrom-2', description: '', tokenPrefix: 'TF'});44    await collection.mint(alice, {Substrate: alice.address}, 10n);45    await collection.approveTokens(alice, {Substrate: bob.address}, 7n);46    expect(await collection.getApprovedTokens({Substrate: alice.address}, {Substrate: bob.address})).to.be.equal(7n);47    48    await collection.transferFrom(bob, {Substrate: alice.address}, {Substrate: charlie.address}, 6n);49    expect(await collection.getBalance({Substrate: charlie.address})).to.be.equal(6n);50    expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(4n);51    expect(await collection.getApprovedTokens({Substrate: alice.address}, {Substrate: bob.address})).to.be.equal(1n);52  });5354  itSub.ifWithPallets('[refungible] Execute the extrinsic and check nftItemList - owner of token', [Pallets.ReFungible], async ({helper}) => {55    const collection = await helper.rft.mintCollection(alice, {name: 'TransferFrom-3', description: '', tokenPrefix: 'TF'});56    const rft = await collection.mintToken(alice, {Substrate: alice.address}, 10n);57    await rft.approve(alice, {Substrate: bob.address}, 7n);58    expect(await rft.getApprovedPieces({Substrate: alice.address}, {Substrate: bob.address})).to.be.equal(7n);59    60    await rft.transferFrom(bob, {Substrate: alice.address}, {Substrate: charlie.address}, 6n);61    expect(await rft.getBalance({Substrate: charlie.address})).to.be.equal(6n);62    expect(await rft.getBalance({Substrate: alice.address})).to.be.equal(4n);63    expect(await rft.getApprovedPieces({Substrate: alice.address}, {Substrate: bob.address})).to.be.equal(1n);64  });6566  itSub('Should reduce allowance if value is big', async ({helper}) => {67    // fungible68    const collection = await helper.ft.mintCollection(alice, {name: 'TransferFrom-4', description: '', tokenPrefix: 'TF'});69    await collection.mint(alice, {Substrate: alice.address}, 500000n);7071    await collection.approveTokens(alice, {Substrate: bob.address}, 500000n);72    expect(await collection.getApprovedTokens({Substrate: alice.address}, {Substrate: bob.address})).to.be.equal(500000n);73    await collection.transferFrom(bob, {Substrate: alice.address}, {Substrate: charlie.address}, 500000n);74    expect(await collection.getApprovedTokens({Substrate: alice.address}, {Substrate: bob.address})).to.be.equal(0n);75  });7677  itSub('can be called by collection owner on non-owned item when OwnerCanTransfer == true', async ({helper}) => {78    const collection = await helper.nft.mintCollection(alice, {name: 'TransferFrom-5', description: '', tokenPrefix: 'TF'});79    await collection.setLimits(alice, {ownerCanTransfer: true});8081    const nft = await collection.mintToken(alice, {Substrate: bob.address});82    await nft.transferFrom(alice, {Substrate: bob.address}, {Substrate: charlie.address});83    expect(await nft.getOwner()).to.be.deep.equal({Substrate: charlie.address});84  });85});8687describe('Negative Integration Test transferFrom(from, recipient, collection_id, item_id, value):', () => {88  let alice: IKeyringPair;89  let bob: IKeyringPair;90  let charlie: IKeyringPair;9192  before(async () => {93    await usingPlaygrounds(async (helper, privateKey) => {94      const donor = privateKey('//Alice');95      [alice, bob, charlie] = await helper.arrange.createAccounts([50n, 10n, 10n], donor);96    });97  });9899  itSub('transferFrom for a collection that does not exist', async ({helper}) => {100    const collectionId = (1 << 32) - 1;101    await expect(helper.collection.approveToken(alice, collectionId, 0, {Substrate: bob.address}, 1n))102      .to.be.rejectedWith(/common\.CollectionNotFound/);103    await expect(helper.collection.transferTokenFrom(bob, collectionId, 0, {Substrate: alice.address}, {Substrate: bob.address}, 1n))104      .to.be.rejectedWith(/common\.CollectionNotFound/);105  });106107  /* itSub('transferFrom for a collection that was destroyed', async ({helper}) => {108      this test copies approve negative test109  }); */110111  /* itSub('transferFrom a token that does not exist', async ({helper}) => {112    this test copies approve negative test113  }); */114115  /* itSub('transferFrom a token that was deleted', async ({helper}) => {116    this test copies approve negative test117  }); */118119  itSub('[nft] transferFrom for not approved address', async ({helper}) => {120    const collection = await helper.nft.mintCollection(alice, {name: 'TransferFrom-Neg-1', description: '', tokenPrefix: 'TF'});121    const nft = await collection.mintToken(alice, {Substrate: alice.address});122123    await expect(nft.transferFrom(bob, {Substrate: alice.address}, {Substrate: charlie.address}))124      .to.be.rejectedWith(/common\.ApprovedValueTooLow/);125    expect(await nft.getOwner()).to.be.deep.equal({Substrate: alice.address});126  });127128  itSub('[fungible] transferFrom for not approved address', async ({helper}) => {129    const collection = await helper.ft.mintCollection(alice, {name: 'TransferFrom-Neg-1', description: '', tokenPrefix: 'TF'});130    await collection.mint(alice, {Substrate: alice.address}, 10n);131132    await expect(collection.transferFrom(bob, {Substrate: alice.address}, {Substrate: charlie.address}, 5n))133      .to.be.rejectedWith(/common\.ApprovedValueTooLow/);134    expect(await collection.getBalance({Substrate: alice.address})).to.be.deep.equal(10n);135    expect(await collection.getBalance({Substrate: bob.address})).to.be.deep.equal(0n);136    expect(await collection.getBalance({Substrate: charlie.address})).to.be.deep.equal(0n);137  });138139  itSub.ifWithPallets('[refungible] transferFrom for not approved address', [Pallets.ReFungible], async({helper}) => {140    const collection = await helper.rft.mintCollection(alice, {name: 'TransferFrom-Neg-3', description: '', tokenPrefix: 'TF'});141    const rft = await collection.mintToken(alice, {Substrate: alice.address}, 10n);142143    await expect(rft.transferFrom(bob, {Substrate: alice.address}, {Substrate: charlie.address}))144      .to.be.rejectedWith(/common\.ApprovedValueTooLow/);145    expect(await rft.getBalance({Substrate: alice.address})).to.be.deep.equal(10n);146    expect(await rft.getBalance({Substrate: bob.address})).to.be.deep.equal(0n);147    expect(await rft.getBalance({Substrate: charlie.address})).to.be.deep.equal(0n);148  });149150  itSub('[nft] transferFrom incorrect token count', async ({helper}) => {151    const collection = await helper.nft.mintCollection(alice, {name: 'TransferFrom-Neg-4', description: '', tokenPrefix: 'TF'});152    const nft = await collection.mintToken(alice, {Substrate: alice.address});153154    await nft.approve(alice, {Substrate: bob.address});155    expect(await nft.isApproved({Substrate: bob.address})).to.be.true;156157    await expect(helper.collection.transferTokenFrom(158      bob, 159      collection.collectionId, 160      nft.tokenId, 161      {Substrate: alice.address}, 162      {Substrate: charlie.address}, 163      2n,164    )).to.be.rejectedWith(/nonfungible\.NonfungibleItemsHaveNoAmount/);165    expect(await nft.getOwner()).to.be.deep.equal({Substrate: alice.address});166  });167168  itSub('[fungible] transferFrom incorrect token count', async ({helper}) => {169    const collection = await helper.ft.mintCollection(alice, {name: 'TransferFrom-Neg-5', description: '', tokenPrefix: 'TF'});170    await collection.mint(alice, {Substrate: alice.address}, 10n);171172    await collection.approveTokens(alice, {Substrate: bob.address}, 2n);173    expect(await collection.getApprovedTokens({Substrate: alice.address}, {Substrate: bob.address})).to.be.eq(2n);174175    await expect(collection.transferFrom(bob, {Substrate: alice.address}, {Substrate: charlie.address}, 5n))176      .to.be.rejectedWith(/common\.ApprovedValueTooLow/);177    expect(await collection.getBalance({Substrate: alice.address})).to.be.deep.equal(10n);178    expect(await collection.getBalance({Substrate: bob.address})).to.be.deep.equal(0n);179    expect(await collection.getBalance({Substrate: charlie.address})).to.be.deep.equal(0n);180  });181182  itSub.ifWithPallets('[refungible] transferFrom incorrect token count', [Pallets.ReFungible], async ({helper}) => {183    const collection = await helper.rft.mintCollection(alice, {name: 'TransferFrom-Neg-6', description: '', tokenPrefix: 'TF'});184    const rft = await collection.mintToken(alice, {Substrate: alice.address}, 10n);185186    await rft.approve(alice, {Substrate: bob.address}, 5n);187    expect(await rft.getApprovedPieces({Substrate: alice.address}, {Substrate: bob.address})).to.be.eq(5n);188189    await expect(rft.transferFrom(bob, {Substrate: alice.address}, {Substrate: charlie.address}, 7n))190      .to.be.rejectedWith(/common\.ApprovedValueTooLow/);191    expect(await rft.getBalance({Substrate: alice.address})).to.be.deep.equal(10n);192    expect(await rft.getBalance({Substrate: bob.address})).to.be.deep.equal(0n);193    expect(await rft.getBalance({Substrate: charlie.address})).to.be.deep.equal(0n);194  });195196  itSub('[nft] execute transferFrom from account that is not owner of collection', async ({helper}) => {197    const collection = await helper.nft.mintCollection(alice, {name: 'TransferFrom-Neg-7', description: '', tokenPrefix: 'TF'});198    const nft = await collection.mintToken(alice, {Substrate: alice.address});199200    await expect(nft.approve(charlie, {Substrate: bob.address})).to.be.rejectedWith(/common\.CantApproveMoreThanOwned/);201    expect(await nft.isApproved({Substrate: bob.address})).to.be.false;202203    await expect(nft.transferFrom(204      charlie,205      {Substrate: alice.address}, 206      {Substrate: charlie.address},207    )).to.be.rejectedWith(/common\.ApprovedValueTooLow/);208    expect(await nft.getOwner()).to.be.deep.equal({Substrate: alice.address});209  });210211  itSub('[fungible] execute transferFrom from account that is not owner of collection', async ({helper}) => {212    const collection = await helper.ft.mintCollection(alice, {name: 'TransferFrom-Neg-8', description: '', tokenPrefix: 'TF'});213    await collection.mint(alice, {Substrate: alice.address}, 10000n);214215    await expect(collection.approveTokens(charlie, {Substrate: bob.address}, 1n)).to.be.rejectedWith(/common\.CantApproveMoreThanOwned/);216    expect(await collection.getApprovedTokens({Substrate: alice.address}, {Substrate: bob.address})).to.be.eq(0n);217    expect(await collection.getApprovedTokens({Substrate: charlie.address}, {Substrate: bob.address})).to.be.eq(0n);218219    await expect(collection.transferFrom(220      charlie,221      {Substrate: alice.address}, 222      {Substrate: charlie.address},223    )).to.be.rejectedWith(/common\.ApprovedValueTooLow/);224    expect(await collection.getBalance({Substrate: alice.address})).to.be.deep.equal(10000n);225    expect(await collection.getBalance({Substrate: bob.address})).to.be.deep.equal(0n);226    expect(await collection.getBalance({Substrate: charlie.address})).to.be.deep.equal(0n);227  });228229  itSub.ifWithPallets('[refungible] execute transferFrom from account that is not owner of collection', [Pallets.ReFungible], async ({helper}) => {230    const collection = await helper.rft.mintCollection(alice, {name: 'TransferFrom-Neg-9', description: '', tokenPrefix: 'TF'});231    const rft = await collection.mintToken(alice, {Substrate: alice.address}, 10000n);232233    await expect(rft.approve(charlie, {Substrate: bob.address}, 1n)).to.be.rejectedWith(/common\.CantApproveMoreThanOwned/);234    expect(await rft.getApprovedPieces({Substrate: alice.address}, {Substrate: bob.address})).to.be.eq(0n);235    expect(await rft.getApprovedPieces({Substrate: charlie.address}, {Substrate: bob.address})).to.be.eq(0n);236237    await expect(rft.transferFrom(238      charlie,239      {Substrate: alice.address}, 240      {Substrate: charlie.address},241    )).to.be.rejectedWith(/common\.ApprovedValueTooLow/);242    expect(await rft.getBalance({Substrate: alice.address})).to.be.deep.equal(10000n);243    expect(await rft.getBalance({Substrate: bob.address})).to.be.deep.equal(0n);244    expect(await rft.getBalance({Substrate: charlie.address})).to.be.deep.equal(0n);245  });246247  itSub('transferFrom burnt token before approve NFT', async ({helper}) => {248    const collection = await helper.nft.mintCollection(alice, {name: 'TransferFrom-Neg-10', description: '', tokenPrefix: 'TF'});249    await collection.setLimits(alice, {ownerCanTransfer: true});250    const nft = await collection.mintToken(alice, {Substrate: alice.address});251252    await nft.burn(alice);253    await expect(nft.approve(alice, {Substrate: bob.address})).to.be.rejectedWith(/common\.TokenNotFound/);254255    await expect(nft.transferFrom(256      bob,257      {Substrate: alice.address}, 258      {Substrate: charlie.address},259    )).to.be.rejectedWith(/common\.ApprovedValueTooLow/);260  });261262  itSub('transferFrom burnt token before approve Fungible', async ({helper}) => {263    const collection = await helper.ft.mintCollection(alice, {name: 'TransferFrom-Neg-11', description: '', tokenPrefix: 'TF'});264    await collection.setLimits(alice, {ownerCanTransfer: true});265    await collection.mint(alice, {Substrate: alice.address}, 10n);266267    await collection.burnTokens(alice, 10n);268    await expect(collection.approveTokens(alice, {Substrate: bob.address})).to.be.not.rejected;269270    await expect(collection.transferFrom(271      alice,272      {Substrate: alice.address}, 273      {Substrate: charlie.address},274    )).to.be.rejectedWith(/common\.TokenValueTooLow/);275  });276277  itSub.ifWithPallets('transferFrom burnt token before approve ReFungible', [Pallets.ReFungible], async ({helper}) => {278    const collection = await helper.rft.mintCollection(alice, {name: 'TransferFrom-Neg-12', description: '', tokenPrefix: 'TF'});279    await collection.setLimits(alice, {ownerCanTransfer: true});280    const rft = await collection.mintToken(alice, {Substrate: alice.address}, 10n);281282    await rft.burn(alice, 10n);283    await expect(rft.approve(alice, {Substrate: bob.address})).to.be.rejectedWith(/common\.CantApproveMoreThanOwned/);284285    await expect(rft.transferFrom(286      alice,287      {Substrate: alice.address}, 288      {Substrate: charlie.address},289    )).to.be.rejectedWith(/common\.TokenValueTooLow/);290  });291292  itSub('transferFrom burnt token after approve NFT', async ({helper}) => {293    const collection = await helper.nft.mintCollection(alice, {name: 'TransferFrom-Neg-13', description: '', tokenPrefix: 'TF'});294    const nft = await collection.mintToken(alice, {Substrate: alice.address});295296    await nft.approve(alice, {Substrate: bob.address});297    expect(await nft.isApproved({Substrate: bob.address})).to.be.true;298299    await nft.burn(alice);300301    await expect(nft.transferFrom(302      bob,303      {Substrate: alice.address}, 304      {Substrate: charlie.address},305    )).to.be.rejectedWith(/common\.ApprovedValueTooLow/);306  });307308  itSub('transferFrom burnt token after approve Fungible', async ({helper}) => {309    const collection = await helper.ft.mintCollection(alice, {name: 'TransferFrom-Neg-14', description: '', tokenPrefix: 'TF'});310    await collection.mint(alice, {Substrate: alice.address}, 10n);311312    await collection.approveTokens(alice, {Substrate: bob.address});313    expect(await collection.getApprovedTokens({Substrate: alice.address}, {Substrate: bob.address})).to.be.eq(1n);314315    await collection.burnTokens(alice, 10n);316317    await expect(collection.transferFrom(318      bob,319      {Substrate: alice.address}, 320      {Substrate: charlie.address},321    )).to.be.rejectedWith(/common\.TokenValueTooLow/);322  });323324  itSub.ifWithPallets('transferFrom burnt token after approve ReFungible', [Pallets.ReFungible], async ({helper}) => {325    const collection = await helper.rft.mintCollection(alice, {name: 'TransferFrom-Neg-15', description: '', tokenPrefix: 'TF'});326    const rft = await collection.mintToken(alice, {Substrate: alice.address}, 10n);327328    await rft.approve(alice, {Substrate: bob.address}, 10n);329    expect(await rft.getApprovedPieces({Substrate: alice.address}, {Substrate: bob.address})).to.be.eq(10n);330331    await rft.burn(alice, 10n);332333    await expect(rft.transferFrom(334      bob,335      {Substrate: alice.address}, 336      {Substrate: charlie.address},337    )).to.be.rejectedWith(/common\.ApprovedValueTooLow/);338  });339340  itSub('fails when called by collection owner on non-owned item when OwnerCanTransfer == false', async ({helper}) => {341    const collection = await helper.nft.mintCollection(alice, {name: 'TransferFrom-Neg-16', description: '', tokenPrefix: 'TF'});342    const nft = await collection.mintToken(alice, {Substrate: bob.address});343344    await collection.setLimits(alice, {ownerCanTransfer: false});345346    await expect(nft.transferFrom(347      alice,348      {Substrate: bob.address}, 349      {Substrate: charlie.address},350    )).to.be.rejectedWith(/common\.ApprovedValueTooLow/);351  });352});
modifiedtests/src/util/playgrounds/index.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/index.ts
+++ b/tests/src/util/playgrounds/index.ts
@@ -2,12 +2,17 @@
 // SPDX-License-Identifier: Apache-2.0
 
 import {IKeyringPair} from '@polkadot/types/types';
+import chai from 'chai';
+import chaiAsPromised from 'chai-as-promised';
 import {Context} from 'mocha';
 import config from '../../config';
 import '../../interfaces/augment-api-events';
 import {DevUniqueHelper, SilentLogger, SilentConsole} from './unique.dev';
 
 
+chai.use(chaiAsPromised);
+export const expect = chai.expect;
+
 export const usingPlaygrounds = async (code: (helper: DevUniqueHelper, privateKey: (seed: string) => IKeyringPair) => Promise<void>) => {
   const silentConsole = new SilentConsole();
   silentConsole.enable();