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

difftreelog

tests fixes

kpozdnikin2021-01-11parent: #a013b67.patch.diff
in: master

2 files changed

modifiedtests/src/setCollectionLimits.test.tsdiffbeforeafterboth
--- a/tests/src/setCollectionLimits.test.ts
+++ b/tests/src/setCollectionLimits.test.ts
@@ -3,7 +3,7 @@
 import { IKeyringPair } from '@polkadot/types/types';
 import chai from 'chai';
 import chaiAsPromised from 'chai-as-promised';
-import usingApi, { submitTransactionAsync } from './substrate/substrate-api';
+import usingApi, {submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
 import { ICollectionInterface } from './types';
 import {
   createCollectionExpectSuccess, getCreatedCollectionCount,
@@ -33,7 +33,6 @@
   it('choose or create collection for testing', async () => {
     await usingApi(async () => {
       collectionIdForTesting = await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: 'NFT'});
-      console.log('collectionIdForTesting', collectionIdForTesting);
     });
   });
 });
@@ -96,12 +95,7 @@
           tokenLimit,
         },
       );
-      try {
-        await submitTransactionAsync(alice, tx);
-      } catch (e) {
-        // tslint:disable-next-line:no-unused-expression
-        expect(e).to.be.exist;
-      }
+      await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;
     });
   });
   it('execute setCollectionLimits from user who is not owner of this collection', async () => {
@@ -115,12 +109,7 @@
           tokenLimit,
         },
       );
-      try {
-        await submitTransactionAsync(bob, tx);
-      } catch (e) {
-        // tslint:disable-next-line:no-unused-expression
-        expect(e).to.be.exist;
-      }
+      await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;
     });
   });
   it('execute setCollectionLimits with incorrect limits', async () => {
@@ -134,12 +123,7 @@
           tokenLimit: '-100',
         },
       );
-      try {
-        await submitTransactionAsync(alice, tx);
-      } catch (e) {
-        // tslint:disable-next-line:no-unused-expression
-        expect(e).to.be.exist;
-      }
+      await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;
     });
   });
 });
modifiedtests/src/setSchemaVersion.test.tsdiffbeforeafterboth
4import BN from 'bn.js';4import BN from 'bn.js';
5import chai from 'chai';5import chai from 'chai';
6import chaiAsPromised from 'chai-as-promised';6import chaiAsPromised from 'chai-as-promised';
7import usingApi, { submitTransactionAsync } from './substrate/substrate-api';7import usingApi, {submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
8import { ICollectionInterface } from './types';8import { ICollectionInterface } from './types';
9import {9import {
10 createCollectionExpectSuccess,10 createCollectionExpectSuccess,
92 const collectionCount = await getCreatedCollectionCount(api);92 const collectionCount = await getCreatedCollectionCount(api);
93 const nonExistedCollectionId = collectionCount + 1;93 const nonExistedCollectionId = collectionCount + 1;
94 tx = api.tx.nft.setSchemaVersion(nonExistedCollectionId, 'ImageURL');94 tx = api.tx.nft.setSchemaVersion(nonExistedCollectionId, 'ImageURL');
95 try {
96 await submitTransactionAsync(alice, tx);
97 } catch (e) {
98 // tslint:disable-next-line:no-unused-expression
99 expect(e).to.be.exist;95 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;
100 }96 /*try {
97 await submitTransactionAsync(alice, tx);
98 } catch (e) {
99 // tslint:disable-next-line:no-unused-expression
100 expect(e).to.be.exist;
101 }*/
101 });102 });
102 });103 });
103104
116 it('execute setSchemaVersion for deleted collection', async () => {117 it('execute setSchemaVersion for deleted collection', async () => {
117 await usingApi(async (api: ApiPromise) => {118 await usingApi(async (api: ApiPromise) => {
118 await destroyCollectionExpectSuccess(collectionIdForTesting);119 await destroyCollectionExpectSuccess(collectionIdForTesting);
119 try {
120 tx = api.tx.nft.setSchemaVersion(collectionIdForTesting, 'ImageURL');120 tx = api.tx.nft.setSchemaVersion(collectionIdForTesting, 'ImageURL');
121 await submitTransactionAsync(alice, tx);
122 } catch (e) {
123 // tslint:disable-next-line:no-unused-expression
124 expect(e).to.be.exist;121 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;
125 }122 /*try {
123 tx = api.tx.nft.setSchemaVersion(collectionIdForTesting, 'ImageURL');
124 await submitTransactionAsync(alice, tx);
125 } catch (e) {
126 // tslint:disable-next-line:no-unused-expression
127 expect(e).to.be.exist;
128 }*/
126 });129 });
127 });130 });
128});131});