git.delta.rocks / unique-network / refs/commits / 55c7c972e8a3

difftreelog

Fix after review

Max Andreev2022-10-04parent: #f6544e6.patch.diff
in: master
Accounts moved inside describe

4 files changed

modifiedtests/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');
modifiedtests/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);
modifiedtests/src/refungible.test.tsdiffbeforeafterboth
122 itSub('Burn some pieces', async ({helper}) => {122 itSub('Burn some pieces', async ({helper}) => {
123 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});123 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
124 const token = await collection.mintToken(alice, 100n);124 const token = await collection.mintToken(alice, 100n);
125 expect(await collection.isTokenExists(token.tokenId)).to.be.true;125 expect(await collection.doesTokenExist(token.tokenId)).to.be.true;
126 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);126 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);
127 expect(await token.burn(alice, 99n)).to.be.true;127 expect(await token.burn(alice, 99n)).to.be.true;
128 expect(await collection.isTokenExists(token.tokenId)).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);129 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(1n);
130 });130 });
131131
132 itSub('Burn all pieces', async ({helper}) => {132 itSub('Burn all pieces', async ({helper}) => {
133 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});133 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
134 const token = await collection.mintToken(alice, 100n);134 const token = await collection.mintToken(alice, 100n);
135 135
136 expect(await collection.isTokenExists(token.tokenId)).to.be.true;136 expect(await collection.doesTokenExist(token.tokenId)).to.be.true;
137 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);137 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);
138138
139 expect(await token.burn(alice, 100n)).to.be.true;139 expect(await token.burn(alice, 100n)).to.be.true;
140 expect(await collection.isTokenExists(token.tokenId)).to.be.false;140 expect(await collection.doesTokenExist(token.tokenId)).to.be.false;
141 });141 });
142142
143 itSub('Burn some pieces for multiple users', async ({helper}) => {143 itSub('Burn some pieces for multiple users', async ({helper}) => {
144 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});144 const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
145 const token = await collection.mintToken(alice, 100n);145 const token = await collection.mintToken(alice, 100n);
146146
147 expect(await collection.isTokenExists(token.tokenId)).to.be.true;147 expect(await collection.doesTokenExist(token.tokenId)).to.be.true;
148 148
149 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(100n);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;150 expect(await token.transfer(alice, {Substrate: bob.address}, 60n)).to.be.true;
154154
155 expect(await token.burn(alice, 40n)).to.be.true;155 expect(await token.burn(alice, 40n)).to.be.true;
156156
157 expect(await collection.isTokenExists(token.tokenId)).to.be.true;157 expect(await collection.doesTokenExist(token.tokenId)).to.be.true;
158 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(0n);158 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(0n);
159159
160 expect(await token.burn(bob, 59n)).to.be.true;160 expect(await token.burn(bob, 59n)).to.be.true;
161161
162 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(1n);162 expect(await token.getBalance({Substrate: bob.address})).to.be.equal(1n);
163 expect(await collection.isTokenExists(token.tokenId)).to.be.true;163 expect(await collection.doesTokenExist(token.tokenId)).to.be.true;
164164
165 expect(await token.burn(bob, 1n)).to.be.true;165 expect(await token.burn(bob, 1n)).to.be.true;
166166
167 expect(await collection.isTokenExists(token.tokenId)).to.be.false;167 expect(await collection.doesTokenExist(token.tokenId)).to.be.false;
168 });168 });
169169
170 itSub('Set allowance for token', async ({helper}) => {170 itSub('Set allowance for token', async ({helper}) => {
modifiedtests/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() {