git.delta.rocks / unique-network / refs/commits / e38fb0c231d7

difftreelog

source

tests/src/setCollectionSponsor.test.ts4.1 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} 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  it('Collection admin add sponsor', async () => {69    const collectionId = await createCollectionExpectSuccess();70    await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);71    await setCollectionSponsorExpectSuccess(collectionId, charlie.address, '//Bob');72  });73});7475describe('(!negative test!) integration test: ext. setCollectionSponsor():', () => {76  before(async () => {77    await usingApi(async (api, privateKeyWrapper) => {78      alice = privateKeyWrapper('//Alice');79      bob = privateKeyWrapper('//Bob');80      charlie = privateKeyWrapper('//Charlie');81    });82  });8384  it('(!negative test!) Add sponsor with a non-owner', async () => {85    const collectionId = await createCollectionExpectSuccess();86    await setCollectionSponsorExpectFailure(collectionId, bob.address, '//Bob');87  });88  it('(!negative test!) Add sponsor to a collection that never existed', async () => {89    // Find the collection that never existed90    let collectionId = 0;91    await usingApi(async (api) => {92      collectionId = await getCreatedCollectionCount(api) + 1;93    });9495    await setCollectionSponsorExpectFailure(collectionId, bob.address);96  });97  it('(!negative test!) Add sponsor to a collection that was destroyed', async () => {98    const collectionId = await createCollectionExpectSuccess();99    await destroyCollectionExpectSuccess(collectionId);100    await setCollectionSponsorExpectFailure(collectionId, bob.address);101  });102});