difftreelog
NFTPAR-237 Integration Test changeCollectionOwner(collection_id, new_owner). Fixed tests.
in: master
4 files changed
tests/src/confirmSponsorship.test.tsdiffbeforeafterboth89 });89 });909091 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');9595115 });115 });116116117 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');121121210 });210 });211211212 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');216216247 });247 });248248249 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');253253tests/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.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.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