difftreelog
Use executeExtrinsic
in: master
3 files changed
tests/src/burnItem.test.tsdiffbeforeafterboth182 });182 });183183184 itSub('Zero burn NFT', async ({helper}) => {184 itSub('Zero burn NFT', async ({helper}) => {185 const api = helper.getApi();186 const collection = await helper.nft.mintCollection(alice, {name: 'Coll', description: 'Desc', tokenPrefix: 'T'});185 const collection = await helper.nft.mintCollection(alice, {name: 'Coll', description: 'Desc', tokenPrefix: 'T'});187 const tokenAlice = await collection.mintToken(alice, {Substrate: alice.address});186 const tokenAlice = await collection.mintToken(alice, {Substrate: alice.address});188 const tokenBob = await collection.mintToken(alice, {Substrate: bob.address});187 const tokenBob = await collection.mintToken(alice, {Substrate: bob.address});189 188 190 // 1. Zero burn of own tokens allowed:189 // 1. Zero burn of own tokens allowed:191 await helper.signTransaction(alice, api.tx.unique.burnItem(collection.collectionId, tokenAlice.tokenId, 0));190 await helper.executeExtrinsic(alice, 'api.tx.unique.burnItem', [collection.collectionId, tokenAlice.tokenId, 0]);192 // 2. Zero burn of non-owned tokens not allowed:191 // 2. Zero burn of non-owned tokens not allowed:193 await expect(helper.signTransaction(alice, api.tx.unique.burnItem(collection.collectionId, tokenBob.tokenId, 0))).to.be.rejectedWith('common.NoPermission');192 await expect(helper.executeExtrinsic(alice, 'api.tx.unique.burnItem', [collection.collectionId, tokenBob.tokenId, 0])).to.be.rejectedWith('common.NoPermission');194 // 3. Zero burn of non-existing tokens not allowed:193 // 3. Zero burn of non-existing tokens not allowed:195 await expect(helper.signTransaction(alice, api.tx.unique.burnItem(collection.collectionId, 9999, 0))).to.be.rejectedWith('common.TokenNotFound');194 await expect(helper.executeExtrinsic(alice, 'api.tx.unique.burnItem', [collection.collectionId, 9999, 0])).to.be.rejectedWith('common.TokenNotFound');196 expect(await tokenAlice.doesExist()).to.be.true;195 expect(await tokenAlice.doesExist()).to.be.true;197 expect(await tokenAlice.getOwner()).to.deep.eq({Substrate: alice.address});196 expect(await tokenAlice.getOwner()).to.deep.eq({Substrate: alice.address});198 expect(await tokenBob.getOwner()).to.deep.eq({Substrate: bob.address});197 expect(await tokenBob.getOwner()).to.deep.eq({Substrate: bob.address});211 await approvedNft.approve(bob, {Substrate: alice.address});210 await approvedNft.approve(bob, {Substrate: alice.address});212211213 // 1. Zero burnFrom of non-existing tokens not allowed:212 // 1. Zero burnFrom of non-existing tokens not allowed:214 await expect(helper.signTransaction(alice, api.tx.unique.burnFrom(collection.collectionId, {Substrate: bob.address}, 9999, 0))).to.be.rejectedWith('common.ApprovedValueTooLow');213 await expect(helper.executeExtrinsic(alice, 'api.tx.unique.burnFrom', [collection.collectionId, {Substrate: bob.address}, 9999, 0])).to.be.rejectedWith('common.ApprovedValueTooLow');215 // 2. Zero burnFrom of not approved tokens not allowed:214 // 2. Zero burnFrom of not approved tokens not allowed:216 await expect(helper.signTransaction(alice, api.tx.unique.burnFrom(collection.collectionId, {Substrate: bob.address}, notApprovedNft.tokenId, 0))).to.be.rejectedWith('common.NoPermission');215 await expect(helper.executeExtrinsic(alice, 'api.tx.unique.burnFrom', [collection.collectionId, {Substrate: bob.address}, notApprovedNft.tokenId, 0])).to.be.rejectedWith('common.NoPermission');217 // 3. Zero burnFrom of approved tokens allowed:216 // 3. Zero burnFrom of approved tokens allowed:218 await helper.signTransaction(alice, api.tx.unique.burnFrom(collection.collectionId, {Substrate: bob.address}, approvedNft.tokenId, 0));217 await helper.executeExtrinsic(alice, 'api.tx.unique.burnFrom', [collection.collectionId, {Substrate: bob.address}, approvedNft.tokenId, 0]);219218220 // 4.1 approvedNft still approved:219 // 4.1 approvedNft still approved:221 expect(await approvedNft.isApproved({Substrate: alice.address})).to.be.true;220 expect(await approvedNft.isApproved({Substrate: alice.address})).to.be.true;tests/src/transfer.test.tsdiffbeforeafterboth--- a/tests/src/transfer.test.ts
+++ b/tests/src/transfer.test.ts
@@ -193,16 +193,15 @@
});
itSub('Zero transfer NFT', async ({helper}) => {
- const api = helper.getApi();
const collection = await helper.nft.mintCollection(alice, {name: 'Transfer-Neg-3-NFT', description: '', tokenPrefix: 'T'});
const tokenAlice = await collection.mintToken(alice, {Substrate: alice.address});
const tokenBob = await collection.mintToken(alice, {Substrate: bob.address});
// 1. Zero transfer of own tokens allowed:
- await helper.signTransaction(alice, api.tx.unique.transfer({Substrate: bob.address}, collection.collectionId, tokenAlice.tokenId, 0));
+ await helper.executeExtrinsic(alice, 'api.tx.unique.transfer', [{Substrate: bob.address}, collection.collectionId, tokenAlice.tokenId, 0]);
// 2. Zero transfer of non-owned tokens not allowed:
- await expect(helper.signTransaction(alice, api.tx.unique.transfer({Substrate: alice.address}, collection.collectionId, tokenBob.tokenId, 0))).to.be.rejectedWith('common.NoPermission');
+ await expect(helper.executeExtrinsic(alice, 'api.tx.unique.transfer', [{Substrate: alice.address}, collection.collectionId, tokenBob.tokenId, 0])).to.be.rejectedWith('common.NoPermission');
// 3. Zero transfer of non-existing tokens not allowed:
- await expect(helper.signTransaction(alice, api.tx.unique.transfer({Substrate: alice.address}, collection.collectionId, 10, 0))).to.be.rejectedWith('common.TokenNotFound');
+ await expect(helper.executeExtrinsic(alice, 'api.tx.unique.transfer', [{Substrate: alice.address}, collection.collectionId, 10, 0])).to.be.rejectedWith('common.TokenNotFound');
expect(await tokenAlice.getOwner()).to.deep.eq({Substrate: alice.address});
expect(await tokenBob.getOwner()).to.deep.eq({Substrate: bob.address});
// 4. Storage is not corrupted:
tests/src/transferFrom.test.tsdiffbeforeafterboth--- a/tests/src/transferFrom.test.ts
+++ b/tests/src/transferFrom.test.ts
@@ -351,18 +351,17 @@
});
itSub('zero transfer NFT', async ({helper}) => {
- const api = helper.getApi();
const collection = await helper.nft.mintCollection(alice, {name: 'Zero', description: 'Zero transfer', tokenPrefix: 'TF'});
const notApprovedNft = await collection.mintToken(alice, {Substrate: bob.address});
const approvedNft = await collection.mintToken(alice, {Substrate: bob.address});
await approvedNft.approve(bob, {Substrate: alice.address});
// 1. Cannot zero transferFrom (non-existing token)
- await expect(helper.signTransaction(alice, api.tx.unique.transferFrom({Substrate: bob.address}, {Substrate: alice.address}, collection.collectionId, 9999, 0))).to.be.rejectedWith('common.ApprovedValueTooLow');
+ await expect(helper.executeExtrinsic(alice, 'api.tx.unique.transferFrom', [{Substrate: bob.address}, {Substrate: alice.address}, collection.collectionId, 9999, 0])).to.be.rejectedWith('common.ApprovedValueTooLow');
// 2. Cannot zero transferFrom (not approved token)
- await expect(helper.signTransaction(alice, api.tx.unique.transferFrom({Substrate: bob.address}, {Substrate: alice.address}, collection.collectionId, notApprovedNft.tokenId, 0))).to.be.rejectedWith('common.NoPermission');
+ await expect(helper.executeExtrinsic(alice, 'api.tx.unique.transferFrom', [{Substrate: bob.address}, {Substrate: alice.address}, collection.collectionId, notApprovedNft.tokenId, 0])).to.be.rejectedWith('common.NoPermission');
// 3. Can zero transferFrom (approved token):
- await helper.signTransaction(alice, api.tx.unique.transferFrom({Substrate: bob.address}, {Substrate: alice.address}, collection.collectionId, approvedNft.tokenId, 0));
+ await helper.executeExtrinsic(alice, 'api.tx.unique.transferFrom', [{Substrate: bob.address}, {Substrate: alice.address}, collection.collectionId, approvedNft.tokenId, 0]);
// 4.1 approvedNft still approved:
expect(await approvedNft.isApproved({Substrate: alice.address})).to.be.true;