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

difftreelog

source

tests/src/setCollectionSponsor.test.ts3.2 KiBsourcehistory
1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import chai from 'chai';7import chaiAsPromised from 'chai-as-promised';8import { default as usingApi } from "./substrate/substrate-api";9import { createCollectionExpectSuccess, setCollectionSponsorExpectSuccess, destroyCollectionExpectSuccess, setCollectionSponsorExpectFailure } from "./util/helpers";10import { Keyring } from "@polkadot/api";11import { IKeyringPair } from "@polkadot/types/types";1213chai.use(chaiAsPromised);14const expect = chai.expect;1516let bob: IKeyringPair;1718describe('integration test: ext. setCollectionSponsor():', () => {1920  before(async () => {21    await usingApi(async (api) => {22      const keyring = new Keyring({ type: 'sr25519' });23      bob = keyring.addFromUri(`//Bob`);24    });25  });2627  it('Set NFT collection sponsor', async () => {28    const collectionId = await createCollectionExpectSuccess();29    await setCollectionSponsorExpectSuccess(collectionId, bob.address);30  });31  it('Set Fungible collection sponsor', async () => {32    const collectionId = await createCollectionExpectSuccess({ mode: {type: 'Fungible', decimalPoints: 0} });33    await setCollectionSponsorExpectSuccess(collectionId, bob.address);34  });35  it('Set ReFungible collection sponsor', async () => {36    const collectionId = await createCollectionExpectSuccess({ mode: {type: 'ReFungible'} });37    await setCollectionSponsorExpectSuccess(collectionId, bob.address);38  });3940  it('Set the same sponsor repeatedly', async () => {41    const collectionId = await createCollectionExpectSuccess();42    await setCollectionSponsorExpectSuccess(collectionId, bob.address);43    await setCollectionSponsorExpectSuccess(collectionId, bob.address);44  });45  it('Replace collection sponsor', async () => {46    const collectionId = await createCollectionExpectSuccess();4748    const keyring = new Keyring({ type: 'sr25519' });49    const charlie = keyring.addFromUri(`//Charlie`);50    await setCollectionSponsorExpectSuccess(collectionId, bob.address);51    await setCollectionSponsorExpectSuccess(collectionId, charlie.address);52  });53});5455describe('(!negative test!) integration test: ext. setCollectionSponsor():', () => {56  before(async () => {57    await usingApi(async (api) => {58      const keyring = new Keyring({ type: 'sr25519' });59      bob = keyring.addFromUri(`//Bob`);60    });61  });6263  it('(!negative test!) Add sponsor with a non-owner', async () => {64    const collectionId = await createCollectionExpectSuccess();65    await setCollectionSponsorExpectFailure(collectionId, bob.address, '//Bob');66  });67  it('(!negative test!) Add sponsor to a collection that never existed', async () => {68    // Find the collection that never existed69    const collectionId = 0;70    await usingApi(async (api) => {71      const collectionId = parseInt((await api.query.nft.createdCollectionCount()).toString()) + 1;72    });7374    await setCollectionSponsorExpectFailure(collectionId, bob.address);75  });76  it('(!negative test!) Add sponsor to a collection that was destroyed', async () => {77    const collectionId = await createCollectionExpectSuccess();78    await destroyCollectionExpectSuccess(collectionId);79    await setCollectionSponsorExpectFailure(collectionId, bob.address);80  });81});