difftreelog
Confirm sponsorship tests in progress
in: master
4 files changed
tests/src/confirmSponsorship.test.tsdiffbeforeafterbothno changes
tests/src/createMultipleItems.test.tsdiffbeforeafterboth111112const idCollection = 12;12const idCollection = 12;131314describe('integration test: ext. createMultipleItems():', () => {14describe.skip('integration test: ext. createMultipleItems():', () => {15 it('Create two NFT tokens in active NFT collection', async () => {15 it('Create two NFT tokens in active NFT collection', async () => {16 await usingApi(async (api) => {16 await usingApi(async (api) => {17 const AitemListIndex = await api.query.nft.itemListIndex(idCollection);17 const AitemListIndex = await api.query.nft.itemListIndex(idCollection);tests/src/setCollectionSponsor.test.tsdiffbeforeafterboth61 });61 });62 });62 });636364 it('(!negative test!) Add sponsor with a non-owner', async () => {65 const collectionId = await createCollectionExpectSuccess('A', 'B', 'C', 'NFT');66 await setCollectionSponsorExpectFailure(collectionId, bob.address, '//Bob');67 });64 it('(!negative test!) Add sponsor to a collection that never existed', async () => {68 it('(!negative test!) Add sponsor to a collection that never existed', async () => {65 // Find the collection that never existed69 // Find the collection that never existed66 const collectionId = 0;70 const collectionId = 0;tests/src/util/helpers.tsdiffbeforeafterboth134 return success;134 return success;135}135}136137export async function setCollectionSponsorExpectSuccess(collectionId: number, sponsor: string) {138 await usingApi(async (api) => {139140 // Run the transaction141 const alicePrivateKey = privateKey('//Alice');142 const tx = api.tx.nft.setCollectionSponsor(collectionId, sponsor);143 const events = await submitTransactionAsync(alicePrivateKey, tx);144 const result = getGenericResult(events);145146 // Get the collection 147 const collection: any = (await api.query.nft.collection(collectionId)).toJSON();148149 // What to expect150 expect(result.success).to.be.true;151 expect(collection.Sponsor.toString()).to.be.equal(sponsor.toString());152 expect(collection.SponsorConfirmed).to.be.false;153 });154}155136156export async function destroyCollectionExpectFailure(collectionId: number, senderSeed: string = '//Alice') {137export async function destroyCollectionExpectFailure(collectionId: number, senderSeed: string = '//Alice') {157 await usingApi(async (api) => {138 await usingApi(async (api) => {184 });165 });185}166}167168export async function setCollectionSponsorExpectSuccess(collectionId: number, sponsor: string) {169 await usingApi(async (api) => {170171 // Run the transaction172 const alicePrivateKey = privateKey('//Alice');173 const tx = api.tx.nft.setCollectionSponsor(collectionId, sponsor);174 const events = await submitTransactionAsync(alicePrivateKey, tx);175 const result = getGenericResult(events);176177 // Get the collection 178 const collection: any = (await api.query.nft.collection(collectionId)).toJSON();179180 // What to expect181 expect(result.success).to.be.true;182 expect(collection.Sponsor.toString()).to.be.equal(sponsor.toString());183 expect(collection.SponsorConfirmed).to.be.false;184 });185}186186187export async function setCollectionSponsorExpectFailure(collectionId: number, sponsor: string) {187export async function setCollectionSponsorExpectFailure(collectionId: number, sponsor: string, senderSeed: string = '//Alice') {188 await usingApi(async (api) => {188 await usingApi(async (api) => {189189190 // Run the transaction190 // Run the transaction191 const alicePrivateKey = privateKey('//Alice');191 const alicePrivateKey = privateKey(senderSeed);192 const tx = api.tx.nft.setCollectionSponsor(collectionId, sponsor);192 const tx = api.tx.nft.setCollectionSponsor(collectionId, sponsor);193 const events = await submitTransactionAsync(alicePrivateKey, tx);193 const events = await submitTransactionAsync(alicePrivateKey, tx);194 const result = getGenericResult(events);194 const result = getGenericResult(events);198 });198 });199}199}200201export async function confirmSponsorshipExpectSuccess(collectionId: number, senderSeed: string = '//Alice') {202 await usingApi(async (api) => {203204 // Run the transaction205 const sender = privateKey(senderSeed);206 const tx = api.tx.nft.confirmSponsorship(collectionId);207 const events = await submitTransactionAsync(sender, tx);208 const result = getGenericResult(events);209210 // Get the collection 211 const collection: any = (await api.query.nft.collection(collectionId)).toJSON();212213 // What to expect214 expect(result.success).to.be.true;215 expect(collection.Sponsor).to.be.equal(sender.address);216 expect(collection.SponsorConfirmed).to.be.true;217 });218}219220export async function confirmSponsorshipExpectFailure(collectionId: number, senderSeed: string = '//Alice') {221 await usingApi(async (api) => {222223 // Run the transaction224 const sender = privateKey(senderSeed);225 const tx = api.tx.nft.confirmSponsorship(collectionId);226 const events = await submitTransactionAsync(sender, tx);227 const result = getGenericResult(events);228229 // What to expect230 expect(result.success).to.be.false;231 });232}200233234