git.delta.rocks / unique-network / refs/commits / 21b4b8a50083

difftreelog

Use executeExtrinsic

Max Andreev2022-12-07parent: #a43996c.patch.diff
in: master

3 files changed

modifiedtests/src/burnItem.test.tsdiffbeforeafterboth
--- a/tests/src/burnItem.test.ts
+++ b/tests/src/burnItem.test.ts
@@ -182,17 +182,16 @@
   });
 
   itSub('Zero burn NFT', async ({helper}) => {
-    const api = helper.getApi();
     const collection = await helper.nft.mintCollection(alice, {name: 'Coll', description: 'Desc', tokenPrefix: 'T'});
     const tokenAlice = await collection.mintToken(alice, {Substrate: alice.address});
     const tokenBob = await collection.mintToken(alice, {Substrate: bob.address});
     
     // 1. Zero burn of own tokens allowed:
-    await helper.signTransaction(alice, api.tx.unique.burnItem(collection.collectionId, tokenAlice.tokenId, 0));
+    await helper.executeExtrinsic(alice, 'api.tx.unique.burnItem', [collection.collectionId, tokenAlice.tokenId, 0]);
     // 2. Zero burn of non-owned tokens not allowed:
-    await expect(helper.signTransaction(alice, api.tx.unique.burnItem(collection.collectionId, tokenBob.tokenId, 0))).to.be.rejectedWith('common.NoPermission');
+    await expect(helper.executeExtrinsic(alice, 'api.tx.unique.burnItem', [collection.collectionId, tokenBob.tokenId, 0])).to.be.rejectedWith('common.NoPermission');
     // 3. Zero burn of non-existing tokens not allowed:
-    await expect(helper.signTransaction(alice, api.tx.unique.burnItem(collection.collectionId, 9999, 0))).to.be.rejectedWith('common.TokenNotFound');
+    await expect(helper.executeExtrinsic(alice, 'api.tx.unique.burnItem', [collection.collectionId, 9999, 0])).to.be.rejectedWith('common.TokenNotFound');
     expect(await tokenAlice.doesExist()).to.be.true;
     expect(await tokenAlice.getOwner()).to.deep.eq({Substrate: alice.address});
     expect(await tokenBob.getOwner()).to.deep.eq({Substrate: bob.address});
@@ -211,11 +210,11 @@
     await approvedNft.approve(bob, {Substrate: alice.address});
 
     // 1. Zero burnFrom of non-existing tokens not allowed:
-    await expect(helper.signTransaction(alice, api.tx.unique.burnFrom(collection.collectionId, {Substrate: bob.address}, 9999, 0))).to.be.rejectedWith('common.ApprovedValueTooLow');
+    await expect(helper.executeExtrinsic(alice, 'api.tx.unique.burnFrom', [collection.collectionId, {Substrate: bob.address}, 9999, 0])).to.be.rejectedWith('common.ApprovedValueTooLow');
     // 2. Zero burnFrom of not approved tokens not allowed:
-    await expect(helper.signTransaction(alice, api.tx.unique.burnFrom(collection.collectionId, {Substrate: bob.address}, notApprovedNft.tokenId, 0))).to.be.rejectedWith('common.NoPermission');
+    await expect(helper.executeExtrinsic(alice, 'api.tx.unique.burnFrom', [collection.collectionId, {Substrate: bob.address}, notApprovedNft.tokenId, 0])).to.be.rejectedWith('common.NoPermission');
     // 3. Zero burnFrom of approved tokens allowed:
-    await helper.signTransaction(alice, api.tx.unique.burnFrom(collection.collectionId, {Substrate: bob.address}, approvedNft.tokenId, 0));
+    await helper.executeExtrinsic(alice, 'api.tx.unique.burnFrom', [collection.collectionId, {Substrate: bob.address}, approvedNft.tokenId, 0]);
 
     // 4.1 approvedNft still approved:
     expect(await approvedNft.isApproved({Substrate: alice.address})).to.be.true;
modifiedtests/src/transfer.test.tsdiffbeforeafterboth
193 });193 });
194194
195 itSub('Zero transfer NFT', async ({helper}) => {195 itSub('Zero transfer NFT', async ({helper}) => {
196 const api = helper.getApi();
197 const collection = await helper.nft.mintCollection(alice, {name: 'Transfer-Neg-3-NFT', description: '', tokenPrefix: 'T'});196 const collection = await helper.nft.mintCollection(alice, {name: 'Transfer-Neg-3-NFT', description: '', tokenPrefix: 'T'});
198 const tokenAlice = await collection.mintToken(alice, {Substrate: alice.address});197 const tokenAlice = await collection.mintToken(alice, {Substrate: alice.address});
199 const tokenBob = await collection.mintToken(alice, {Substrate: bob.address});198 const tokenBob = await collection.mintToken(alice, {Substrate: bob.address});
200 // 1. Zero transfer of own tokens allowed:199 // 1. Zero transfer of own tokens allowed:
201 await helper.signTransaction(alice, api.tx.unique.transfer({Substrate: bob.address}, collection.collectionId, tokenAlice.tokenId, 0));200 await helper.executeExtrinsic(alice, 'api.tx.unique.transfer', [{Substrate: bob.address}, collection.collectionId, tokenAlice.tokenId, 0]);
202 // 2. Zero transfer of non-owned tokens not allowed:201 // 2. Zero transfer of non-owned tokens not allowed:
203 await expect(helper.signTransaction(alice, api.tx.unique.transfer({Substrate: alice.address}, collection.collectionId, tokenBob.tokenId, 0))).to.be.rejectedWith('common.NoPermission');202 await expect(helper.executeExtrinsic(alice, 'api.tx.unique.transfer', [{Substrate: alice.address}, collection.collectionId, tokenBob.tokenId, 0])).to.be.rejectedWith('common.NoPermission');
204 // 3. Zero transfer of non-existing tokens not allowed:203 // 3. Zero transfer of non-existing tokens not allowed:
205 await expect(helper.signTransaction(alice, api.tx.unique.transfer({Substrate: alice.address}, collection.collectionId, 10, 0))).to.be.rejectedWith('common.TokenNotFound');204 await expect(helper.executeExtrinsic(alice, 'api.tx.unique.transfer', [{Substrate: alice.address}, collection.collectionId, 10, 0])).to.be.rejectedWith('common.TokenNotFound');
206 expect(await tokenAlice.getOwner()).to.deep.eq({Substrate: alice.address});205 expect(await tokenAlice.getOwner()).to.deep.eq({Substrate: alice.address});
207 expect(await tokenBob.getOwner()).to.deep.eq({Substrate: bob.address});206 expect(await tokenBob.getOwner()).to.deep.eq({Substrate: bob.address});
208 // 4. Storage is not corrupted:207 // 4. Storage is not corrupted:
modifiedtests/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;