difftreelog
Fix after review
in: master
Accounts moved inside describe
4 files changed
tests/src/burnItem.test.tsdiffbeforeafterboth--- a/tests/src/burnItem.test.ts
+++ b/tests/src/burnItem.test.ts
@@ -17,11 +17,12 @@
import {IKeyringPair} from '@polkadot/types/types';
import {expect, itSub, Pallets, usingPlaygrounds} from './util/playgrounds';
-let donor: IKeyringPair;
-let alice: IKeyringPair;
-let bob: IKeyringPair;
describe('integration test: ext. burnItem():', () => {
+ let donor: IKeyringPair;
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
+
before(async () => {
await usingPlaygrounds(async (helper, privateKey) => {
donor = privateKey('//Alice');
@@ -34,7 +35,7 @@
const token = await collection.mintToken(alice);
await token.burn(alice);
- expect(await token.isExist()).to.be.false;
+ expect(await token.doesExist()).to.be.false;
});
itSub('Burn item in Fungible collection', async ({helper}) => {
@@ -73,6 +74,10 @@
});
describe('integration test: ext. burnItem() with admin permissions:', () => {
+ let donor: IKeyringPair;
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
+
before(async () => {
await usingPlaygrounds(async (helper, privateKey) => {
donor = privateKey('//Alice');
@@ -87,7 +92,7 @@
const token = await collection.mintToken(alice);
await token.burnFrom(bob, {Substrate: alice.address});
- expect(await token.isExist()).to.be.false;
+ expect(await token.doesExist()).to.be.false;
});
itSub('Burn item in Fungible collection', async ({helper}) => {
@@ -107,11 +112,15 @@
const token = await collection.mintToken(alice, 100n);
await token.burnFrom(bob, {Substrate: alice.address}, 100n);
- expect(await token.isExist()).to.be.false;
+ expect(await token.doesExist()).to.be.false;
});
});
describe('Negative integration test: ext. burnItem():', () => {
+ let donor: IKeyringPair;
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
+
before(async () => {
await usingPlaygrounds(async (helper, privateKey) => {
donor = privateKey('//Alice');
tests/src/fungible.test.tsdiffbeforeafterboth--- a/tests/src/fungible.test.ts
+++ b/tests/src/fungible.test.ts
@@ -101,10 +101,10 @@
const collection = await helper.ft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
await collection.mint(alice, 500n);
- expect(await collection.isTokenExists(0)).to.be.true;
+ expect(await collection.doesTokenExist(0)).to.be.true;
expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(500n);
expect(await collection.burnTokens(alice, 499n)).to.be.true;
- expect(await collection.isTokenExists(0)).to.be.true;
+ expect(await collection.doesTokenExist(0)).to.be.true;
expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(1n);
});
@@ -112,9 +112,9 @@
const collection = await helper.ft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
await collection.mint(alice, 500n);
- expect(await collection.isTokenExists(0)).to.be.true;
+ expect(await collection.doesTokenExist(0)).to.be.true;
expect(await collection.burnTokens(alice, 500n)).to.be.true;
- expect(await collection.isTokenExists(0)).to.be.true;
+ expect(await collection.doesTokenExist(0)).to.be.true;
expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(0n);
expect(await collection.getTotalPieces()).to.be.equal(0n);
tests/src/refungible.test.tsdiffbeforeafterboth1// 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, requirePalletsOrSkip, usingPlaygrounds, expect} from './util/playgrounds';1920const MAX_REFUNGIBLE_PIECES = 1_000_000_000_000_000_000_000n;2122describe('integration test: Refungible functionality:', async () => {23 let alice: IKeyringPair;24 let bob: IKeyringPair;2526 before(async function() {27 await usingPlaygrounds(async (helper, privateKey) => {28 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);2930 const donor = privateKey('//Alice');31 [alice, bob] = await helper.arrange.createAccounts([100n, 10n], donor);32 });33 });34 35 itSub('Create refungible collection and token', async ({helper}) => {36 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});3738 const itemCountBefore = await collection.getLastTokenId();39 const token = await collection.mintToken(alice, 100n);40 41 const itemCountAfter = await collection.getLastTokenId();42 43 // What to expect44 expect(token?.tokenId).to.be.gte(itemCountBefore);45 expect(itemCountAfter).to.be.equal(itemCountBefore + 1);46 expect(itemCountAfter.toString()).to.be.equal(token?.tokenId.toString());47 });48 49 itSub('Checking RPC methods when interacting with maximum allowed values (MAX_REFUNGIBLE_PIECES)', async ({helper}) => {50 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});51 52 const token = await collection.mintToken(alice, MAX_REFUNGIBLE_PIECES);53 54 expect(await collection.getTokenBalance(token.tokenId, {Substrate: alice.address})).to.be.equal(MAX_REFUNGIBLE_PIECES);55 56 await collection.transferToken(alice, token.tokenId, {Substrate: bob.address}, MAX_REFUNGIBLE_PIECES);57 expect(await collection.getTokenBalance(token.tokenId, {Substrate: bob.address})).to.be.equal(MAX_REFUNGIBLE_PIECES);58 expect(await token.getTotalPieces()).to.be.equal(MAX_REFUNGIBLE_PIECES);59 60 await expect(collection.mintToken(alice, MAX_REFUNGIBLE_PIECES + 1n))61 .to.eventually.be.rejectedWith(/refungible\.WrongRefungiblePieces/);62 });63 64 itSub('RPC method tokenOnewrs for refungible collection and token', async ({helper, privateKey}) => {65 const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};66 const facelessCrowd = Array(7).fill(0).map((_, i) => ({Substrate: privateKey(`//Alice+${i}`).address}));6768 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});6970 const token = await collection.mintToken(alice, 10_000n);7172 await token.transfer(alice, {Substrate: bob.address}, 1000n);73 await token.transfer(alice, ethAcc, 900n);74 75 for (let i = 0; i < 7; i++) {76 await token.transfer(alice, facelessCrowd[i], 50n * BigInt(i + 1));77 } 7879 const owners = await token.getTop10Owners();8081 // What to expect82 expect(owners).to.deep.include.members([{Substrate: alice.address}, ethAcc, {Substrate: bob.address}, ...facelessCrowd]);83 expect(owners.length).to.be.equal(10);84 85 const eleven = privateKey('//ALice+11');86 expect(await token.transfer(alice, {Substrate: eleven.address}, 10n)).to.be.true;87 expect((await token.getTop10Owners()).length).to.be.equal(10);88 });89 90 itSub('Transfer token pieces', async ({helper}) => {91 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});92 const token = await collection.mintToken(alice, 100n);9394 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);95 expect(await token.transfer(alice, {Substrate: bob.address}, 60n)).to.be.true;96 97 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(40n);98 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(60n);99 100 await expect(token.transfer(alice, {Substrate: bob.address}, 41n))101 .to.eventually.be.rejectedWith(/common\.TokenValueTooLow/);102 });103104 itSub('Create multiple tokens', async ({helper}) => {105 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});106 // TODO: fix mintMultipleTokens107 // await collection.mintMultipleTokens(alice, [108 // {owner: {Substrate: alice.address}, pieces: 1n},109 // {owner: {Substrate: alice.address}, pieces: 2n},110 // {owner: {Substrate: alice.address}, pieces: 100n},111 // ]);112 await helper.rft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, [113 {pieces: 1n}, 114 {pieces: 2n}, 115 {pieces: 100n},116 ]);117 const lastTokenId = await collection.getLastTokenId();118 expect(lastTokenId).to.be.equal(3);119 expect(await collection.getTokenBalance(lastTokenId, {Substrate: alice.address})).to.be.equal(100n);120 });121122 itSub('Burn some pieces', async ({helper}) => {123 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});124 const token = await collection.mintToken(alice, 100n);125 expect(await collection.isTokenExists(token.tokenId)).to.be.true;126 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);127 expect(await token.burn(alice, 99n)).to.be.true;128 expect(await collection.isTokenExists(token.tokenId)).to.be.true;129 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(1n);130 });131132 itSub('Burn all pieces', async ({helper}) => {133 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});134 const token = await collection.mintToken(alice, 100n);135 136 expect(await collection.isTokenExists(token.tokenId)).to.be.true;137 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);138139 expect(await token.burn(alice, 100n)).to.be.true;140 expect(await collection.isTokenExists(token.tokenId)).to.be.false;141 });142143 itSub('Burn some pieces for multiple users', async ({helper}) => {144 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});145 const token = await collection.mintToken(alice, 100n);146147 expect(await collection.isTokenExists(token.tokenId)).to.be.true;148 149 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);150 expect(await token.transfer(alice, {Substrate: bob.address}, 60n)).to.be.true;151152 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(40n);153 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(60n);154155 expect(await token.burn(alice, 40n)).to.be.true;156157 expect(await collection.isTokenExists(token.tokenId)).to.be.true;158 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(0n);159160 expect(await token.burn(bob, 59n)).to.be.true;161162 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(1n);163 expect(await collection.isTokenExists(token.tokenId)).to.be.true;164165 expect(await token.burn(bob, 1n)).to.be.true;166167 expect(await collection.isTokenExists(token.tokenId)).to.be.false;168 });169170 itSub('Set allowance for token', async ({helper}) => {171 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});172 const token = await collection.mintToken(alice, 100n);173 174 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);175176 expect(await token.approve(alice, {Substrate: bob.address}, 60n)).to.be.true;177 expect(await token.getApprovedPieces({Substrate: alice.address}, {Substrate: bob.address})).to.be.equal(60n);178179 expect(await token.transferFrom(bob, {Substrate: alice.address}, {Substrate: bob.address}, 20n)).to.be.true;180 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(80n);181 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(20n);182 expect(await token.getApprovedPieces({Substrate: alice.address}, {Substrate: bob.address})).to.be.equal(40n);183 });184185 itSub('Repartition', async ({helper}) => {186 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});187 const token = await collection.mintToken(alice, 100n);188189 expect(await token.repartition(alice, 200n)).to.be.true;190 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(200n);191 expect(await token.getTotalPieces()).to.be.equal(200n);192 193 expect(await token.transfer(alice, {Substrate: bob.address}, 110n)).to.be.true;194 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(90n);195 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(110n);196 197 await expect(token.repartition(alice, 80n))198 .to.eventually.be.rejectedWith(/refungible\.RepartitionWhileNotOwningAllPieces/);199 200 expect(await token.transfer(alice, {Substrate: bob.address}, 90n)).to.be.true;201 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(0n);202 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(200n);203204 expect(await token.repartition(bob, 150n)).to.be.true;205 await expect(token.transfer(bob, {Substrate: alice.address}, 160n))206 .to.eventually.be.rejectedWith(/common\.TokenValueTooLow/);207 });208209 itSub('Repartition with increased amount', async ({helper}) => {210 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});211 const token = await collection.mintToken(alice, 100n);212 await token.repartition(alice, 200n);213 const chainEvents = helper.chainLog.slice(-1)[0].events;214 expect(chainEvents).to.deep.include({215 section: 'common',216 method: 'ItemCreated',217 index: [66, 2],218 data: [219 collection.collectionId,220 token.tokenId,221 {substrate: alice.address}, 222 100n,223 ],224 phase: {applyExtrinsic: 2},225 });226 });227228 itSub('Repartition with decreased amount', async ({helper}) => {229 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});230 const token = await collection.mintToken(alice, 100n);231 await token.repartition(alice, 50n);232 const chainEvents = helper.chainLog.slice(-1)[0].events;233 expect(chainEvents).to.deep.include({234 method: 'ItemDestroyed',235 section: 'common',236 index: [66, 3],237 data: [238 collection.collectionId,239 token.tokenId,240 {substrate: alice.address}, 241 50n,242 ],243 phase: {applyExtrinsic: 2},244 });245 });246 247 itSub('Create new collection with properties', async ({helper}) => {248 const properties = [{key: 'key1', value: 'val1'}];249 const tokenPropertyPermissions = [{key: 'key1', permission: {tokenOwner: true, mutable: false, collectionAdmin: true}}];250 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test', properties, tokenPropertyPermissions});251 const info = await collection.getData();252 expect(info?.raw.properties).to.be.deep.equal(properties);253 expect(info?.raw.tokenPropertyPermissions).to.be.deep.equal(tokenPropertyPermissions);254 });255});2561// 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, requirePalletsOrSkip, usingPlaygrounds, expect} from './util/playgrounds';1920const MAX_REFUNGIBLE_PIECES = 1_000_000_000_000_000_000_000n;2122describe('integration test: Refungible functionality:', async () => {23 let alice: IKeyringPair;24 let bob: IKeyringPair;2526 before(async function() {27 await usingPlaygrounds(async (helper, privateKey) => {28 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);2930 const donor = privateKey('//Alice');31 [alice, bob] = await helper.arrange.createAccounts([100n, 10n], donor);32 });33 });34 35 itSub('Create refungible collection and token', async ({helper}) => {36 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});3738 const itemCountBefore = await collection.getLastTokenId();39 const token = await collection.mintToken(alice, 100n);40 41 const itemCountAfter = await collection.getLastTokenId();42 43 // What to expect44 expect(token?.tokenId).to.be.gte(itemCountBefore);45 expect(itemCountAfter).to.be.equal(itemCountBefore + 1);46 expect(itemCountAfter.toString()).to.be.equal(token?.tokenId.toString());47 });48 49 itSub('Checking RPC methods when interacting with maximum allowed values (MAX_REFUNGIBLE_PIECES)', async ({helper}) => {50 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});51 52 const token = await collection.mintToken(alice, MAX_REFUNGIBLE_PIECES);53 54 expect(await collection.getTokenBalance(token.tokenId, {Substrate: alice.address})).to.be.equal(MAX_REFUNGIBLE_PIECES);55 56 await collection.transferToken(alice, token.tokenId, {Substrate: bob.address}, MAX_REFUNGIBLE_PIECES);57 expect(await collection.getTokenBalance(token.tokenId, {Substrate: bob.address})).to.be.equal(MAX_REFUNGIBLE_PIECES);58 expect(await token.getTotalPieces()).to.be.equal(MAX_REFUNGIBLE_PIECES);59 60 await expect(collection.mintToken(alice, MAX_REFUNGIBLE_PIECES + 1n))61 .to.eventually.be.rejectedWith(/refungible\.WrongRefungiblePieces/);62 });63 64 itSub('RPC method tokenOnewrs for refungible collection and token', async ({helper, privateKey}) => {65 const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};66 const facelessCrowd = Array(7).fill(0).map((_, i) => ({Substrate: privateKey(`//Alice+${i}`).address}));6768 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});6970 const token = await collection.mintToken(alice, 10_000n);7172 await token.transfer(alice, {Substrate: bob.address}, 1000n);73 await token.transfer(alice, ethAcc, 900n);74 75 for (let i = 0; i < 7; i++) {76 await token.transfer(alice, facelessCrowd[i], 50n * BigInt(i + 1));77 } 7879 const owners = await token.getTop10Owners();8081 // What to expect82 expect(owners).to.deep.include.members([{Substrate: alice.address}, ethAcc, {Substrate: bob.address}, ...facelessCrowd]);83 expect(owners.length).to.be.equal(10);84 85 const eleven = privateKey('//ALice+11');86 expect(await token.transfer(alice, {Substrate: eleven.address}, 10n)).to.be.true;87 expect((await token.getTop10Owners()).length).to.be.equal(10);88 });89 90 itSub('Transfer token pieces', async ({helper}) => {91 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});92 const token = await collection.mintToken(alice, 100n);9394 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);95 expect(await token.transfer(alice, {Substrate: bob.address}, 60n)).to.be.true;96 97 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(40n);98 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(60n);99 100 await expect(token.transfer(alice, {Substrate: bob.address}, 41n))101 .to.eventually.be.rejectedWith(/common\.TokenValueTooLow/);102 });103104 itSub('Create multiple tokens', async ({helper}) => {105 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});106 // TODO: fix mintMultipleTokens107 // await collection.mintMultipleTokens(alice, [108 // {owner: {Substrate: alice.address}, pieces: 1n},109 // {owner: {Substrate: alice.address}, pieces: 2n},110 // {owner: {Substrate: alice.address}, pieces: 100n},111 // ]);112 await helper.rft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, [113 {pieces: 1n}, 114 {pieces: 2n}, 115 {pieces: 100n},116 ]);117 const lastTokenId = await collection.getLastTokenId();118 expect(lastTokenId).to.be.equal(3);119 expect(await collection.getTokenBalance(lastTokenId, {Substrate: alice.address})).to.be.equal(100n);120 });121122 itSub('Burn some pieces', async ({helper}) => {123 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});124 const token = await collection.mintToken(alice, 100n);125 expect(await collection.doesTokenExist(token.tokenId)).to.be.true;126 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);127 expect(await token.burn(alice, 99n)).to.be.true;128 expect(await collection.doesTokenExist(token.tokenId)).to.be.true;129 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(1n);130 });131132 itSub('Burn all pieces', async ({helper}) => {133 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});134 const token = await collection.mintToken(alice, 100n);135 136 expect(await collection.doesTokenExist(token.tokenId)).to.be.true;137 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);138139 expect(await token.burn(alice, 100n)).to.be.true;140 expect(await collection.doesTokenExist(token.tokenId)).to.be.false;141 });142143 itSub('Burn some pieces for multiple users', async ({helper}) => {144 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});145 const token = await collection.mintToken(alice, 100n);146147 expect(await collection.doesTokenExist(token.tokenId)).to.be.true;148 149 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);150 expect(await token.transfer(alice, {Substrate: bob.address}, 60n)).to.be.true;151152 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(40n);153 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(60n);154155 expect(await token.burn(alice, 40n)).to.be.true;156157 expect(await collection.doesTokenExist(token.tokenId)).to.be.true;158 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(0n);159160 expect(await token.burn(bob, 59n)).to.be.true;161162 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(1n);163 expect(await collection.doesTokenExist(token.tokenId)).to.be.true;164165 expect(await token.burn(bob, 1n)).to.be.true;166167 expect(await collection.doesTokenExist(token.tokenId)).to.be.false;168 });169170 itSub('Set allowance for token', async ({helper}) => {171 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});172 const token = await collection.mintToken(alice, 100n);173 174 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);175176 expect(await token.approve(alice, {Substrate: bob.address}, 60n)).to.be.true;177 expect(await token.getApprovedPieces({Substrate: alice.address}, {Substrate: bob.address})).to.be.equal(60n);178179 expect(await token.transferFrom(bob, {Substrate: alice.address}, {Substrate: bob.address}, 20n)).to.be.true;180 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(80n);181 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(20n);182 expect(await token.getApprovedPieces({Substrate: alice.address}, {Substrate: bob.address})).to.be.equal(40n);183 });184185 itSub('Repartition', async ({helper}) => {186 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});187 const token = await collection.mintToken(alice, 100n);188189 expect(await token.repartition(alice, 200n)).to.be.true;190 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(200n);191 expect(await token.getTotalPieces()).to.be.equal(200n);192 193 expect(await token.transfer(alice, {Substrate: bob.address}, 110n)).to.be.true;194 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(90n);195 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(110n);196 197 await expect(token.repartition(alice, 80n))198 .to.eventually.be.rejectedWith(/refungible\.RepartitionWhileNotOwningAllPieces/);199 200 expect(await token.transfer(alice, {Substrate: bob.address}, 90n)).to.be.true;201 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(0n);202 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(200n);203204 expect(await token.repartition(bob, 150n)).to.be.true;205 await expect(token.transfer(bob, {Substrate: alice.address}, 160n))206 .to.eventually.be.rejectedWith(/common\.TokenValueTooLow/);207 });208209 itSub('Repartition with increased amount', async ({helper}) => {210 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});211 const token = await collection.mintToken(alice, 100n);212 await token.repartition(alice, 200n);213 const chainEvents = helper.chainLog.slice(-1)[0].events;214 expect(chainEvents).to.deep.include({215 section: 'common',216 method: 'ItemCreated',217 index: [66, 2],218 data: [219 collection.collectionId,220 token.tokenId,221 {substrate: alice.address}, 222 100n,223 ],224 phase: {applyExtrinsic: 2},225 });226 });227228 itSub('Repartition with decreased amount', async ({helper}) => {229 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});230 const token = await collection.mintToken(alice, 100n);231 await token.repartition(alice, 50n);232 const chainEvents = helper.chainLog.slice(-1)[0].events;233 expect(chainEvents).to.deep.include({234 method: 'ItemDestroyed',235 section: 'common',236 index: [66, 3],237 data: [238 collection.collectionId,239 token.tokenId,240 {substrate: alice.address}, 241 50n,242 ],243 phase: {applyExtrinsic: 2},244 });245 });246 247 itSub('Create new collection with properties', async ({helper}) => {248 const properties = [{key: 'key1', value: 'val1'}];249 const tokenPropertyPermissions = [{key: 'key1', permission: {tokenOwner: true, mutable: false, collectionAdmin: true}}];250 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test', properties, tokenPropertyPermissions});251 const info = await collection.getData();252 expect(info?.raw.properties).to.be.deep.equal(properties);253 expect(info?.raw.tokenPropertyPermissions).to.be.deep.equal(tokenPropertyPermissions);254 });255});256tests/src/util/playgrounds/unique.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -1114,10 +1114,10 @@
*
* @param collectionId ID of collection
* @param tokenId ID of token
- * @example isTokenExists(10, 20);
+ * @example doesTokenExist(10, 20);
* @returns true if the token exists, otherwise false
*/
- async isTokenExists(collectionId: number, tokenId: number): Promise<boolean> {
+ async doesTokenExist(collectionId: number, tokenId: number): Promise<boolean> {
return (await this.helper.callRpc('api.rpc.unique.tokenExists', [collectionId, tokenId])).toJSON();
}
}
@@ -2277,8 +2277,8 @@
return await this.helper.collection.getLastTokenId(this.collectionId);
}
- async isTokenExists(tokenId: number) {
- return await this.helper.collection.isTokenExists(this.collectionId, tokenId);
+ async doesTokenExist(tokenId: number) {
+ return await this.helper.collection.doesTokenExist(this.collectionId, tokenId);
}
async getAdmins() {
@@ -2607,8 +2607,8 @@
return await this.collection.deleteTokenProperties(signer, this.tokenId, propertyKeys);
}
- async isExist() {
- return await this.collection.isTokenExists(this.tokenId);
+ async doesExist() {
+ return await this.collection.doesTokenExist(this.tokenId);
}
nestingAccount() {