difftreelog
set limits test scenarios
in: master
5 files changed
tests/package.jsondiffbeforeafterboth19 "test": "mocha --timeout 9999999 -r ts-node/register ./**/*.test.ts",19 "test": "mocha --timeout 9999999 -r ts-node/register ./**/*.test.ts",20 "load": "mocha --timeout 9999999 -r ts-node/register ./**/*.load.ts",20 "load": "mocha --timeout 9999999 -r ts-node/register ./**/*.load.ts",21 "testSetSchemaVersion": "mocha --timeout 9999999 -r ts-node/register ./**/setSchemaVersion.test.ts",21 "testSetSchemaVersion": "mocha --timeout 9999999 -r ts-node/register ./**/setSchemaVersion.test.ts",22 "testSetCollectionLimits": "mocha --timeout 9999999 -r ts-node/register ./**/setCollectionLimits.test.ts",22 "testConnection": "mocha --timeout 9999999 -r ts-node/register ./**/connection.test.ts",23 "testConnection": "mocha --timeout 9999999 -r ts-node/register ./**/connection.test.ts",23 "testCollection": "mocha --timeout 9999999 -r ts-node/register ./**/createCollection.test.ts"24 "testCollection": "mocha --timeout 9999999 -r ts-node/register ./**/createCollection.test.ts"24 },25 },tests/src/setCollectionLimits.test.tsdiffbeforeafterbothno changes
tests/src/setSchemaVersion.test.tsdiffbeforeafterboth1// https://unique-network.readthedocs.io/en/latest/jsapi.html#setchainlimits1// https://unique-network.readthedocs.io/en/latest/jsapi.html#setschemaversion2import { ApiPromise, Keyring } from '@polkadot/api';2import { ApiPromise, Keyring } from '@polkadot/api';3import { IKeyringPair } from '@polkadot/types/types';3import { IKeyringPair } from '@polkadot/types/types';4import BN from 'bn.js';4import BN from 'bn.js';9import { createCollectionExpectSuccess, destroyCollectionExpectSuccess, getCreateItemResult } from './util/helpers';9import {10 createCollectionExpectSuccess,11 destroyCollectionExpectSuccess,12 getCreatedCollectionCount,13 getCreateItemResult,14 getDetailedCollectionInfo,15} from './util/helpers';101611chai.use(chaiAsPromised);17chai.use(chaiAsPromised);203. Use this id for setSchemaVersion.263. Use this id for setSchemaVersion.21*/27*/2223const getDetailedCollectionInfo = async (api: ApiPromise, collectionId: number)24 : Promise<ICollectionInterface | null> => {25 return await api.query.nft.collection(collectionId) as unknown as ICollectionInterface;26};2728const getCreatedCollectionCount = async (api: ApiPromise): Promise<number> => {29 // set global object - collectionsCount30 return (await api.query.nft.createdCollectionCount() as unknown as BN).toNumber();31};322833describe('hooks', () => {29describe('hooks', () => {34 before(async () => {30 before(async () => {57 tx = api.tx.nft.setSchemaVersion(collectionIdForTesting, 'Unique');53 tx = api.tx.nft.setSchemaVersion(collectionIdForTesting, 'Unique');58 const events = await submitTransactionAsync(alice, tx);54 const events = await submitTransactionAsync(alice, tx);59 const result = getCreateItemResult(events);55 const result = getCreateItemResult(events);60 const collectionInfo = await getDetailedCollectionInfo(api, collectionIdForTesting);56 const collectionInfo = await getDetailedCollectionInfo(api, collectionIdForTesting) as ICollectionInterface;61 // tslint:disable-next-line:no-unused-expression57 // tslint:disable-next-line:no-unused-expression62 expect(result.success).to.be.true;58 expect(result.success).to.be.true;63 // tslint:disable-next-line:no-unused-expression59 // tslint:disable-next-line:no-unused-expression72 tx = api.tx.nft.setSchemaVersion(collectionIdForTesting, 'ImageURL');68 tx = api.tx.nft.setSchemaVersion(collectionIdForTesting, 'ImageURL');73 const events = await submitTransactionAsync(alice, tx);69 const events = await submitTransactionAsync(alice, tx);74 const result = getCreateItemResult(events);70 const result = getCreateItemResult(events);75 const collectionInfo = await getDetailedCollectionInfo(api, collectionIdForTesting);71 const collectionInfo = await getDetailedCollectionInfo(api, collectionIdForTesting) as ICollectionInterface;76 // tslint:disable-next-line:no-unused-expression72 // tslint:disable-next-line:no-unused-expression77 expect(result.success).to.be.true;73 expect(result.success).to.be.true;78 // tslint:disable-next-line:no-unused-expression74 // tslint:disable-next-line:no-unused-expressiontests/src/types.tsdiffbeforeafterboth7 // constOnChainSchema7 // constOnChainSchema8 Description: [BN, BN]; // utf168 Description: [BN, BN]; // utf169 isReFungible: boolean;9 isReFungible: boolean;10 Limits: {11 AccountTokenOwnershipLimit: BN;12 SponsoredMintSize: BN;13 TokenLimit: BN;14 SponsorTimeout: BN;15 };10 MintMode: boolean;16 MintMode: boolean;11 Mode: {17 Mode: {12 Nft: null;18 Nft: null;13 };19 };14 Name: [BN, BN]; // utf1620 Name: [BN, BN]; // utf1615 OffchainSchema: [Uint8Array];21 OffchainSchema: [Uint8Array];16 SchemaVersion: string;17 Owner: [Uint8Array];22 Owner: [Uint8Array];23 SchemaVersion: string;18 // prefix24 // prefix19 // sponsor25 // sponsor20 // tokenPrefix26 // tokenPrefixtests/src/util/helpers.tsdiffbeforeafterboth10import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from "../substrate/substrate-api";10import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from "../substrate/substrate-api";11import privateKey from '../substrate/privateKey';11import privateKey from '../substrate/privateKey';12import { alicesPublicKey, nullPublicKey } from "../accounts";12import { alicesPublicKey, nullPublicKey } from "../accounts";13import { strToUTF16, utf16ToStr, hexToStr } from '../util/util';13import { strToUTF16, utf16ToStr, hexToStr } from './util';14import { IKeyringPair } from "@polkadot/types/types";14import { IKeyringPair } from '@polkadot/types/types';15import { BigNumber } from 'bignumber.js';15import { BigNumber } from 'bignumber.js';16import { Struct, Enum } from '@polkadot/types/codec';16import { Struct, Enum } from '@polkadot/types/codec';17import { u128 } from '@polkadot/types/primitive';17import { u128 } from '@polkadot/types/primitive';18import { ICollectionInterface } from '../types';19import BN from "bn.js";182019chai.use(chaiAsPromised);21chai.use(chaiAsPromised);20const expect = chai.expect;22const expect = chai.expect;399 });401 });400}402}403404export const getDetailedCollectionInfo = async (api: ApiPromise, collectionId: number)405 : Promise<ICollectionInterface | null> => {406 return await api.query.nft.collection(collectionId) as unknown as ICollectionInterface;407};408409export const getCreatedCollectionCount = async (api: ApiPromise): Promise<number> => {410 // set global object - collectionsCount411 return (await api.query.nft.createdCollectionCount() as unknown as BN).toNumber();412};401413402