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});
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();