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

difftreelog

set limits test scenarios

kpozdnikin2020-12-31parent: #49640f3.patch.diff
in: master

5 files changed

modifiedtests/package.jsondiffbeforeafterboth
19 "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 },
addedtests/src/setCollectionLimits.test.tsdiffbeforeafterboth

no changes

modifiedtests/src/setSchemaVersion.test.tsdiffbeforeafterboth
1// https://unique-network.readthedocs.io/en/latest/jsapi.html#setchainlimits1// https://unique-network.readthedocs.io/en/latest/jsapi.html#setschemaversion
2import { 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';
1016
11chai.use(chaiAsPromised);17chai.use(chaiAsPromised);
203. Use this id for setSchemaVersion.263. Use this id for setSchemaVersion.
21*/27*/
22
23const getDetailedCollectionInfo = async (api: ApiPromise, collectionId: number)
24 : Promise<ICollectionInterface | null> => {
25 return await api.query.nft.collection(collectionId) as unknown as ICollectionInterface;
26};
27
28const getCreatedCollectionCount = async (api: ApiPromise): Promise<number> => {
29 // set global object - collectionsCount
30 return (await api.query.nft.createdCollectionCount() as unknown as BN).toNumber();
31};
3228
33describe('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-expression
62 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-expression
72 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-expression
77 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-expression
modifiedtests/src/types.tsdiffbeforeafterboth
7 // constOnChainSchema7 // constOnChainSchema
8 Description: [BN, BN]; // utf168 Description: [BN, BN]; // utf16
9 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]; // utf16
15 OffchainSchema: [Uint8Array];21 OffchainSchema: [Uint8Array];
16 SchemaVersion: string;
17 Owner: [Uint8Array];22 Owner: [Uint8Array];
23 SchemaVersion: string;
18 // prefix24 // prefix
19 // sponsor25 // sponsor
20 // tokenPrefix26 // tokenPrefix
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
10import { 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";
1820
19chai.use(chaiAsPromised);21chai.use(chaiAsPromised);
20const expect = chai.expect;22const expect = chai.expect;
399 });401 });
400}402}
403
404export const getDetailedCollectionInfo = async (api: ApiPromise, collectionId: number)
405 : Promise<ICollectionInterface | null> => {
406 return await api.query.nft.collection(collectionId) as unknown as ICollectionInterface;
407};
408
409export const getCreatedCollectionCount = async (api: ApiPromise): Promise<number> => {
410 // set global object - collectionsCount
411 return (await api.query.nft.createdCollectionCount() as unknown as BN).toNumber();
412};
401413
402