git.delta.rocks / unique-network / refs/commits / 9d35eaceaefb

difftreelog

source

tests/src/collision-tests/setSponsorNewOwner.test.ts2.0 KiBsourcehistory
1import { IKeyringPair } from '@polkadot/types/types';2import BN from 'bn.js';3import chai from 'chai';4import chaiAsPromised from 'chai-as-promised';5import privateKey from '../substrate/privateKey';6import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from '../substrate/substrate-api';7import {8  createCollectionExpectSuccess, createItemExpectSuccess, setCollectionSponsorExpectSuccess,9} from '../util/helpers';1011chai.use(chaiAsPromised);12const expect = chai.expect;13interface ITokenDataType {14  Owner: number[];15  ConstData: number[];16  VariableData: number[];17}18let Alice: IKeyringPair;19let Bob: IKeyringPair;20let Ferdie: IKeyringPair;2122before(async () => {23  await usingApi(async () => {24    Alice = privateKey('//Alice');25    Bob = privateKey('//Bob');26    Ferdie = privateKey('//Ferdie');27  });28});2930describe('Sponsored with new owner ', () => {31  // tslint:disable-next-line: max-line-length32  it('Confirmation of sponsorship of a collection in a block with a change in the owner of the collection: ', async () => {33    await usingApi(async (api) => {34      const collectionId = await createCollectionExpectSuccess();35      await setCollectionSponsorExpectSuccess(collectionId, Bob.address);36      const timeoutPromise = (timeout: number) => new Promise((resolve) => setTimeout(resolve, timeout));37      await timeoutPromise(10000);38      //39      const confirmSponsorship = api.tx.nft.confirmSponsorship(collectionId);40      const changeCollectionOwner = api.tx.nft.changeCollectionOwner(collectionId, Ferdie.address);41      await Promise.all42      ([43        confirmSponsorship.signAndSend(Bob),44        changeCollectionOwner.signAndSend(Alice),45      ]);46      await timeoutPromise(10000);47      const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();48      expect(collection.Sponsorship.Confirmed).to.be.eq(Bob.address);49      expect(collection.Owner).to.be.eq(Ferdie.address);50      await timeoutPromise(20000);51    });52  });53});