git.delta.rocks / unique-network / refs/commits / 44f9d3c6ebe4

difftreelog

tests: find not existing ids

Yaroslav Bolyukin2021-01-25parent: #0e762cd.patch.diff
in: master

2 files changed

modifiedtests/src/setVariableMetaData.test.tsdiffbeforeafterboth
--- a/tests/src/setVariableMetaData.test.ts
+++ b/tests/src/setVariableMetaData.test.ts
@@ -8,6 +8,7 @@
   createCollectionExpectSuccess,
   createItemExpectSuccess,
   destroyCollectionExpectSuccess,
+  findNotExistingCollection,
   setVariableMetaDataExpectFailure,
   setVariableMetaDataExpectSuccess,
 } from './util/helpers';
@@ -62,9 +63,10 @@
   });
 
   it('fails on not existing collection id', async () => {
-    // Not sure how to implement it
-    const nonExistingCollectionId = 200000;
-    await setVariableMetaDataExpectFailure(alice, nonExistingCollectionId, 1, data);
+    await usingApi(async api => {
+      let nonExistingCollectionId = await findNotExistingCollection(api);
+      await setVariableMetaDataExpectFailure(alice, nonExistingCollectionId, 1, data);
+    });
   });
   it('fails on removed collection id', async () => {
     const removedCollectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
@@ -81,7 +83,7 @@
     await setVariableMetaDataExpectFailure(alice, removedTokenCollectionId, removedTokenId, data);
   });
   it('fails on not existing token', async () => {
-    const nonExistingTokenId = 200000;
+    const nonExistingTokenId = validTokenId + 1;
 
     await setVariableMetaDataExpectFailure(alice, validCollectionId, nonExistingTokenId, data);
   });
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
253 return unused;253 return unused;
254}254}
255
256export async function findNotExistingCollection(api: ApiPromise): Promise<number> {
257 let collection: number = parseInt((await api.query.nft.createdCollectionCount()).toString()) as unknown as number + 1;
258 return collection;
259}
255260
256function getDestroyResult(events: EventRecord[]): boolean {261function getDestroyResult(events: EventRecord[]): boolean {
257 let success: boolean = false;262 let success: boolean = false;