difftreelog
Fix after review
in: master
Accounts moved inside describe
4 files changed
tests/src/burnItem.test.tsdiffbeforeafterboth17import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';18import {expect, itSub, Pallets, usingPlaygrounds} from './util/playgrounds';18import {expect, itSub, Pallets, usingPlaygrounds} from './util/playgrounds';191920let donor: IKeyringPair;21let alice: IKeyringPair;22let bob: IKeyringPair;232024describe('integration test: ext. burnItem():', () => {21describe('integration test: ext. burnItem():', () => {22 let donor: IKeyringPair;23 let alice: IKeyringPair;24 let bob: IKeyringPair;2525 before(async () => {26 before(async () => {26 await usingPlaygrounds(async (helper, privateKey) => {27 await usingPlaygrounds(async (helper, privateKey) => {34 const token = await collection.mintToken(alice);35 const token = await collection.mintToken(alice);353636 await token.burn(alice);37 await token.burn(alice);37 expect(await token.isExist()).to.be.false;38 expect(await token.doesExist()).to.be.false;38 });39 });394040 itSub('Burn item in Fungible collection', async ({helper}) => {41 itSub('Burn item in Fungible collection', async ({helper}) => {73});74});747575describe('integration test: ext. burnItem() with admin permissions:', () => {76describe('integration test: ext. burnItem() with admin permissions:', () => {77 let donor: IKeyringPair;78 let alice: IKeyringPair;79 let bob: IKeyringPair;8076 before(async () => {81 before(async () => {77 await usingPlaygrounds(async (helper, privateKey) => {82 await usingPlaygrounds(async (helper, privateKey) => {87 const token = await collection.mintToken(alice);92 const token = await collection.mintToken(alice);889389 await token.burnFrom(bob, {Substrate: alice.address});94 await token.burnFrom(bob, {Substrate: alice.address});90 expect(await token.isExist()).to.be.false;95 expect(await token.doesExist()).to.be.false;91 });96 });929793 itSub('Burn item in Fungible collection', async ({helper}) => {98 itSub('Burn item in Fungible collection', async ({helper}) => {107 const token = await collection.mintToken(alice, 100n);112 const token = await collection.mintToken(alice, 100n);108113109 await token.burnFrom(bob, {Substrate: alice.address}, 100n);114 await token.burnFrom(bob, {Substrate: alice.address}, 100n);110 expect(await token.isExist()).to.be.false;115 expect(await token.doesExist()).to.be.false;111 });116 });112});117});113118114describe('Negative integration test: ext. burnItem():', () => {119describe('Negative integration test: ext. burnItem():', () => {120 let donor: IKeyringPair;121 let alice: IKeyringPair;122 let bob: IKeyringPair;123115 before(async () => {124 before(async () => {116 await usingPlaygrounds(async (helper, privateKey) => {125 await usingPlaygrounds(async (helper, privateKey) => {tests/src/fungible.test.tsdiffbeforeafterboth101 const collection = await helper.ft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});101 const collection = await helper.ft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});102 await collection.mint(alice, 500n);102 await collection.mint(alice, 500n);103103104 expect(await collection.isTokenExists(0)).to.be.true;104 expect(await collection.doesTokenExist(0)).to.be.true;105 expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(500n);105 expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(500n);106 expect(await collection.burnTokens(alice, 499n)).to.be.true;106 expect(await collection.burnTokens(alice, 499n)).to.be.true;107 expect(await collection.isTokenExists(0)).to.be.true;107 expect(await collection.doesTokenExist(0)).to.be.true;108 expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(1n);108 expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(1n);109 });109 });110 110 111 itSub('Burn all tokens ', async ({helper}) => {111 itSub('Burn all tokens ', async ({helper}) => {112 const collection = await helper.ft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});112 const collection = await helper.ft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});113 await collection.mint(alice, 500n);113 await collection.mint(alice, 500n);114114115 expect(await collection.isTokenExists(0)).to.be.true;115 expect(await collection.doesTokenExist(0)).to.be.true;116 expect(await collection.burnTokens(alice, 500n)).to.be.true;116 expect(await collection.burnTokens(alice, 500n)).to.be.true;117 expect(await collection.isTokenExists(0)).to.be.true;117 expect(await collection.doesTokenExist(0)).to.be.true;118118119 expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(0n);119 expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(0n);120 expect(await collection.getTotalPieces()).to.be.equal(0n);120 expect(await collection.getTotalPieces()).to.be.equal(0n);tests/src/refungible.test.tsdiffbeforeafterboth122 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 });131131132 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);138138139 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 });142142143 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);146146147 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;154154155 expect(await token.burn(alice, 40n)).to.be.true;155 expect(await token.burn(alice, 40n)).to.be.true;156156157 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);159159160 expect(await token.burn(bob, 59n)).to.be.true;160 expect(await token.burn(bob, 59n)).to.be.true;161161162 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;164164165 expect(await token.burn(bob, 1n)).to.be.true;165 expect(await token.burn(bob, 1n)).to.be.true;166166167 expect(await collection.isTokenExists(token.tokenId)).to.be.false;167 expect(await collection.doesTokenExist(token.tokenId)).to.be.false;168 });168 });169169170 itSub('Set allowance for token', async ({helper}) => {170 itSub('Set allowance for token', async ({helper}) => {tests/src/util/playgrounds/unique.tsdiffbeforeafterboth1109 return (await this.helper.callRpc('api.rpc.unique.lastTokenId', [collectionId])).toNumber();1109 return (await this.helper.callRpc('api.rpc.unique.lastTokenId', [collectionId])).toNumber();1110 }1110 }111111111112 /**1112 /**1113 * Check if token exists1113 * Check if token exists1114 *1114 *1115 * @param collectionId ID of collection1115 * @param collectionId ID of collection1116 * @param tokenId ID of token1116 * @param tokenId ID of token1117 * @example isTokenExists(10, 20);1117 * @example doesTokenExist(10, 20);1118 * @returns true if the token exists, otherwise false1118 * @returns true if the token exists, otherwise false1119 */1119 */1120 async isTokenExists(collectionId: number, tokenId: number): Promise<boolean> {1120 async doesTokenExist(collectionId: number, tokenId: number): Promise<boolean> {1121 return (await this.helper.callRpc('api.rpc.unique.tokenExists', [collectionId, tokenId])).toJSON();1121 return (await this.helper.callRpc('api.rpc.unique.tokenExists', [collectionId, tokenId])).toJSON();1122 }1122 }1123}1123}2277 return await this.helper.collection.getLastTokenId(this.collectionId);2277 return await this.helper.collection.getLastTokenId(this.collectionId);2278 }2278 }227922792280 async isTokenExists(tokenId: number) {2280 async doesTokenExist(tokenId: number) {2281 return await this.helper.collection.isTokenExists(this.collectionId, tokenId);2281 return await this.helper.collection.doesTokenExist(this.collectionId, tokenId);2282 }2282 }228322832284 async getAdmins() {2284 async getAdmins() {2607 return await this.collection.deleteTokenProperties(signer, this.tokenId, propertyKeys);2607 return await this.collection.deleteTokenProperties(signer, this.tokenId, propertyKeys);2608 }2608 }260926092610 async isExist() {2610 async doesExist() {2611 return await this.collection.isTokenExists(this.tokenId);2611 return await this.collection.doesTokenExist(this.tokenId);2612 }2612 }261326132614 nestingAccount() {2614 nestingAccount() {