difftreelog
NFTPAR-237 Integration Test changeCollectionOwner(collection_id, new_owner). Fixed tests.
in: master
4 files changed
tests/src/confirmSponsorship.test.tsdiffbeforeafterboth--- a/tests/src/confirmSponsorship.test.ts
+++ b/tests/src/confirmSponsorship.test.ts
@@ -89,7 +89,7 @@
});
it('Fungible: Transfer fees are paid by the sponsor after confirmation', async () => {
- const collectionId = await createCollectionExpectSuccess();
+ const collectionId = await createCollectionExpectSuccess({mode: 'Fungible'});
await setCollectionSponsorExpectSuccess(collectionId, bob.address);
await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
@@ -115,7 +115,7 @@
});
it('ReFungible: Transfer fees are paid by the sponsor after confirmation', async () => {
- const collectionId = await createCollectionExpectSuccess();
+ const collectionId = await createCollectionExpectSuccess({mode: 'ReFungible'});
await setCollectionSponsorExpectSuccess(collectionId, bob.address);
await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
@@ -210,7 +210,7 @@
});
it('Fungible: Sponsoring is rate limited', async () => {
- const collectionId = await createCollectionExpectSuccess();
+ const collectionId = await createCollectionExpectSuccess({mode: 'Fungible'});
await setCollectionSponsorExpectSuccess(collectionId, bob.address);
await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
@@ -247,7 +247,7 @@
});
it('ReFungible: Sponsoring is rate limited', async () => {
- const collectionId = await createCollectionExpectSuccess();
+ const collectionId = await createCollectionExpectSuccess({mode: 'ReFungible'});
await setCollectionSponsorExpectSuccess(collectionId, bob.address);
await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
tests/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());
});
});
tests/src/substrate/substrate-api.tsdiffbeforeafterboth68 resolve(events);68 resolve(events);69 } else if (transactionStatus == TransactionStatus.Fail) {69 } else if (transactionStatus == TransactionStatus.Fail) {70 console.log(`Something went wrong with transaction. Status: ${status}`);70 console.log(`Something went wrong with transaction. Status: ${status}`);71 reject("Transaction failed");71 reject(events);72 }72 }73 });73 });74 } catch (e) {74 } catch (e) {107 if (transactionStatus == TransactionStatus.Success) {107 if (transactionStatus == TransactionStatus.Success) {108 resolve(events);108 resolve(events);109 } else if (transactionStatus == TransactionStatus.Fail) {109 } else if (transactionStatus == TransactionStatus.Fail) {110 reject("Transaction failed");110 reject(events);111 }111 }112 });112 });113 } catch (e) {113 } catch (e) {tests/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;
});
}