git.delta.rocks / unique-network / refs/commits / 50109b665ea6

difftreelog

fix RMRK disconnect

Daniel Shiposha2022-10-14parent: #2c2096c.patch.diff
in: master

20 files changed

modifiedtests/src/rmrk/acceptNft.test.tsdiffbeforeafterboth
--- a/tests/src/rmrk/acceptNft.test.ts
+++ b/tests/src/rmrk/acceptNft.test.ts
@@ -103,5 +103,5 @@
     expect(isChild).to.be.false;
   });
 
-  after(() => { api.disconnect(); });
+  after(async() => { await api.disconnect(); });
 });
modifiedtests/src/rmrk/addResource.test.tsdiffbeforeafterboth
--- a/tests/src/rmrk/addResource.test.ts
+++ b/tests/src/rmrk/addResource.test.ts
@@ -432,6 +432,6 @@
 
 
   after(() => {
-    api.disconnect();
+    after(async() => { await api.disconnect(); });
   });
 });
modifiedtests/src/rmrk/addTheme.test.tsdiffbeforeafterboth
--- a/tests/src/rmrk/addTheme.test.ts
+++ b/tests/src/rmrk/addTheme.test.ts
@@ -125,5 +125,5 @@
     await expectTxFailure(/rmrkEquip\.PermissionError/, tx);
   });
 
-  after(() => { api.disconnect(); });
+  after(async() => { await api.disconnect(); });
 });
modifiedtests/src/rmrk/burnNft.test.tsdiffbeforeafterboth
--- a/tests/src/rmrk/burnNft.test.ts
+++ b/tests/src/rmrk/burnNft.test.ts
@@ -166,7 +166,5 @@
     });
   });
 
-  after(() => {
-    api.disconnect();
-  });
+  after(async() => { await api.disconnect(); });
 });
modifiedtests/src/rmrk/changeCollectionIssuer.test.tsdiffbeforeafterboth
--- a/tests/src/rmrk/changeCollectionIssuer.test.ts
+++ b/tests/src/rmrk/changeCollectionIssuer.test.ts
@@ -49,7 +49,5 @@
     });
   });
 
-  after(() => {
-    api.disconnect();
-  });
+  after(async() => { await api.disconnect(); });
 });
modifiedtests/src/rmrk/createBase.test.tsdiffbeforeafterboth
--- a/tests/src/rmrk/createBase.test.ts
+++ b/tests/src/rmrk/createBase.test.ts
@@ -84,5 +84,5 @@
     ]);
   });
 
-  after(() => { api.disconnect(); });
+  after(async() => { await api.disconnect(); });
 });
modifiedtests/src/rmrk/createCollection.test.tsdiffbeforeafterboth
--- a/tests/src/rmrk/createCollection.test.ts
+++ b/tests/src/rmrk/createCollection.test.ts
@@ -21,5 +21,5 @@
     await createCollection(api, alice, 'no-limit-metadata', null, 'no-limit-symbol');
   });
 
-  after(() => { api.disconnect(); });
+  after(async() => { await api.disconnect(); });
 });
modifiedtests/src/rmrk/deleteCollection.test.tsdiffbeforeafterboth
--- a/tests/src/rmrk/deleteCollection.test.ts
+++ b/tests/src/rmrk/deleteCollection.test.ts
@@ -42,7 +42,5 @@
     });
   });
 
-  after(() => {
-    api.disconnect();
-  });
+  after(async() => { await api.disconnect(); });
 });
modifiedtests/src/rmrk/equipNft.test.tsdiffbeforeafterboth
--- a/tests/src/rmrk/equipNft.test.ts
+++ b/tests/src/rmrk/equipNft.test.ts
@@ -336,7 +336,5 @@
     await expectTxFailure(/rmrkEquip\.CollectionNotEquippable/, tx);
   });
 
-  after(() => {
-    api.disconnect();
-  });
+  after(async() => { await api.disconnect(); });
 });
