git.delta.rocks / unique-network / refs/commits / 6b16ace53bf5

difftreelog

Tests updated

str-mv2021-08-13parent: #7c95ae9.patch.diff
in: master

2 files changed

modifiedtests/src/change-collection-owner.test.tsdiffbeforeafterboth
--- a/tests/src/change-collection-owner.test.ts
+++ b/tests/src/change-collection-owner.test.ts
@@ -15,6 +15,12 @@
   enableWhiteListExpectSuccess,
   setMintPermissionExpectSuccess,
   destroyCollectionExpectSuccess,
+  setCollectionSponsorExpectFailure,
+  confirmSponsorshipExpectFailure,
+  removeCollectionSponsorExpectFailure,
+  enableWhiteListExpectFail,
+  setMintPermissionExpectFailure,
+  destroyCollectionExpectFailure,
 } from './util/helpers';
 
 chai.use(chaiAsPromised);
@@ -53,7 +59,7 @@
       await submitTransactionAsync(alice, changeOwnerTx);
 
       const badChangeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, alice.address);
-      await expect(submitTransactionAsync(alice, badChangeOwnerTx)).to.be.rejected;
+      await expect(submitTransactionExpectFailAsync(alice, badChangeOwnerTx)).to.be.rejected;
 
       const collectionAfterOwnerChange: any = (await api.query.nft.collectionById(collectionId)).toJSON();
       expect(collectionAfterOwnerChange.Owner).to.be.deep.eq(bob.address);
@@ -169,14 +175,14 @@
       await submitTransactionAsync(alice, changeOwnerTx);
 
       const badChangeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, alice.address);
-      await expect(submitTransactionAsync(alice, badChangeOwnerTx)).to.be.rejected;
+      await expect(submitTransactionExpectFailAsync(alice, badChangeOwnerTx)).to.be.rejected;
 
       const collectionAfterOwnerChange: any = (await api.query.nft.collectionById(collectionId)).toJSON();
       expect(collectionAfterOwnerChange.Owner).to.be.deep.eq(bob.address);
 
-      await expect(setCollectionSponsorExpectSuccess(collectionId, charlie.address, '//Alice')).to.be.rejected;
-      await expect(confirmSponsorshipExpectSuccess(collectionId, '//Alice')).to.be.rejected;
-      await expect(removeCollectionSponsorExpectSuccess(collectionId, '//Alice')).to.be.rejected;
+      await setCollectionSponsorExpectFailure(collectionId, charlie.address, '//Alice');
+      await confirmSponsorshipExpectFailure(collectionId, '//Alice');
+      await removeCollectionSponsorExpectFailure(collectionId, '//Alice');
 
       const collectionLimits = {
         AccountTokenOwnershipLimit: 1,
@@ -190,11 +196,11 @@
         collectionId,
         collectionLimits,
       );
-      await expect(submitTransactionAsync(alice, tx1)).to.be.rejected;
+      await expect(submitTransactionExpectFailAsync(alice, tx1)).to.be.rejected;
 
-      await expect(enableWhiteListExpectSuccess(alice, collectionId)).to.be.rejected;
-      await expect(setMintPermissionExpectSuccess(alice, collectionId, true)).to.be.rejected;
-      await expect(destroyCollectionExpectSuccess(collectionId, '//Alice')).to.be.rejected;
+      await enableWhiteListExpectFail(alice, collectionId);
+      await setMintPermissionExpectFailure(alice, collectionId, true);
+      await destroyCollectionExpectFailure(collectionId, '//Alice');
     });
   });
 });
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
1006 });1006 });
1007}1007}
1008
1009export async function setPublicAccessModeExpectFail(
1010 sender: IKeyringPair, collectionId: number,
1011 accessMode: 'Normal' | 'WhiteList',
1012) {
1013 await usingApi(async (api) => {
1014
1015 // Run the transaction
1016 const tx = api.tx.nft.setPublicAccessMode(collectionId, accessMode);
1017 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
1018 const result = getGenericResult(events);
1019
1020 // What to expect
1021 // tslint:disable-next-line:no-unused-expression
1022 expect(result.success).to.be.false;
1023 });
1024}
10081025
1009export async function enableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {1026export async function enableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {
1010 await setPublicAccessModeExpectSuccess(sender, collectionId, 'WhiteList');1027 await setPublicAccessModeExpectSuccess(sender, collectionId, 'WhiteList');
1011}1028}
1029
1030export async function enableWhiteListExpectFail(sender: IKeyringPair, collectionId: number) {
1031 await setPublicAccessModeExpectFail(sender, collectionId, 'WhiteList');
1032}
10121033
1013export async function disableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {1034export async function disableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {
1014 await setPublicAccessModeExpectSuccess(sender, collectionId, 'Normal');1035 await setPublicAccessModeExpectSuccess(sender, collectionId, 'Normal');