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
55
6import 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());
6464
65 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;
6767
68 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);
7272
73 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 });
modifiedtests/src/substrate/substrate-api.tsdiffbeforeafterboth
68 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) {
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
7import 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 transaction
148 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);
152152
153 // Get number of collections after the transaction153 // Get number of collections after the transaction
187 // Run the DestroyCollection transaction187 // Run the DestroyCollection transaction
188 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);
192
193 // What to expect
194 expect(result).to.be.false;190 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;
195 });191 });
196}192}
197193
257 // Run the transaction253 // Run the transaction
258 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);
262
263 // What to expect
264 expect(result.success).to.be.false;256 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;
265 });257 });
266}258}
267259
271 // Run the transaction263 // Run the transaction
272 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);
276
277 // What to expect
278 expect(result.success).to.be.false;266 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;
279 });267 });
280}268}
281269
304 // Run the transaction292 // Run the transaction
305 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);
309
310 // What to expect
311 expect(result.success).to.be.false;295 await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
312 });296 });
313}297}
314298