1234567891011121314151617import {IKeyringPair} from '@polkadot/types/types';18import {itSub, usingPlaygrounds, expect} from './util/playgrounds';1920describe('integration test: ext. removeCollectionSponsor():', () => {21 let donor: IKeyringPair;22 let alice: IKeyringPair;23 let bob: IKeyringPair;2425 before(async () => {26 await usingPlaygrounds(async (helper, privateKey) => {27 donor = privateKey('//Alice');28 [alice, bob] = await helper.arrange.createAccounts([10n, 10n], donor);29 });30 });3132 itSub('Removing NFT collection sponsor stops sponsorship', async ({helper}) => {33 const collection = await helper.nft.mintCollection(alice, {name: 'RemoveCollectionSponsor-1', tokenPrefix: 'RCS'});34 await collection.setSponsor(alice, bob.address);35 await collection.confirmSponsorship(bob);36 await collection.removeSponsor(alice);3738 39 const [zeroBalance] = await helper.arrange.createAccounts([0n], donor);4041 42 const token = await collection.mintToken(alice, {Substrate: zeroBalance.address});4344 45 const sponsorBalanceBefore = await helper.balance.getSubstrate(bob.address);46 await expect(token.transfer(zeroBalance, {Substrate: alice.address}))47 .to.be.rejectedWith('Inability to pay some fees');48 const sponsorBalanceAfter = await helper.balance.getSubstrate(bob.address);4950 expect(sponsorBalanceAfter).to.be.equal(sponsorBalanceBefore);51 });5253 itSub('Remove a sponsor after it was already removed', async ({helper}) => {54 const collection = await helper.nft.mintCollection(alice, {name: 'RemoveCollectionSponsor-2', tokenPrefix: 'RCS'});55 await collection.setSponsor(alice, bob.address);56 await collection.confirmSponsorship(bob);57 await expect(collection.removeSponsor(alice)).to.not.be.rejected;58 await expect(collection.removeSponsor(alice)).to.not.be.rejected;59 });6061 itSub('Remove sponsor in a collection that never had the sponsor set', async ({helper}) => {62 const collection = await helper.nft.mintCollection(alice, {name: 'RemoveCollectionSponsor-3', tokenPrefix: 'RCS'});63 await expect(collection.removeSponsor(alice)).to.not.be.rejected;64 });6566 itSub('Remove sponsor for a collection that had the sponsor set, but not confirmed', async ({helper}) => {67 const collection = await helper.nft.mintCollection(alice, {name: 'RemoveCollectionSponsor-4', tokenPrefix: 'RCS'});68 await collection.setSponsor(alice, bob.address);69 await expect(collection.removeSponsor(alice)).to.not.be.rejected;70 });7172});7374describe('(!negative test!) integration test: ext. removeCollectionSponsor():', () => {75 let alice: IKeyringPair;76 let bob: IKeyringPair;77 let charlie: IKeyringPair;7879 before(async () => {80 await usingPlaygrounds(async (helper, privateKey) => {81 const donor = privateKey('//Alice');82 [alice, bob, charlie] = await helper.arrange.createAccounts([20n, 10n, 10n], donor);83 });84 });8586 itSub('(!negative test!) Remove sponsor for a collection that never existed', async ({helper}) => {87 const collectionId = (1 << 32) - 1;88 await expect(helper.collection.removeSponsor(alice, collectionId)).to.be.rejectedWith(/common\.CollectionNotFound/);89 });9091 itSub('(!negative test!) Remove sponsor for a collection with collection admin permissions', async ({helper}) => {92 const collection = await helper.nft.mintCollection(alice, {name: 'RemoveCollectionSponsor-Neg-1', tokenPrefix: 'RCS'});93 await collection.setSponsor(alice, bob.address);94 await collection.addAdmin(alice, {Substrate: charlie.address});95 await expect(collection.removeSponsor(charlie)).to.be.rejectedWith(/common\.NoPermission/);96 });9798 itSub('(!negative test!) Remove sponsor for a collection by regular user', async ({helper}) => {99 const collection = await helper.nft.mintCollection(alice, {name: 'RemoveCollectionSponsor-Neg-2', tokenPrefix: 'RCS'});100 await collection.setSponsor(alice, bob.address);101 await expect(collection.removeSponsor(charlie)).to.be.rejectedWith(/common\.NoPermission/);102 });103104 itSub('(!negative test!) Remove sponsor in a destroyed collection', async ({helper}) => {105 const collection = await helper.nft.mintCollection(alice, {name: 'RemoveCollectionSponsor-Neg-3', tokenPrefix: 'RCS'});106 await collection.setSponsor(alice, bob.address);107 await collection.burn(alice);108 await expect(collection.removeSponsor(alice)).to.be.rejectedWith(/common\.CollectionNotFound/);109 });110111 itSub('Set - remove - confirm: fails', async ({helper}) => {112 const collection = await helper.nft.mintCollection(alice, {name: 'RemoveCollectionSponsor-Neg-4', tokenPrefix: 'RCS'});113 await collection.setSponsor(alice, bob.address);114 await collection.removeSponsor(alice);115 await expect(collection.confirmSponsorship(bob)).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);116 });117118 itSub('Set - confirm - remove - confirm: Sponsor cannot come back', async ({helper}) => {119 const collection = await helper.nft.mintCollection(alice, {name: 'RemoveCollectionSponsor-Neg-5', tokenPrefix: 'RCS'});120 await collection.setSponsor(alice, bob.address);121 await collection.confirmSponsorship(bob);122 await collection.removeSponsor(alice);123 await expect(collection.confirmSponsorship(bob)).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);124 });125});