git.delta.rocks / unique-network / refs/commits / b2341b500512

difftreelog

source

tests/src/scheduler.test.ts2.9 KiBsourcehistory
1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import { IKeyringPair } from '@polkadot/types/types';7import chai from 'chai';8import chaiAsPromised from 'chai-as-promised';9import privateKey from './substrate/privateKey';10import usingApi from './substrate/substrate-api';11import {12  createItemExpectSuccess,13  createCollectionExpectSuccess,14  destroyCollectionExpectSuccess,15  findNotExistingCollection,16  queryCollectionExpectSuccess,17  setOffchainSchemaExpectFailure,18  setOffchainSchemaExpectSuccess,19  transferExpectSuccess,20  scheduleTransferExpectSuccess,21  setCollectionSponsorExpectSuccess,22  confirmSponsorshipExpectSuccess23} from './util/helpers';242526chai.use(chaiAsPromised);27const expect = chai.expect;2829const DATA = [1, 2, 3, 4];3031describe('Integration Test scheduler base transaction', () => {32  let alice: IKeyringPair;3334  before(async () => {35    await usingApi(async () => {36      alice = privateKey('//Alice');37    });38  });3940  it('User can transfer owned token with delay (scheduler)', async () => {41    await usingApi(async (api) => {42      const Alice = privateKey('//Alice');43      const Bob = privateKey('//Bob');44      // nft45      const nftCollectionId = await createCollectionExpectSuccess();46      const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');47      await setCollectionSponsorExpectSuccess(nftCollectionId, Alice.address);48      await confirmSponsorshipExpectSuccess(nftCollectionId);4950      await scheduleTransferExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob, 1, 'NFT');51    });52  });5354  55});5657// describe('Negative Integration Test setOffchainSchema', () => {58//   let alice: IKeyringPair;59//   let bob: IKeyringPair;6061//   let validCollectionId: number;6263//   before(async () => {64//     await usingApi(async () => {65//       alice = privateKey('//Alice');66//       bob = privateKey('//Bob');6768//       validCollectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });69//     });70//   });7172//   it('fails on not existing collection id', async () => {73//     const nonExistingCollectionId = await usingApi(findNotExistingCollection);7475//     await setOffchainSchemaExpectFailure(alice, nonExistingCollectionId, DATA);76//   });7778//   it('fails on destroyed collection id', async () => {79//     const destroyedCollectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });80//     await destroyCollectionExpectSuccess(destroyedCollectionId);8182//     await setOffchainSchemaExpectFailure(alice, destroyedCollectionId, DATA);83//   });8485//   it('fails on too long data', async () => {86//     const tooLongData = new Array(4097).fill(0xff);8788//     await setOffchainSchemaExpectFailure(alice, validCollectionId, tooLongData);89//   });9091//   it('fails on execution by non-owner', async () => {92//     await setOffchainSchemaExpectFailure(bob, validCollectionId, DATA);93//   });94// });