123456import chai from 'chai';7import chaiAsPromised from 'chai-as-promised';8import privateKey from './substrate/privateKey';9import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from "./substrate/substrate-api";10import { createCollectionExpectSuccess, createCollectionExpectFailure, normalizeAccountId } from "./util/helpers";1112chai.use(chaiAsPromised);13const expect = chai.expect;1415describe('Integration Test changeCollectionOwner(collection_id, new_owner):', () => {16 it('Changing owner changes owner.', async () => {17 await usingApi(async api => {18 const collectionId = await createCollectionExpectSuccess();19 const alice = privateKey('//Alice');20 const bob = privateKey('//Bob');2122 const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();23 expect(collection.Owner).to.be.deep.eq(normalizeAccountId(alice.address));2425 const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, normalizeAccountId(bob.address));26 await submitTransactionAsync(alice, changeOwnerTx);2728 const collectionAfterOwnerChange: any = (await api.query.nft.collectionById(collectionId)).toJSON();29 expect(collectionAfterOwnerChange.Owner).to.be.deep.eq(normalizeAccountId(bob.address));30 });31 });32});3334describe('Negative Integration Test changeCollectionOwner(collection_id, new_owner):', () => {35 it(`Not owner can't change owner.`, async () => {36 await usingApi(async api => {37 const collectionId = await createCollectionExpectSuccess();38 const alice = privateKey('//Alice');39 const bob = privateKey('//Bob');4041 const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, normalizeAccountId(bob.address));42 await expect(submitTransactionExpectFailAsync(bob, changeOwnerTx)).to.be.rejected;4344 const collectionAfterOwnerChange: any = (await api.query.nft.collectionById(collectionId)).toJSON();45 expect(collectionAfterOwnerChange.Owner).to.be.deep.eq(normalizeAccountId(alice.address));4647 48 await createCollectionExpectSuccess();49 });50 });51 it(`Can't change owner of not existing collection.`, async () => {52 await usingApi(async api => {53 const collectionId = (1<<32) - 1;54 const alice = privateKey('//Alice');55 const bob = privateKey('//Bob');5657 const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, normalizeAccountId(bob.address));58 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;5960 61 await createCollectionExpectSuccess();62 });63 });64});