modifiedtests/src/rmrk/getOwnedNfts.test.tsdiffbeforeafterboth
--- a/tests/src/rmrk/getOwnedNfts.test.ts
+++ b/tests/src/rmrk/getOwnedNfts.test.ts
@@ -76,5 +76,5 @@
     });
   });
 
-  after(() => { api.disconnect(); });
+  after(async() => { await api.disconnect(); });
 });
modifiedtests/src/rmrk/lockCollection.test.tsdiffbeforeafterboth
--- a/tests/src/rmrk/lockCollection.test.ts
+++ b/tests/src/rmrk/lockCollection.test.ts
@@ -112,7 +112,5 @@
     });
   });
 
-  after(() => {
-    api.disconnect();
-  });
+  after(async() => { await api.disconnect(); });
 });
modifiedtests/src/rmrk/mintNft.test.tsdiffbeforeafterboth
--- a/tests/src/rmrk/mintNft.test.ts
+++ b/tests/src/rmrk/mintNft.test.ts
@@ -207,5 +207,5 @@
     expect(nft.isSome).to.be.false;
   });
 
-  after(() => { api.disconnect(); });
+  after(async() => { await api.disconnect(); });
 });
modifiedtests/src/rmrk/rejectNft.test.tsdiffbeforeafterboth
before · tests/src/rmrk/rejectNft.test.ts
1import {expect} from 'chai';2import {getApiConnection} from '../substrate/substrate-api';3import {4  createCollection,5  mintNft,6  sendNft,7  rejectNft,8} from './util/tx';9import {getChildren, NftIdTuple} from './util/fetch';10import {isNftChildOfAnother, expectTxFailure, requirePallets, Pallets} from './util/helpers';1112describe('integration test: reject NFT', () => {13  let api: any;14  before(async function () {15    api = await getApiConnection();16    await requirePallets(this, [Pallets.RmrkCore]);17  });18192021  const alice = '//Alice';22  const bob = '//Bob';2324  const createTestCollection = async (issuerUri: string) => {25    return await createCollection(26      api,27      issuerUri,28      'reject-metadata',29      null,30      'rjct',31    );32  };3334  it('reject NFT', async () => {35    const ownerAlice = alice;36    const ownerBob = bob;3738    const aliceCollectionId = await createTestCollection(alice);39    const bobCollectionId = await createTestCollection(bob);4041    const parentNftId = await mintNft(api, alice, ownerAlice, aliceCollectionId, 'parent-nft-metadata');42    const childNftId = await mintNft(api, bob, ownerBob, bobCollectionId, 'child-nft-metadata');4344    const newOwnerNFT: NftIdTuple = [aliceCollectionId, parentNftId];4546    await sendNft(api, 'pending', ownerBob, bobCollectionId, childNftId, newOwnerNFT);47    await rejectNft(api, alice, bobCollectionId, childNftId);4849    const isChild = await isNftChildOfAnother(api, bobCollectionId, childNftId, newOwnerNFT);50    expect(isChild, 'Error: rejected NFT is still a child of the target NFT').to.be.false;51  });5253  it('[negative] unable to reject NFT by a not-an-owner', async () => {54    const ownerAlice = alice;55    const ownerBob = bob;5657    const aliceCollectionId = await createTestCollection(alice);58    const bobCollectionId = await createTestCollection(bob);5960    const parentNftId = await mintNft(api, alice, ownerAlice, aliceCollectionId, 'parent-nft-metadata');61    const childNftId = await mintNft(api, bob, ownerBob, bobCollectionId, 'child-nft-metadata');6263    const newOwnerNFT: NftIdTuple = [aliceCollectionId, parentNftId];6465    await sendNft(api, 'pending', ownerBob, bobCollectionId, childNftId, newOwnerNFT);66    const tx = rejectNft(api, bob, bobCollectionId, childNftId);6768    await expectTxFailure(/rmrkCore\.CannotRejectNonOwnedNft/, tx);69  });7071  it('[negative] unable to reject non-existing NFT', async () => {72    const maxNftId = 0xFFFFFFFF;7374    const collectionId = await createTestCollection(alice);7576    const tx = rejectNft(api, alice, collectionId, maxNftId);7778    await expectTxFailure(/rmrkCore\.NoAvailableNftId/, tx);79  });8081  it('[negative] unable to reject NFT which is not sent', async () => {82    const ownerAlice = alice;8384    const collectionId = await createTestCollection(alice);8586    const nftId = await mintNft(api, alice, ownerAlice, collectionId, 'parent-nft-metadata');8788    const tx = rejectNft(api, alice, collectionId, nftId);8990    await expectTxFailure(/rmrkCore\.CannotRejectNonPendingNft/, tx);91  });9293  after(() => { api.disconnect(); });94});
after · tests/src/rmrk/rejectNft.test.ts
1import {expect} from 'chai';2import {getApiConnection} from '../substrate/substrate-api';3import {4  createCollection,5  mintNft,6  sendNft,7  rejectNft,8} from './util/tx';9import {getChildren, NftIdTuple} from './util/fetch';10import {isNftChildOfAnother, expectTxFailure, requirePallets, Pallets} from './util/helpers';1112describe('integration test: reject NFT', () => {13  let api: any;14  before(async function () {15    api = await getApiConnection();16    await requirePallets(this, [Pallets.RmrkCore]);17  });18192021  const alice = '//Alice';22  const bob = '//Bob';2324  const createTestCollection = async (issuerUri: string) => {25    return await createCollection(26      api,27      issuerUri,28      'reject-metadata',29      null,30      'rjct',31    );32  };3334  it('reject NFT', async () => {35    const ownerAlice = alice;36    const ownerBob = bob;3738    const aliceCollectionId = await createTestCollection(alice);39    const bobCollectionId = await createTestCollection(bob);4041    const parentNftId = await mintNft(api, alice, ownerAlice, aliceCollectionId, 'parent-nft-metadata');42    const childNftId = await mintNft(api, bob, ownerBob, bobCollectionId, 'child-nft-metadata');4344    const newOwnerNFT: NftIdTuple = [aliceCollectionId, parentNftId];4546    await sendNft(api, 'pending', ownerBob, bobCollectionId, childNftId, newOwnerNFT);47    await rejectNft(api, alice, bobCollectionId, childNftId);4849    const isChild = await isNftChildOfAnother(api, bobCollectionId, childNftId, newOwnerNFT);50    expect(isChild, 'Error: rejected NFT is still a child of the target NFT').to.be.false;51  });5253  it('[negative] unable to reject NFT by a not-an-owner', async () => {54    const ownerAlice = alice;55    const ownerBob = bob;5657    const aliceCollectionId = await createTestCollection(alice);58    const bobCollectionId = await createTestCollection(bob);5960    const parentNftId = await mintNft(api, alice, ownerAlice, aliceCollectionId, 'parent-nft-metadata');61    const childNftId = await mintNft(api, bob, ownerBob, bobCollectionId, 'child-nft-metadata');6263    const newOwnerNFT: NftIdTuple = [aliceCollectionId, parentNftId];6465    await sendNft(api, 'pending', ownerBob, bobCollectionId, childNftId, newOwnerNFT);66    const tx = rejectNft(api, bob, bobCollectionId, childNftId);6768    await expectTxFailure(/rmrkCore\.CannotRejectNonOwnedNft/, tx);69  });7071  it('[negative] unable to reject non-existing NFT', async () => {72    const maxNftId = 0xFFFFFFFF;7374    const collectionId = await createTestCollection(alice);7576    const tx = rejectNft(api, alice, collectionId, maxNftId);7778    await expectTxFailure(/rmrkCore\.NoAvailableNftId/, tx);79  });8081  it('[negative] unable to reject NFT which is not sent', async () => {82    const ownerAlice = alice;8384    const collectionId = await createTestCollection(alice);8586    const nftId = await mintNft(api, alice, ownerAlice, collectionId, 'parent-nft-metadata');8788    const tx = rejectNft(api, alice, collectionId, nftId);8990    await expectTxFailure(/rmrkCore\.CannotRejectNonPendingNft/, tx);91  });9293  after(async() => { await api.disconnect(); });94});
modifiedtests/src/rmrk/removeResource.test.tsdiffbeforeafterboth
--- a/tests/src/rmrk/removeResource.test.ts
+++ b/tests/src/rmrk/removeResource.test.ts
@@ -343,7 +343,5 @@
     await expectTxFailure(/rmrkCore\.NoPermission/, tx);
   });
 
