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

difftreelog

Merge pull request #51 from usetech-llc/feature/NFTPAR-246_remove_sponsor_tests

str-mv2020-12-25parents: #cd29302 #bd903ea.patch.diff
in: master
NFTPAR-246 remove sponsor tests

3 files changed

modifiedtests/src/confirmSponsorship.test.tsdiffbeforeafterboth
before · tests/src/confirmSponsorship.test.ts
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, submitTransactionAsync } from "./substrate/substrate-api";9import { 10  createCollectionExpectSuccess, 11  setCollectionSponsorExpectSuccess, 12  destroyCollectionExpectSuccess, 13  setCollectionSponsorExpectFailure,14  confirmSponsorshipExpectSuccess,15  confirmSponsorshipExpectFailure,16  createItemExpectSuccess,17  findUnusedAddress,18  getGenericResult,19  enableWhiteListExpectSuccess,20  enablePublicMintingExpectSuccess,21  addToWhiteListExpectSuccess,22} from "./util/helpers";23import { Keyring } from "@polkadot/api";24import { IKeyringPair } from "@polkadot/types/types";25import type { AccountId } from '@polkadot/types/interfaces';26import { BigNumber } from 'bignumber.js';2728chai.use(chaiAsPromised);29const expect = chai.expect;3031let alice: IKeyringPair;32let bob: IKeyringPair;33let charlie: IKeyringPair;3435describe.only('integration test: ext. confirmSponsorship():', () => {3637  before(async () => {38    await usingApi(async (api) => {39      const keyring = new Keyring({ type: 'sr25519' });40      alice = keyring.addFromUri(`//Alice`);41      bob = keyring.addFromUri(`//Bob`);42      charlie = keyring.addFromUri(`//Charlie`);43    });44  });4546  it('Confirm collection sponsorship', async () => {47    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');48    await setCollectionSponsorExpectSuccess(collectionId, bob.address);49    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');50  });51  it('Add sponsor to a collection after the same sponsor was already added and confirmed', async () => {52    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');53    await setCollectionSponsorExpectSuccess(collectionId, bob.address);54    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');55    await setCollectionSponsorExpectSuccess(collectionId, bob.address);56  });57  it('Add new sponsor to a collection after another sponsor was already added and confirmed', async () => {58    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');59    await setCollectionSponsorExpectSuccess(collectionId, bob.address);60    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');61    await setCollectionSponsorExpectSuccess(collectionId, charlie.address);62  });6364  it('NFT: Transfer fees are paid by the sponsor after confirmation', async () => {65    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');66    await setCollectionSponsorExpectSuccess(collectionId, bob.address);67    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');6869    await usingApi(async (api) => {70      const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());7172      // Find unused address73      const zeroBalance = await findUnusedAddress(api);7475      // Mint token for unused address76      const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', zeroBalance.address);7778      // Transfer this tokens from unused address to Alice79      const zeroToAlice = api.tx.nft.transfer(zeroBalance.address, collectionId, itemId, 0);80      const events = await submitTransactionAsync(zeroBalance, zeroToAlice);81      const result = getGenericResult(events);8283      const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());8485      expect(result.success).to.be.true;86      expect(BsponsorBalance.lt(AsponsorBalance)).to.be.true;87    });8889  });9091  it('Fungible: Transfer fees are paid by the sponsor after confirmation', async () => {92    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'Fungible');93    await setCollectionSponsorExpectSuccess(collectionId, bob.address);94    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');9596    await usingApi(async (api) => {97      const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());9899      // Find unused address100      const zeroBalance = await findUnusedAddress(api);101102      // Mint token for unused address103      const itemId = await createItemExpectSuccess(alice, collectionId, 'Fungible', zeroBalance.address);104105      // Transfer this tokens from unused address to Alice106      const zeroToAlice = api.tx.nft.transfer(zeroBalance.address, collectionId, itemId, 1);107      const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);108      const result1 = getGenericResult(events1);109110      const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());111112      expect(result1.success).to.be.true;113      expect(BsponsorBalance.lt(AsponsorBalance)).to.be.true;114    });115  });116117  it('ReFungible: Transfer fees are paid by the sponsor after confirmation', async () => {118    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'ReFungible');119    await setCollectionSponsorExpectSuccess(collectionId, bob.address);120    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');121122    await usingApi(async (api) => {123      const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());124125      // Find unused address126      const zeroBalance = await findUnusedAddress(api);127128      // Mint token for unused address129      const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', zeroBalance.address);130131      // Transfer this tokens from unused address to Alice132      const zeroToAlice = api.tx.nft.transfer(zeroBalance.address, collectionId, itemId, 1);133      const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);134      const result1 = getGenericResult(events1);135136      const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());137138      expect(result1.success).to.be.true;139      expect(BsponsorBalance.lt(AsponsorBalance)).to.be.true;140    });141  });142143  it('CreateItem fees are paid by the sponsor after confirmation', async () => {144    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');145    await setCollectionSponsorExpectSuccess(collectionId, bob.address);146    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');147148    // Enable collection white list 149    await enableWhiteListExpectSuccess(alice, collectionId);150151    // Enable public minting152    await enablePublicMintingExpectSuccess(alice, collectionId);153154    // Create Item 155    await usingApi(async (api) => {156      const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());157158      // Find unused address159      const zeroBalance = await findUnusedAddress(api);160161      // Add zeroBalance address to white list162      await addToWhiteListExpectSuccess(alice, collectionId, zeroBalance.address);163164      // Mint token using unused address as signer165      const tokenId = await createItemExpectSuccess(zeroBalance, collectionId, 'NFT', zeroBalance.address);166167      const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());168169      expect(BsponsorBalance.lt(AsponsorBalance)).to.be.true;170    });171  });172173  it('NFT: Sponsoring is rate limited', async () => {174    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');175    await setCollectionSponsorExpectSuccess(collectionId, bob.address);176    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');177178    await usingApi(async (api) => {179      // Find unused address180      const zeroBalance = await findUnusedAddress(api);181182      // Mint token for alice183      const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);184185      // Transfer this token from Alice to unused address and back186      // Alice to Zero gets sponsored187      const aliceToZero = api.tx.nft.transfer(zeroBalance.address, collectionId, itemId, 0);188      const events1 = await submitTransactionAsync(alice, aliceToZero);189      const result1 = getGenericResult(events1);190191      // Second transfer should fail192      const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());193      const zeroToAlice = api.tx.nft.transfer(alice.address, collectionId, itemId, 0);194      const badTransaction = async function () { 195        console.log = function () {};196        console.error = function () {};197        await submitTransactionAsync(zeroBalance, zeroToAlice);198        delete console.log;199        delete console.error;200      };201      await expect(badTransaction()).to.be.rejectedWith("Inability to pay some fees");202      const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());203204      // Try again after Zero gets some balance - now it should succeed205      const balancetx = api.tx.balances.transfer(zeroBalance.address, 1e15);206      await submitTransactionAsync(alice, balancetx);207      const events2 = await submitTransactionAsync(zeroBalance, zeroToAlice);208      const result2 = getGenericResult(events2);209210      expect(result1.success).to.be.true;211      expect(result2.success).to.be.true;212      expect(BsponsorBalance.isEqualTo(AsponsorBalance)).to.be.true;213    });214  });215216  it('Fungible: Sponsoring is rate limited', async () => {217    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'Fungible');218    await setCollectionSponsorExpectSuccess(collectionId, bob.address);219    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');220221    await usingApi(async (api) => {222      // Find unused address223      const zeroBalance = await findUnusedAddress(api);224225      // Mint token for unused address226      const itemId = await createItemExpectSuccess(alice, collectionId, 'Fungible', zeroBalance.address);227228      // Transfer this tokens in parts from unused address to Alice229      const zeroToAlice = api.tx.nft.transfer(zeroBalance.address, collectionId, itemId, 1);230      const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);231      const result1 = getGenericResult(events1);232233      const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());234235      const badTransaction = async function () { 236        console.log = function () {};237        console.error = function () {};238        await submitTransactionAsync(zeroBalance, zeroToAlice);239        delete console.log;240        delete console.error;241      };242243      const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());244245      // Try again after Zero gets some balance - now it should succeed246      const balancetx = api.tx.balances.transfer(zeroBalance.address, 1e15);247      await submitTransactionAsync(alice, balancetx);248      const events2 = await submitTransactionAsync(zeroBalance, zeroToAlice);249      const result2 = getGenericResult(events2);250251      expect(result1.success).to.be.true;252      expect(result2.success).to.be.true;253      expect(BsponsorBalance.isEqualTo(AsponsorBalance)).to.be.true;254    });255  });256257  it('ReFungible: Sponsoring is rate limited', async () => {258    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'ReFungible');259    await setCollectionSponsorExpectSuccess(collectionId, bob.address);260    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');261262    await usingApi(async (api) => {263      // Find unused address264      const zeroBalance = await findUnusedAddress(api);265266      // Mint token for alice267      const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', alice.address);268269      // Transfer this token from Alice to unused address and back270      // Alice to Zero gets sponsored271      const aliceToZero = api.tx.nft.transfer(zeroBalance.address, collectionId, itemId, 1);272      const events1 = await submitTransactionAsync(alice, aliceToZero);273      const result1 = getGenericResult(events1);274275      // Second transfer should fail276      const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());277      const zeroToAlice = api.tx.nft.transfer(alice.address, collectionId, itemId, 1);278      const badTransaction = async function () { 279        console.log = function () {};280        console.error = function () {};281        await submitTransactionAsync(zeroBalance, zeroToAlice);282        delete console.log;283        delete console.error;284      };285      await expect(badTransaction()).to.be.rejectedWith("Inability to pay some fees");286      const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());287288      // Try again after Zero gets some balance - now it should succeed289      const balancetx = api.tx.balances.transfer(zeroBalance.address, 1e15);290      await submitTransactionAsync(alice, balancetx);291      const events2 = await submitTransactionAsync(zeroBalance, zeroToAlice);292      const result2 = getGenericResult(events2);293294      expect(result1.success).to.be.true;295      expect(result2.success).to.be.true;296      expect(BsponsorBalance.isEqualTo(AsponsorBalance)).to.be.true;297    });298  });299300});301302describe.only('(!negative test!) integration test: ext. setCollectionSponsor():', () => {303  before(async () => {304    await usingApi(async (api) => {305      const keyring = new Keyring({ type: 'sr25519' });306      alice = keyring.addFromUri(`//Alice`);307      bob = keyring.addFromUri(`//Bob`);308      charlie = keyring.addFromUri(`//Charlie`);309    });310  });311312  it('(!negative test!) Confirm sponsorship for a collection that never existed', async () => {313    // Find the collection that never existed314    const collectionId = 0;315    await usingApi(async (api) => {316      const collectionId = parseInt((await api.query.nft.createdCollectionCount()).toString()) + 1;317    });318319    await confirmSponsorshipExpectFailure(collectionId, '//Bob');320  });321322  it('(!negative test!) Confirm sponsorship using a non-sponsor address', async () => {323    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');324    await setCollectionSponsorExpectSuccess(collectionId, bob.address);325326    await usingApi(async (api) => {327      const transfer = api.tx.balances.transfer(charlie.address, 1e15);328      await submitTransactionAsync(alice, transfer);329    });330331    await confirmSponsorshipExpectFailure(collectionId, '//Charlie');332  });333334  it('(!negative test!) Confirm sponsorship using owner address', async () => {335    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');336    await setCollectionSponsorExpectSuccess(collectionId, bob.address);337    await confirmSponsorshipExpectFailure(collectionId, '//Alice');338  });339340  it('(!negative test!) Confirm sponsorship without sponsor being set with setCollectionSponsor', async () => {341    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');342    await confirmSponsorshipExpectFailure(collectionId, '//Bob');343  });344    345  it('(!negative test!) Confirm sponsorship in a collection that was destroyed', async () => {346    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');347    await destroyCollectionExpectSuccess(collectionId);348    await confirmSponsorshipExpectFailure(collectionId, '//Bob');349  });350});
after · tests/src/confirmSponsorship.test.ts
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, submitTransactionAsync } from "./substrate/substrate-api";9import { 10  createCollectionExpectSuccess, 11  setCollectionSponsorExpectSuccess, 12  destroyCollectionExpectSuccess, 13  setCollectionSponsorExpectFailure,14  confirmSponsorshipExpectSuccess,15  confirmSponsorshipExpectFailure,16  createItemExpectSuccess,17  findUnusedAddress,18  getGenericResult,19  enableWhiteListExpectSuccess,20  enablePublicMintingExpectSuccess,21  addToWhiteListExpectSuccess,22} from "./util/helpers";23import { Keyring } from "@polkadot/api";24import { IKeyringPair } from "@polkadot/types/types";25import type { AccountId } from '@polkadot/types/interfaces';26import { BigNumber } from 'bignumber.js';2728chai.use(chaiAsPromised);29const expect = chai.expect;3031let alice: IKeyringPair;32let bob: IKeyringPair;33let charlie: IKeyringPair;3435describe('integration test: ext. confirmSponsorship():', () => {3637  before(async () => {38    await usingApi(async (api) => {39      const keyring = new Keyring({ type: 'sr25519' });40      alice = keyring.addFromUri(`//Alice`);41      bob = keyring.addFromUri(`//Bob`);42      charlie = keyring.addFromUri(`//Charlie`);43    });44  });4546  it('Confirm collection sponsorship', async () => {47    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');48    await setCollectionSponsorExpectSuccess(collectionId, bob.address);49    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');50  });51  it('Add sponsor to a collection after the same sponsor was already added and confirmed', async () => {52    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');53    await setCollectionSponsorExpectSuccess(collectionId, bob.address);54    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');55    await setCollectionSponsorExpectSuccess(collectionId, bob.address);56  });57  it('Add new sponsor to a collection after another sponsor was already added and confirmed', async () => {58    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');59    await setCollectionSponsorExpectSuccess(collectionId, bob.address);60    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');61    await setCollectionSponsorExpectSuccess(collectionId, charlie.address);62  });6364  it('NFT: Transfer fees are paid by the sponsor after confirmation', async () => {65    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');66    await setCollectionSponsorExpectSuccess(collectionId, bob.address);67    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');6869    await usingApi(async (api) => {70      const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());7172      // Find unused address73      const zeroBalance = await findUnusedAddress(api);7475      // Mint token for unused address76      const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', zeroBalance.address);7778      // Transfer this tokens from unused address to Alice79      const zeroToAlice = api.tx.nft.transfer(zeroBalance.address, collectionId, itemId, 0);80      const events = await submitTransactionAsync(zeroBalance, zeroToAlice);81      const result = getGenericResult(events);8283      const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());8485      expect(result.success).to.be.true;86      expect(BsponsorBalance.lt(AsponsorBalance)).to.be.true;87    });8889  });9091  it('Fungible: Transfer fees are paid by the sponsor after confirmation', async () => {92    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'Fungible');93    await setCollectionSponsorExpectSuccess(collectionId, bob.address);94    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');9596    await usingApi(async (api) => {97      const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());9899      // Find unused address100      const zeroBalance = await findUnusedAddress(api);101102      // Mint token for unused address103      const itemId = await createItemExpectSuccess(alice, collectionId, 'Fungible', zeroBalance.address);104105      // Transfer this tokens from unused address to Alice106      const zeroToAlice = api.tx.nft.transfer(zeroBalance.address, collectionId, itemId, 1);107      const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);108      const result1 = getGenericResult(events1);109110      const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());111112      expect(result1.success).to.be.true;113      expect(BsponsorBalance.lt(AsponsorBalance)).to.be.true;114    });115  });116117  it('ReFungible: Transfer fees are paid by the sponsor after confirmation', async () => {118    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'ReFungible');119    await setCollectionSponsorExpectSuccess(collectionId, bob.address);120    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');121122    await usingApi(async (api) => {123      const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());124125      // Find unused address126      const zeroBalance = await findUnusedAddress(api);127128      // Mint token for unused address129      const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', zeroBalance.address);130131      // Transfer this tokens from unused address to Alice132      const zeroToAlice = api.tx.nft.transfer(zeroBalance.address, collectionId, itemId, 1);133      const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);134      const result1 = getGenericResult(events1);135136      const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());137138      expect(result1.success).to.be.true;139      expect(BsponsorBalance.lt(AsponsorBalance)).to.be.true;140    });141  });142143  it('CreateItem fees are paid by the sponsor after confirmation', async () => {144    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');145    await setCollectionSponsorExpectSuccess(collectionId, bob.address);146    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');147148    // Enable collection white list 149    await enableWhiteListExpectSuccess(alice, collectionId);150151    // Enable public minting152    await enablePublicMintingExpectSuccess(alice, collectionId);153154    // Create Item 155    await usingApi(async (api) => {156      const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());157158      // Find unused address159      const zeroBalance = await findUnusedAddress(api);160161      // Add zeroBalance address to white list162      await addToWhiteListExpectSuccess(alice, collectionId, zeroBalance.address);163164      // Mint token using unused address as signer165      const tokenId = await createItemExpectSuccess(zeroBalance, collectionId, 'NFT', zeroBalance.address);166167      const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());168169      expect(BsponsorBalance.lt(AsponsorBalance)).to.be.true;170    });171  });172173  it('NFT: Sponsoring is rate limited', async () => {174    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');175    await setCollectionSponsorExpectSuccess(collectionId, bob.address);176    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');177178    await usingApi(async (api) => {179      // Find unused address180      const zeroBalance = await findUnusedAddress(api);181182      // Mint token for alice183      const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);184185      // Transfer this token from Alice to unused address and back186      // Alice to Zero gets sponsored187      const aliceToZero = api.tx.nft.transfer(zeroBalance.address, collectionId, itemId, 0);188      const events1 = await submitTransactionAsync(alice, aliceToZero);189      const result1 = getGenericResult(events1);190191      // Second transfer should fail192      const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());193      const zeroToAlice = api.tx.nft.transfer(alice.address, collectionId, itemId, 0);194      const badTransaction = async function () { 195        console.log = function () {};196        console.error = function () {};197        await submitTransactionAsync(zeroBalance, zeroToAlice);198        delete console.log;199        delete console.error;200      };201      await expect(badTransaction()).to.be.rejectedWith("Inability to pay some fees");202      const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());203204      // Try again after Zero gets some balance - now it should succeed205      const balancetx = api.tx.balances.transfer(zeroBalance.address, 1e15);206      await submitTransactionAsync(alice, balancetx);207      const events2 = await submitTransactionAsync(zeroBalance, zeroToAlice);208      const result2 = getGenericResult(events2);209210      expect(result1.success).to.be.true;211      expect(result2.success).to.be.true;212      expect(BsponsorBalance.isEqualTo(AsponsorBalance)).to.be.true;213    });214  });215216  it('Fungible: Sponsoring is rate limited', async () => {217    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'Fungible');218    await setCollectionSponsorExpectSuccess(collectionId, bob.address);219    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');220221    await usingApi(async (api) => {222      // Find unused address223      const zeroBalance = await findUnusedAddress(api);224225      // Mint token for unused address226      const itemId = await createItemExpectSuccess(alice, collectionId, 'Fungible', zeroBalance.address);227228      // Transfer this tokens in parts from unused address to Alice229      const zeroToAlice = api.tx.nft.transfer(zeroBalance.address, collectionId, itemId, 1);230      const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);231      const result1 = getGenericResult(events1);232233      const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());234235      const badTransaction = async function () { 236        console.log = function () {};237        console.error = function () {};238        await submitTransactionAsync(zeroBalance, zeroToAlice);239        delete console.log;240        delete console.error;241      };242243      const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());244245      // Try again after Zero gets some balance - now it should succeed246      const balancetx = api.tx.balances.transfer(zeroBalance.address, 1e15);247      await submitTransactionAsync(alice, balancetx);248      const events2 = await submitTransactionAsync(zeroBalance, zeroToAlice);249      const result2 = getGenericResult(events2);250251      expect(result1.success).to.be.true;252      expect(result2.success).to.be.true;253      expect(BsponsorBalance.isEqualTo(AsponsorBalance)).to.be.true;254    });255  });256257  it('ReFungible: Sponsoring is rate limited', async () => {258    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'ReFungible');259    await setCollectionSponsorExpectSuccess(collectionId, bob.address);260    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');261262    await usingApi(async (api) => {263      // Find unused address264      const zeroBalance = await findUnusedAddress(api);265266      // Mint token for alice267      const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', alice.address);268269      // Transfer this token from Alice to unused address and back270      // Alice to Zero gets sponsored271      const aliceToZero = api.tx.nft.transfer(zeroBalance.address, collectionId, itemId, 1);272      const events1 = await submitTransactionAsync(alice, aliceToZero);273      const result1 = getGenericResult(events1);274275      // Second transfer should fail276      const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());277      const zeroToAlice = api.tx.nft.transfer(alice.address, collectionId, itemId, 1);278      const badTransaction = async function () { 279        console.log = function () {};280        console.error = function () {};281        await submitTransactionAsync(zeroBalance, zeroToAlice);282        delete console.log;283        delete console.error;284      };285      await expect(badTransaction()).to.be.rejectedWith("Inability to pay some fees");286      const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());287288      // Try again after Zero gets some balance - now it should succeed289      const balancetx = api.tx.balances.transfer(zeroBalance.address, 1e15);290      await submitTransactionAsync(alice, balancetx);291      const events2 = await submitTransactionAsync(zeroBalance, zeroToAlice);292      const result2 = getGenericResult(events2);293294      expect(result1.success).to.be.true;295      expect(result2.success).to.be.true;296      expect(BsponsorBalance.isEqualTo(AsponsorBalance)).to.be.true;297    });298  });299300});301302describe('(!negative test!) integration test: ext. removeCollectionSponsor():', () => {303  before(async () => {304    await usingApi(async (api) => {305      const keyring = new Keyring({ type: 'sr25519' });306      alice = keyring.addFromUri(`//Alice`);307      bob = keyring.addFromUri(`//Bob`);308      charlie = keyring.addFromUri(`//Charlie`);309    });310  });311312  it('(!negative test!) Confirm sponsorship for a collection that never existed', async () => {313    // Find the collection that never existed314    const collectionId = 0;315    await usingApi(async (api) => {316      const collectionId = parseInt((await api.query.nft.createdCollectionCount()).toString()) + 1;317    });318319    await confirmSponsorshipExpectFailure(collectionId, '//Bob');320  });321322  it('(!negative test!) Confirm sponsorship using a non-sponsor address', async () => {323    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');324    await setCollectionSponsorExpectSuccess(collectionId, bob.address);325326    await usingApi(async (api) => {327      const transfer = api.tx.balances.transfer(charlie.address, 1e15);328      await submitTransactionAsync(alice, transfer);329    });330331    await confirmSponsorshipExpectFailure(collectionId, '//Charlie');332  });333334  it('(!negative test!) Confirm sponsorship using owner address', async () => {335    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');336    await setCollectionSponsorExpectSuccess(collectionId, bob.address);337    await confirmSponsorshipExpectFailure(collectionId, '//Alice');338  });339340  it('(!negative test!) Confirm sponsorship without sponsor being set with setCollectionSponsor', async () => {341    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');342    await confirmSponsorshipExpectFailure(collectionId, '//Bob');343  });344    345  it('(!negative test!) Confirm sponsorship in a collection that was destroyed', async () => {346    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');347    await destroyCollectionExpectSuccess(collectionId);348    await confirmSponsorshipExpectFailure(collectionId, '//Bob');349  });350});
addedtests/src/removeCollectionSponsor.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/removeCollectionSponsor.test.ts
@@ -0,0 +1,141 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
+import chai from 'chai';
+import chaiAsPromised from 'chai-as-promised';
+import { default as usingApi, submitTransactionAsync } from "./substrate/substrate-api";
+import { 
+  createCollectionExpectSuccess, 
+  setCollectionSponsorExpectSuccess, 
+  destroyCollectionExpectSuccess, 
+  setCollectionSponsorExpectFailure,
+  confirmSponsorshipExpectSuccess,
+  confirmSponsorshipExpectFailure,
+  createItemExpectSuccess,
+  findUnusedAddress,
+  getGenericResult,
+  enableWhiteListExpectSuccess,
+  enablePublicMintingExpectSuccess,
+  addToWhiteListExpectSuccess,
+  removeCollectionSponsorExpectSuccess,
+  removeCollectionSponsorExpectFailure,
+} from "./util/helpers";
+import { Keyring } from "@polkadot/api";
+import { IKeyringPair } from "@polkadot/types/types";
+import type { AccountId } from '@polkadot/types/interfaces';
+import { BigNumber } from 'bignumber.js';
+
+chai.use(chaiAsPromised);
+const expect = chai.expect;
+
+let alice: IKeyringPair;
+let bob: IKeyringPair;
+let charlie: IKeyringPair;
+
+describe('integration test: ext. removeCollectionSponsor():', () => {
+
+  before(async () => {
+    await usingApi(async (api) => {
+      const keyring = new Keyring({ type: 'sr25519' });
+      alice = keyring.addFromUri(`//Alice`);
+      bob = keyring.addFromUri(`//Bob`);
+      charlie = keyring.addFromUri(`//Charlie`);
+    });
+  });
+
+  it('Remove NFT collection sponsor stops sponsorship', async () => {
+    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');
+    await setCollectionSponsorExpectSuccess(collectionId, bob.address);
+    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
+    await removeCollectionSponsorExpectSuccess(collectionId);
+
+    await usingApi(async (api) => {
+      // Find unused address
+      const zeroBalance = await findUnusedAddress(api);
+
+      // Mint token for unused address
+      const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', zeroBalance.address);
+
+      // Transfer this tokens from unused address to Alice - should fail
+      const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());
+      const zeroToAlice = api.tx.nft.transfer(alice.address, collectionId, itemId, 0);
+      const badTransaction = async function () { 
+        console.log = function () {};
+        console.error = function () {};
+        await submitTransactionAsync(zeroBalance, zeroToAlice);
+        delete console.log;
+        delete console.error;
+      };
+      await expect(badTransaction()).to.be.rejectedWith("Inability to pay some fees");
+      const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());
+
+      expect(BsponsorBalance.isEqualTo(AsponsorBalance)).to.be.true;
+    });
+  });
+
+  it('Remove a sponsor after it was already removed', async () => {
+    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');
+    await setCollectionSponsorExpectSuccess(collectionId, bob.address);
+    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
+    await removeCollectionSponsorExpectSuccess(collectionId);
+    await removeCollectionSponsorExpectSuccess(collectionId);
+  });
+
+  it('Remove sponsor in a collection that never had the sponsor set', async () => {
+    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');
+    await removeCollectionSponsorExpectSuccess(collectionId);
+  });
+
+  it('Remove sponsor for a collection that had the sponsor set, but not confirmed', async () => {
+    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');
+    await setCollectionSponsorExpectSuccess(collectionId, bob.address);
+    await removeCollectionSponsorExpectSuccess(collectionId);
+  });
+
+});
+
+describe('(!negative test!) integration test: ext. removeCollectionSponsor():', () => {
+  before(async () => {
+    await usingApi(async (api) => {
+      const keyring = new Keyring({ type: 'sr25519' });
+      alice = keyring.addFromUri(`//Alice`);
+      bob = keyring.addFromUri(`//Bob`);
+      charlie = keyring.addFromUri(`//Charlie`);
+    });
+  });
+
+  it('(!negative test!) Remove sponsor for a collection that never existed', async () => {
+    // Find the collection that never existed
+    const collectionId = 0;
+    await usingApi(async (api) => {
+      const collectionId = parseInt((await api.query.nft.createdCollectionCount()).toString()) + 1;
+    });
+
+    await removeCollectionSponsorExpectFailure(collectionId);
+  });
+
+  it('(!negative test!) Remove sponsor in a destroyed collection', async () => {
+    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');
+    await setCollectionSponsorExpectSuccess(collectionId, bob.address);
+    await destroyCollectionExpectSuccess(collectionId);
+    await removeCollectionSponsorExpectFailure(collectionId);
+  });
+
+  it('Set - remove - confirm: fails', async () => {
+    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');
+    await setCollectionSponsorExpectSuccess(collectionId, bob.address);
+    await removeCollectionSponsorExpectSuccess(collectionId);
+    await confirmSponsorshipExpectFailure(collectionId, '//Bob');
+  });
+
+  it('Set - confirm - remove - confirm: Sponsor cannot come back', async () => {
+    const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');
+    await setCollectionSponsorExpectSuccess(collectionId, bob.address);
+    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
+    await removeCollectionSponsorExpectSuccess(collectionId);
+    await confirmSponsorshipExpectFailure(collectionId, '//Bob');
+  });
+
+});
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -213,6 +213,39 @@
   });
 }
 
