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.tsdiffbeforeafterboth556import chai from 'chai';6import chai from 'chai';7import chaiAsPromised from 'chai-as-promised';7import chaiAsPromised from 'chai-as-promised';8import { default as usingApi, submitTransactionAsync } from "./substrate/substrate-api";8import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from "./substrate/substrate-api";9import { alicesPublicKey, bobsPublicKey } from "./accounts";9import { alicesPublicKey, bobsPublicKey } from "./accounts";10import privateKey from "./substrate/privateKey";10import privateKey from "./substrate/privateKey";11import { BigNumber } from 'bignumber.js';11import { BigNumber } from 'bignumber.js';63 const bobBalanceBefore = new BigNumber((await api.query.system.account(bobsPublicKey)).data.free.toString());63 const bobBalanceBefore = new BigNumber((await api.query.system.account(bobsPublicKey)).data.free.toString());646465 const badTx = api.tx.balances.setBalance(alicesPublicKey, 0, 0);65 const badTx = api.tx.balances.setBalance(alicesPublicKey, 0, 0);66 const result = getGenericResult(await submitTransactionAsync(bobPrivateKey, badTx));66 await expect(submitTransactionExpectFailAsync(bobPrivateKey, badTx)).to.be.rejected;676768 const treasuryBalanceAfter = new BigNumber((await api.query.system.account(Treasury)).data.free.toString());68 const treasuryBalanceAfter = new BigNumber((await api.query.system.account(Treasury)).data.free.toString());69 const bobBalanceAfter = new BigNumber((await api.query.system.account(bobsPublicKey)).data.free.toString());69 const bobBalanceAfter = new BigNumber((await api.query.system.account(bobsPublicKey)).data.free.toString());70 const fee = bobBalanceBefore.minus(bobBalanceAfter);70 const fee = bobBalanceBefore.minus(bobBalanceAfter);71 const treasuryIncrease = treasuryBalanceAfter.minus(treasuryBalanceBefore);71 const treasuryIncrease = treasuryBalanceAfter.minus(treasuryBalanceBefore);727273 expect(result.success).to.be.false;74 expect(treasuryIncrease.toFixed()).to.be.equal(fee.toFixed());73 expect(treasuryIncrease.toFixed()).to.be.equal(fee.toFixed());75 });74 });76 });75 });tests/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) {
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;
});
}