-  after(() => {
-    api.disconnect();
-  });
+  after(async() => { await api.disconnect(); });
 });
modifiedtests/src/rmrk/rmrkIsolation.test.tsdiffbeforeafterboth
--- a/tests/src/rmrk/rmrkIsolation.test.ts
+++ b/tests/src/rmrk/rmrkIsolation.test.ts
@@ -90,7 +90,7 @@
       bob = privateKey('//Bob');
       normalizedAlice = {Substrate: helper.address.normalizeSubstrateToChainFormat(alice.address)};
 
-      requirePalletsOrSkip(this, helper, [Pallets.RmrkCore]);
+      await requirePalletsOrSkip(this, helper, [Pallets.RmrkCore]);
 
       const collectionIds = await createRmrkCollection(helper, alice);
       uniqueCollectionId = collectionIds.uniqueId;
modifiedtests/src/rmrk/sendNft.test.tsdiffbeforeafterboth
--- a/tests/src/rmrk/sendNft.test.ts
+++ b/tests/src/rmrk/sendNft.test.ts
@@ -251,5 +251,5 @@
     await expectTxFailure(/rmrkCore\.NoPermission/, tx);
   });
 
-  after(() => { api.disconnect(); });
+  after(async() => { await api.disconnect(); });
 });
modifiedtests/src/rmrk/setCollectionProperty.test.tsdiffbeforeafterboth
--- a/tests/src/rmrk/setCollectionProperty.test.ts
+++ b/tests/src/rmrk/setCollectionProperty.test.ts
@@ -62,7 +62,5 @@
     });
   });
 
