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.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.tsdiffbeforeafterboth7import chaiAsPromised from 'chai-as-promised';7import chaiAsPromised from 'chai-as-promised';8import type { AccountId, EventRecord } from '@polkadot/types/interfaces';8import type { AccountId, EventRecord } from '@polkadot/types/interfaces';9import { ApiPromise, Keyring } from "@polkadot/api";9import { ApiPromise, Keyring } from "@polkadot/api";10import { default as usingApi, submitTransactionAsync } from "../substrate/substrate-api";10import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from "../substrate/substrate-api";11import privateKey from '../substrate/privateKey';11import privateKey from '../substrate/privateKey';12import { alicesPublicKey, nullPublicKey } from "../accounts";12import { alicesPublicKey, nullPublicKey } from "../accounts";13import { strToUTF16, utf16ToStr, hexToStr } from '../util/util';13import { strToUTF16, utf16ToStr, hexToStr } from '../util/util';147 // Run the CreateCollection transaction147 // Run the CreateCollection transaction148 const alicePrivateKey = privateKey('//Alice');148 const alicePrivateKey = privateKey('//Alice');149 const tx = api.tx.nft.createCollection(strToUTF16(name), strToUTF16(description), strToUTF16(tokenPrefix), mode);149 const tx = api.tx.nft.createCollection(strToUTF16(name), strToUTF16(description), strToUTF16(tokenPrefix), mode);150 const events = await submitTransactionAsync(alicePrivateKey, tx);150 const events = await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;151 const result = getCreateCollectionResult(events);151 const result = getCreateCollectionResult(events);152152153 // Get number of collections after the transaction153 // Get number of collections after the transaction187 // Run the DestroyCollection transaction187 // Run the DestroyCollection transaction188 const alicePrivateKey = privateKey(senderSeed);188 const alicePrivateKey = privateKey(senderSeed);189 const tx = api.tx.nft.destroyCollection(collectionId);189 const tx = api.tx.nft.destroyCollection(collectionId);190 const events = await submitTransactionAsync(alicePrivateKey, tx);191 const result = getDestroyResult(events);192193 // What to expect194 expect(result).to.be.false;190 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;195 });191 });196}192}197193257 // Run the transaction253 // Run the transaction258 const alicePrivateKey = privateKey('//Alice');254 const alicePrivateKey = privateKey('//Alice');259 const tx = api.tx.nft.removeCollectionSponsor(collectionId);255 const tx = api.tx.nft.removeCollectionSponsor(collectionId);260 const events = await submitTransactionAsync(alicePrivateKey, tx);261 const result = getGenericResult(events);262263 // What to expect264 expect(result.success).to.be.false;256 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;265 });257 });266}258}267259271 // Run the transaction263 // Run the transaction272 const alicePrivateKey = privateKey(senderSeed);264 const alicePrivateKey = privateKey(senderSeed);273 const tx = api.tx.nft.setCollectionSponsor(collectionId, sponsor);265 const tx = api.tx.nft.setCollectionSponsor(collectionId, sponsor);274 const events = await submitTransactionAsync(alicePrivateKey, tx);275 const result = getGenericResult(events);276277 // What to expect278 expect(result.success).to.be.false;266 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;279 });267 });280}268}281269304 // Run the transaction292 // Run the transaction305 const sender = privateKey(senderSeed);293 const sender = privateKey(senderSeed);306 const tx = api.tx.nft.confirmSponsorship(collectionId);294 const tx = api.tx.nft.confirmSponsorship(collectionId);307 const events = await submitTransactionAsync(sender, tx);308 const result = getGenericResult(events);309310 // What to expect311 expect(result.success).to.be.false;295 await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;312 });296 });313}297}314298