git.delta.rocks / unique-network / refs/commits / fd8f5c47fa0c

difftreelog

Tests: fix false positive tests

Max Andreev2023-04-21parent: #642e462.patch.diff
in: master
Tests should try trasferFrom token owner

1 file changed

modifiedtests/src/approve.test.tsdiffbeforeafterboth
277 });277 });
278278
279 itSub('NFT', async ({helper}) => {279 itSub('NFT', async ({helper}) => {
280 const owner = testCase.account(alice);
280 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});281 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
281 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(alice)});282 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: owner});
283
282 await (helper.nft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address});284 await (helper.nft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address});
283 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true;285 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true;
286
284 await (helper.nft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}, 0n);287 await (helper.nft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}, 0n);
285 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.false;288 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.false;
289
286 const transferTokenFromTx = () => helper.nft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: bob.address});290 const transferTokenFromTx = helper.nft.transferTokenFrom(bob, collectionId, tokenId, owner, {Substrate: bob.address});
287 await expect(transferTokenFromTx()).to.be.rejected;291 await expect(transferTokenFromTx).to.be.rejectedWith('common.ApprovedValueTooLow');
288 });292 });
289293
290 itSub('Fungible', async ({helper}) => {294 itSub('Fungible', async ({helper}) => {
295 const owner = testCase.account(alice);
291 const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);296 const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
292 await helper.ft.mintTokens(alice, collectionId, 10n, testCase.account(alice));297 await helper.ft.mintTokens(alice, collectionId, 10n, owner);
293 const tokenId = await helper.ft.getLastTokenId(collectionId);298 const tokenId = await helper.ft.getLastTokenId(collectionId);
294 await (helper.ft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address});299 await (helper.ft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address});
295 const amountBefore = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, testCase.account(alice));300 const amountBefore = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, owner);
296 expect(amountBefore).to.be.equal(BigInt(1));301 expect(amountBefore).to.be.equal(1n);
297302
298 await (helper.ft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}, 0n);303 await (helper.ft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}, 0n);
299 const amountAfter = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, testCase.account(alice));304 const amountAfter = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, owner);
300 expect(amountAfter).to.be.equal(BigInt(0));305 expect(amountAfter).to.be.equal(BigInt(0));
301306
302 const transferTokenFromTx = () => helper.ft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address}, 1n);307 const transferTokenFromTx = helper.ft.transferTokenFrom(bob, collectionId, tokenId, owner, {Substrate: charlie.address}, 1n);
303 await expect(transferTokenFromTx()).to.be.rejected;308 await expect(transferTokenFromTx).to.be.rejectedWith('common.ApprovedValueTooLow');
304 });309 });
305310
306 itSub.ifWithPallets('ReFungible', [Pallets.ReFungible], async ({helper}) => {311 itSub.ifWithPallets('ReFungible', [Pallets.ReFungible], async ({helper}) => {
312 const owner = testCase.account(alice);
307 const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});313 const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
308 const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(alice), pieces: 100n});314 const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner, pieces: 100n});
309 await (helper.rft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address});315 await (helper.rft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address});
310 const amountBefore = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, testCase.account(alice));316 const amountBefore = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, owner);
311 expect(amountBefore).to.be.equal(BigInt(1));317 expect(amountBefore).to.be.equal(1n);
312318
313 await (helper.rft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}, 0n);319 await (helper.rft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}, 0n);
314 const amountAfter = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, testCase.account(alice));320 const amountAfter = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, owner);
315 expect(amountAfter).to.be.equal(BigInt(0));321 expect(amountAfter).to.be.equal(0n);
316322
317 const transferTokenFromTx = () => helper.rft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address}, 100n);323 const transferTokenFromTx = helper.rft.transferTokenFrom(bob, collectionId, tokenId, owner, {Substrate: charlie.address}, 1n);
318 await expect(transferTokenFromTx()).to.be.rejected;324 await expect(transferTokenFromTx).to.be.rejectedWith('common.ApprovedValueTooLow');
319 });325 });
320 });326 });
321327