-  after(() => {
-    api.disconnect();
-  });
+  after(async() => { await api.disconnect(); });
 });
modifiedtests/src/rmrk/setEquippableList.test.tsdiffbeforeafterboth
--- a/tests/src/rmrk/setEquippableList.test.ts
+++ b/tests/src/rmrk/setEquippableList.test.ts
@@ -110,5 +110,5 @@
     await expectTxFailure(/rmrkEquip\.PartDoesntExist/, tx);
   });
 
-  after(() => { api.disconnect(); });
+  after(async() => { await api.disconnect(); });
 });
modifiedtests/src/rmrk/setNftProperty.test.tsdiffbeforeafterboth
--- a/tests/src/rmrk/setNftProperty.test.ts
+++ b/tests/src/rmrk/setNftProperty.test.ts
@@ -84,5 +84,5 @@
     await expectTxFailure(/rmrkCore\.NoPermission/, tx);
   });
 
-  after(() => { api.disconnect(); });
+  after(async() => { await api.disconnect(); });
 });
modifiedtests/src/rmrk/setResourcePriorities.test.tsdiffbeforeafterboth
--- a/tests/src/rmrk/setResourcePriorities.test.ts
+++ b/tests/src/rmrk/setResourcePriorities.test.ts
@@ -54,5 +54,5 @@
     await expectTxFailure(/rmrkCore\.NoAvailableNftId/, tx);
   });
 
-  after(() => { api.disconnect(); });
+  after(async() => { await api.disconnect(); });
 });