git.delta.rocks / unique-network / refs/commits / 4eaa88907f7a

difftreelog

source

js-packages/tests/nextSponsoring.test.ts3.9 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 type {IKeyringPair} from '@polkadot/types/types';18import {expect, itSub, Pallets, usingPlaygrounds} from './util/index.js';1920const SPONSORING_TIMEOUT = 5;2122describe('Integration Test getNextSponsored(collection_id, owner, item_id):', () => {23  let alice: IKeyringPair;24  let bob: IKeyringPair;2526  before(async () => {27    await usingPlaygrounds(async (helper, privateKey) => {28      const donor = await privateKey({url: import.meta.url});29      [alice, bob] = await helper.arrange.createAccounts([20n, 10n], donor);30    });31  });3233  itSub('NFT', async ({helper}) => {34    // Non-existing collection35    expect(await helper.collection.getTokenNextSponsored(0, 0, {Substrate: alice.address})).to.be.null;3637    const collection = await helper.nft.mintCollection(alice, {});38    const token = await collection.mintToken(alice);3940    // Check with Disabled sponsoring state41    expect(await token.getNextSponsored({Substrate: alice.address})).to.be.null;4243    // Check with Unconfirmed sponsoring state44    await collection.setSponsor(alice, bob.address);45    expect(await token.getNextSponsored({Substrate: alice.address})).to.be.null;4647    // Check with Confirmed sponsoring state48    await collection.confirmSponsorship(bob);49    expect(await token.getNextSponsored({Substrate: alice.address})).to.be.equal(0);5051    // Check after transfer52    await token.transfer(alice, {Substrate: bob.address});53    expect(await token.getNextSponsored({Substrate: alice.address})).to.be.lessThanOrEqual(SPONSORING_TIMEOUT);5455    // Non-existing token56    expect(await collection.getTokenNextSponsored(0, {Substrate: alice.address})).to.be.null;57  });5859  itSub('Fungible', async ({helper}) => {60    const collection = await helper.ft.mintCollection(alice, {});61    await collection.mint(alice, 10n);6263    // Check with Disabled sponsoring state64    expect(await collection.getTokenNextSponsored(0, {Substrate: alice.address})).to.be.null;6566    await collection.setSponsor(alice, bob.address);67    await collection.confirmSponsorship(bob);6869    // Check with Confirmed sponsoring state70    expect(await collection.getTokenNextSponsored(0, {Substrate: alice.address})).to.be.equal(0);7172    // Check after transfer73    await collection.transfer(alice, {Substrate: bob.address});74    expect(await collection.getTokenNextSponsored(0, {Substrate: alice.address})).to.be.lessThanOrEqual(SPONSORING_TIMEOUT);75  });7677  itSub.ifWithPallets('ReFungible', [Pallets.ReFungible], async ({helper}) => {78    const collection = await helper.rft.mintCollection(alice, {});79    const token = await collection.mintToken(alice, 10n);8081    // Check with Disabled sponsoring state82    expect(await token.getNextSponsored({Substrate: alice.address})).to.be.null;8384    await collection.setSponsor(alice, bob.address);85    await collection.confirmSponsorship(bob);8687    // Check with Confirmed sponsoring state88    expect(await token.getNextSponsored({Substrate: alice.address})).to.be.equal(0);8990    // Check after transfer91    await token.transfer(alice, {Substrate: bob.address});92    expect(await token.getNextSponsored({Substrate: alice.address})).to.be.lessThanOrEqual(SPONSORING_TIMEOUT);9394    // Non-existing token95    expect(await collection.getTokenNextSponsored(0, {Substrate: alice.address})).to.be.null;96  });97});