1234567891011121314151617import chai from 'chai';18import chaiAsPromised from 'chai-as-promised';19import {default as usingApi} from './substrate/substrate-api';20import {createCollectionExpectSuccess,21 setCollectionSponsorExpectSuccess,22 destroyCollectionExpectSuccess,23 setCollectionSponsorExpectFailure,24 addCollectionAdminExpectSuccess,25 getCreatedCollectionCount,26} from './util/helpers';27import {IKeyringPair} from '@polkadot/types/types';2829chai.use(chaiAsPromised);3031let alice: IKeyringPair;32let bob: IKeyringPair;33let charlie: IKeyringPair;3435describe('integration test: ext. setCollectionSponsor():', () => {3637 before(async () => {38 await usingApi(async (api, privateKeyWrapper) => {39 alice = privateKeyWrapper('//Alice');40 bob = privateKeyWrapper('//Bob');41 charlie = privateKeyWrapper('//Charlie');42 });43 });4445 it('Set NFT collection sponsor', async () => {46 const collectionId = await createCollectionExpectSuccess();47 await setCollectionSponsorExpectSuccess(collectionId, bob.address);48 });49 it('Set Fungible collection sponsor', async () => {50 const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});51 await setCollectionSponsorExpectSuccess(collectionId, bob.address);52 });53 it('Set ReFungible collection sponsor', async () => {54 const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});55 await setCollectionSponsorExpectSuccess(collectionId, bob.address);56 });5758 it('Set the same sponsor repeatedly', async () => {59 const collectionId = await createCollectionExpectSuccess();60 await setCollectionSponsorExpectSuccess(collectionId, bob.address);61 await setCollectionSponsorExpectSuccess(collectionId, bob.address);62 });63 it('Replace collection sponsor', async () => {64 const collectionId = await createCollectionExpectSuccess();65 await setCollectionSponsorExpectSuccess(collectionId, bob.address);66 await setCollectionSponsorExpectSuccess(collectionId, charlie.address);67 });68});6970describe('(!negative test!) integration test: ext. setCollectionSponsor():', () => {71 before(async () => {72 await usingApi(async (api, privateKeyWrapper) => {73 alice = privateKeyWrapper('//Alice');74 bob = privateKeyWrapper('//Bob');75 charlie = privateKeyWrapper('//Charlie');76 });77 });7879 it('(!negative test!) Add sponsor with a non-owner', async () => {80 const collectionId = await createCollectionExpectSuccess();81 await setCollectionSponsorExpectFailure(collectionId, bob.address, '//Bob');82 });83 it('(!negative test!) Add sponsor to a collection that never existed', async () => {84 85 let collectionId = 0;86 await usingApi(async (api) => {87 collectionId = await getCreatedCollectionCount(api) + 1;88 });8990 await setCollectionSponsorExpectFailure(collectionId, bob.address);91 });92 it('(!negative test!) Add sponsor to a collection that was destroyed', async () => {93 const collectionId = await createCollectionExpectSuccess();94 await destroyCollectionExpectSuccess(collectionId);95 await setCollectionSponsorExpectFailure(collectionId, bob.address);96 });97 it('(!negative test!) Collection admin add sponsor', async () => {98 const collectionId = await createCollectionExpectSuccess();99 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);100 await setCollectionSponsorExpectFailure(collectionId, charlie.address, '//Bob');101 });102});