git.delta.rocks / unique-network / refs/commits / 6521b4029dca

difftreelog

source

tests/src/collision-tests/setSponsorNewOwner.test.ts1.8 KiBsourcehistory
1import { IKeyringPair } from '@polkadot/types/types';2import chai from 'chai';3import chaiAsPromised from 'chai-as-promised';4import privateKey from '../substrate/privateKey';5import usingApi from '../substrate/substrate-api';6import {7  createCollectionExpectSuccess, 8  setCollectionSponsorExpectSuccess,9  normalizeAccountId,10} from '../util/helpers';1112chai.use(chaiAsPromised);13const expect = chai.expect;14let Alice: IKeyringPair;15let Bob: IKeyringPair;16let Ferdie: IKeyringPair;1718before(async () => {19  await usingApi(async () => {20    Alice = privateKey('//Alice');21    Bob = privateKey('//Bob');22    Ferdie = privateKey('//Ferdie');23  });24});2526describe('Sponsored with new owner ', () => {27  // tslint:disable-next-line: max-line-length28  it('Confirmation of sponsorship of a collection in a block with a change in the owner of the collection: ', async () => {29    await usingApi(async (api) => {30      const collectionId = await createCollectionExpectSuccess();31      await setCollectionSponsorExpectSuccess(collectionId, Bob.address);32      const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));33      await timeoutPromise(20000);34      const confirmSponsorship = api.tx.nft.confirmSponsorship(collectionId);35      const changeCollectionOwner = api.tx.nft.changeCollectionOwner(collectionId, Ferdie.address);36      await Promise.all([37        confirmSponsorship.signAndSend(Bob),38        changeCollectionOwner.signAndSend(Alice),39      ]);40      await timeoutPromise(20000);41      const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();42      expect(collection.Sponsorship.confirmed).to.be.eq(Bob.address);43      expect(collection.Owner).to.be.eq(Ferdie.address);44      await timeoutPromise(20000);45    });46  });47});