git.delta.rocks / unique-network / refs/commits / 9c1caa86048b

difftreelog

NFTPAR-237 Integration Test changeCollectionOwner(collection_id, new_owner). Fixed tests.

sotmorskiy2020-12-29parent: #91e3663.patch.diff
in: master

4 files changed

modifiedtests/src/confirmSponsorship.test.tsdiffbeforeafterboth
89 });89 });
9090
91 it('Fungible: Transfer fees are paid by the sponsor after confirmation', async () => {91 it('Fungible: Transfer fees are paid by the sponsor after confirmation', async () => {
92 const collectionId = await createCollectionExpectSuccess();92 const collectionId = await createCollectionExpectSuccess({mode: 'Fungible'});
93 await setCollectionSponsorExpectSuccess(collectionId, bob.address);93 await setCollectionSponsorExpectSuccess(collectionId, bob.address);
94 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');94 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
9595
115 });115 });
116116
117 it('ReFungible: Transfer fees are paid by the sponsor after confirmation', async () => {117 it('ReFungible: Transfer fees are paid by the sponsor after confirmation', async () => {
118 const collectionId = await createCollectionExpectSuccess();118 const collectionId = await createCollectionExpectSuccess({mode: 'ReFungible'});
119 await setCollectionSponsorExpectSuccess(collectionId, bob.address);119 await setCollectionSponsorExpectSuccess(collectionId, bob.address);
120 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');120 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
121121
210 });210 });
211211
212 it('Fungible: Sponsoring is rate limited', async () => {212 it('Fungible: Sponsoring is rate limited', async () => {
213 const collectionId = await createCollectionExpectSuccess();213 const collectionId = await createCollectionExpectSuccess({mode: 'Fungible'});
214 await setCollectionSponsorExpectSuccess(collectionId, bob.address);214 await setCollectionSponsorExpectSuccess(collectionId, bob.address);
215 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');215 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
216216
247 });247 });
248248
249 it('ReFungible: Sponsoring is rate limited', async () => {249 it('ReFungible: Sponsoring is rate limited', async () => {
250 const collectionId = await createCollectionExpectSuccess();250 const collectionId = await createCollectionExpectSuccess({mode: 'ReFungible'});
251 await setCollectionSponsorExpectSuccess(collectionId, bob.address);251 await setCollectionSponsorExpectSuccess(collectionId, bob.address);
252 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');252 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
253253
modifiedtests/src/creditFeesToTreasury.test.tsdiffbeforeafterboth
--- a/tests/src/creditFeesToTreasury.test.ts
+++ b/tests/src/creditFeesToTreasury.test.ts
@@ -5,7 +5,7 @@
 
 import chai from 'chai';
 import chaiAsPromised from 'chai-as-promised';
-import { default as usingApi, submitTransactionAsync } from "./substrate/substrate-api";
+import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from "./substrate/substrate-api";
 import { alicesPublicKey, bobsPublicKey } from "./accounts";
 import privateKey from "./substrate/privateKey";
 import { BigNumber } from 'bignumber.js';
@@ -63,14 +63,13 @@
       const bobBalanceBefore = new BigNumber((await api.query.system.account(bobsPublicKey)).data.free.toString());
 
       const badTx = api.tx.balances.setBalance(alicesPublicKey, 0, 0);
-      const result = getGenericResult(await submitTransactionAsync(bobPrivateKey, badTx));
+      await expect(submitTransactionExpectFailAsync(bobPrivateKey, badTx)).to.be.rejected;
 
       const treasuryBalanceAfter = new BigNumber((await api.query.system.account(Treasury)).data.free.toString());
       const bobBalanceAfter = new BigNumber((await api.query.system.account(bobsPublicKey)).data.free.toString());
       const fee = bobBalanceBefore.minus(bobBalanceAfter);
       const treasuryIncrease = treasuryBalanceAfter.minus(treasuryBalanceBefore);
 
-      expect(result.success).to.be.false;
       expect(treasuryIncrease.toFixed()).to.be.equal(fee.toFixed());
     });
   });
modifiedtests/src/substrate/substrate-api.tsdiffbeforeafterboth
--- a/tests/src/substrate/substrate-api.ts
+++ b/tests/src/substrate/substrate-api.ts
@@ -68,7 +68,7 @@
           resolve(events);
         } else if (transactionStatus == TransactionStatus.Fail) {
           console.log(`Something went wrong with transaction. Status: ${status}`);
-          reject("Transaction failed");
+          reject(events);
         }
       });
     } catch (e) {
@@ -107,7 +107,7 @@
         if (transactionStatus == TransactionStatus.Success) {
           resolve(events);
         } else if (transactionStatus == TransactionStatus.Fail) {
-          reject("Transaction failed");
+          reject(events);
         }
       });
     } catch (e) {
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -7,7 +7,7 @@
 import chaiAsPromised from 'chai-as-promised';
 import type { AccountId, EventRecord } from '@polkadot/types/interfaces';
 import { ApiPromise, Keyring } from "@polkadot/api";
-import { default as usingApi, submitTransactionAsync } from "../substrate/substrate-api";
+import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from "../substrate/substrate-api";
 import privateKey from '../substrate/privateKey';
 import { alicesPublicKey, nullPublicKey } from "../accounts";
 import { strToUTF16, utf16ToStr, hexToStr } from '../util/util';
@@ -147,7 +147,7 @@
     // Run the CreateCollection transaction
     const alicePrivateKey = privateKey('//Alice');
     const tx = api.tx.nft.createCollection(strToUTF16(name), strToUTF16(description), strToUTF16(tokenPrefix), mode);
-    const events = await submitTransactionAsync(alicePrivateKey, tx);
+    const events = await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;
     const result = getCreateCollectionResult(events);
 
     // Get number of collections after the transaction
@@ -187,11 +187,7 @@
     // Run the DestroyCollection transaction
     const alicePrivateKey = privateKey(senderSeed);
     const tx = api.tx.nft.destroyCollection(collectionId);
-    const events = await submitTransactionAsync(alicePrivateKey, tx);
-    const result = getDestroyResult(events);
-
-    // What to expect
-    expect(result).to.be.false;
+    await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;
   });
 }
 
@@ -257,11 +253,7 @@
     // Run the transaction
     const alicePrivateKey = privateKey('//Alice');
     const tx = api.tx.nft.removeCollectionSponsor(collectionId);
-    const events = await submitTransactionAsync(alicePrivateKey, tx);
-    const result = getGenericResult(events);
-
-    // What to expect
-    expect(result.success).to.be.false;
+    await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;
   });
 }
 
@@ -271,11 +263,7 @@
     // Run the transaction
     const alicePrivateKey = privateKey(senderSeed);
     const tx = api.tx.nft.setCollectionSponsor(collectionId, sponsor);
-    const events = await submitTransactionAsync(alicePrivateKey, tx);
-    const result = getGenericResult(events);
-
-    // What to expect
-    expect(result.success).to.be.false;
+    await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;
   });
 }
 
@@ -304,11 +292,7 @@
     // Run the transaction
     const sender = privateKey(senderSeed);
     const tx = api.tx.nft.confirmSponsorship(collectionId);
-    const events = await submitTransactionAsync(sender, tx);
-    const result = getGenericResult(events);
-
-    // What to expect
-    expect(result.success).to.be.false;
+    await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
   });
 }