git.delta.rocks / unique-network / refs/commits / 9abd4dac4b08

difftreelog

source

tests/src/change-collection-owner.test.ts2.6 KiBsourcehistory
1import chai from 'chai';2import chaiAsPromised from 'chai-as-promised';3import privateKey from './substrate/privateKey';4import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from "./substrate/substrate-api";5import { createCollectionExpectSuccess, createCollectionExpectFailure } from "./util/helpers";67chai.use(chaiAsPromised);8const expect = chai.expect;910describe('Integration Test changeCollectionOwner(collection_id, new_owner):', () => {11  it('Changing owner changes owner.', async () => {12    await usingApi(async api => {13      const collectionId = await createCollectionExpectSuccess();14      const alice = privateKey('//Alice');15      const bob = privateKey('//Bob');1617      const collection: any = (await api.query.nft.collection(collectionId));18      expect(collection.Owner.toString()).to.be.eq(alice.address);1920      const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);21      await submitTransactionAsync(alice, changeOwnerTx);2223      const collectionAfterOwnerChange: any = (await api.query.nft.collection(collectionId));24      expect(collectionAfterOwnerChange.Owner.toString()).to.be.eq(bob.address);25    });26  });27});2829describe('Negative Integration Test changeCollectionOwner(collection_id, new_owner):', () => {30  it(`Not owner can't change owner.`, async () => {31    await usingApi(async api => {32      const collectionId = await createCollectionExpectSuccess();33      const alice = privateKey('//Alice');34      const bob = privateKey('//Bob');3536      const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);37      await expect(submitTransactionExpectFailAsync(bob, changeOwnerTx)).to.be.rejected;3839      const collectionAfterOwnerChange: any = (await api.query.nft.collection(collectionId));40      expect(collectionAfterOwnerChange.Owner.toString()).to.be.eq(alice.address);4142      // Verifying that nothing bad happened (network is live, new collections can be created, etc.)43      await createCollectionExpectSuccess();44    });45  });46  it(`Can't change owner of not existing collection.`, async () => {47    await usingApi(async api => {48      const collectionId = (1<<32) - 1;49      const alice = privateKey('//Alice');50      const bob = privateKey('//Bob');5152      const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);53      await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;5455      // Verifying that nothing bad happened (network is live, new collections can be created, etc.)56      await createCollectionExpectSuccess();57    });58  });59});