+export async function removeCollectionSponsorExpectSuccess(collectionId: number) {
+  await usingApi(async (api) => {
+
+    // Run the transaction
+    const alicePrivateKey = privateKey('//Alice');
+    const tx = api.tx.nft.removeCollectionSponsor(collectionId);
+    const events = await submitTransactionAsync(alicePrivateKey, tx);
+    const result = getGenericResult(events);
+
+    // Get the collection 
+    const collection: any = (await api.query.nft.collection(collectionId)).toJSON();
+
+    // What to expect
+    expect(result.success).to.be.true;
+    expect(collection.Sponsor).to.be.equal(nullPublicKey);
+    expect(collection.SponsorConfirmed).to.be.false;
+  });
+}
+
+export async function removeCollectionSponsorExpectFailure(collectionId: number) {
+  await usingApi(async (api) => {
+
+    // Run the transaction
+    const alicePrivateKey = privateKey('//Alice');
+    const tx = api.tx.nft.removeCollectionSponsor(collectionId);
+    const events = await submitTransactionAsync(alicePrivateKey, tx);
+    const result = getGenericResult(events);
+
+    // What to expect
+    expect(result.success).to.be.false;
+  });
+}
+
 export async function setCollectionSponsorExpectFailure(collectionId: number, sponsor: string, senderSeed: string = '//Alice') {
   await usingApi(async (api) => {