git.delta.rocks / unique-network / refs/commits / 8b81bd98dc15

difftreelog

source

tests/src/setCollectionSponsor.test.ts4.2 KiBsourcehistory
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import 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  requirePallets,27  Pallets,28} from './util/helpers';29import {IKeyringPair} from '@polkadot/types/types';3031chai.use(chaiAsPromised);3233let alice: IKeyringPair;34let bob: IKeyringPair;35let charlie: IKeyringPair;3637describe('integration test: ext. setCollectionSponsor():', () => {3839  before(async () => {40    await usingApi(async (api, privateKeyWrapper) => {41      alice = privateKeyWrapper('//Alice');42      bob = privateKeyWrapper('//Bob');43      charlie = privateKeyWrapper('//Charlie');44    });45  });4647  it('Set NFT collection sponsor', async () => {48    const collectionId = await createCollectionExpectSuccess();49    await setCollectionSponsorExpectSuccess(collectionId, bob.address);50  });51  it('Set Fungible collection sponsor', async () => {52    const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});53    await setCollectionSponsorExpectSuccess(collectionId, bob.address);54  });55  it('Set ReFungible collection sponsor', async function() {56    await requirePallets(this, [Pallets.ReFungible]);5758    const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});59    await setCollectionSponsorExpectSuccess(collectionId, bob.address);60  });6162  it('Set the same sponsor repeatedly', async () => {63    const collectionId = await createCollectionExpectSuccess();64    await setCollectionSponsorExpectSuccess(collectionId, bob.address);65    await setCollectionSponsorExpectSuccess(collectionId, bob.address);66  });67  it('Replace collection sponsor', async () => {68    const collectionId = await createCollectionExpectSuccess();69    await setCollectionSponsorExpectSuccess(collectionId, bob.address);70    await setCollectionSponsorExpectSuccess(collectionId, charlie.address);71  });72  it('Collection admin add sponsor', async () => {73    const collectionId = await createCollectionExpectSuccess();74    await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);75    await setCollectionSponsorExpectSuccess(collectionId, charlie.address, '//Bob');76  });77});7879describe('(!negative test!) integration test: ext. setCollectionSponsor():', () => {80  before(async () => {81    await usingApi(async (api, privateKeyWrapper) => {82      alice = privateKeyWrapper('//Alice');83      bob = privateKeyWrapper('//Bob');84      charlie = privateKeyWrapper('//Charlie');85    });86  });8788  it('(!negative test!) Add sponsor with a non-owner', async () => {89    const collectionId = await createCollectionExpectSuccess();90    await setCollectionSponsorExpectFailure(collectionId, bob.address, '//Bob');91  });92  it('(!negative test!) Add sponsor to a collection that never existed', async () => {93    // Find the collection that never existed94    let collectionId = 0;95    await usingApi(async (api) => {96      collectionId = await getCreatedCollectionCount(api) + 1;97    });9899    await setCollectionSponsorExpectFailure(collectionId, bob.address);100  });101  it('(!negative test!) Add sponsor to a collection that was destroyed', async () => {102    const collectionId = await createCollectionExpectSuccess();103    await destroyCollectionExpectSuccess(collectionId);104    await setCollectionSponsorExpectFailure(collectionId, bob.address);105  });106});