From ffad1cd6c2c1826aec962f3b614d29404793da88 Mon Sep 17 00:00:00 2001 From: Antz0x0z <47379684+Antz0x0z@users.noreply.github.com> Date: Tue, 02 Mar 2021 11:52:28 +0000 Subject: [PATCH] Create setSponsorNewOwner.test.ts Add test confirm sponsor & new owner. --- --- /dev/null +++ b/tests/src/collision-tests/setSponsorNewOwner.test.ts @@ -0,0 +1,54 @@ +import { IKeyringPair } from '@polkadot/types/types'; +import BN from 'bn.js'; +import chai from 'chai'; +import chaiAsPromised from 'chai-as-promised'; +import privateKey from '../substrate/privateKey'; +import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from '../substrate/substrate-api'; +import { + createCollectionExpectSuccess, createItemExpectSuccess, setCollectionSponsorExpectSuccess, +} from '../util/helpers'; + +chai.use(chaiAsPromised); +const expect = chai.expect; +interface ITokenDataType { + Owner: number[]; + ConstData: number[]; + VariableData: number[]; +} +let Alice: IKeyringPair; +let Bob: IKeyringPair; +let Ferdie: IKeyringPair; + +before(async () => { + await usingApi(async () => { + Alice = privateKey('//Alice'); + Bob = privateKey('//Bob'); + Ferdie = privateKey('//Ferdie'); + }); +}); + +describe('Sponsored with new owner ', () => { + // tslint:disable-next-line: max-line-length + it('Confirmation of sponsorship of a collection in a block with a change in the owner of the collection: ', async () => { + await usingApi(async (api) => { + const collectionId = await createCollectionExpectSuccess(); + await setCollectionSponsorExpectSuccess(collectionId, Bob.address); + const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout)); + await timeoutPromise(10000); + // + const confirmSponsorship = api.tx.nft.confirmSponsorship(collectionId); + const changeCollectionOwner = api.tx.nft.changeCollectionOwner(collectionId, Ferdie.address); + await Promise.all + ([ + confirmSponsorship.signAndSend(Bob), + changeCollectionOwner.signAndSend(Alice), + ]); + await timeoutPromise(10000); + const collection: any = (await api.query.nft.collection(collectionId)).toJSON(); + expect(collection.Sponsor).to.be.eq(Bob.address); + // tslint:disable-next-line: no-unused-expression + expect(collection.SponsorConfirmed).to.be.true; + expect(collection.Owner).to.be.eq(Ferdie.address); + }); + }); +}); -- gitstuff