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

difftreelog

source

tests/src/apiConsts.test.ts3.7 KiBsourcehistory
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {ApiPromise} from '@polkadot/api';18import {usingPlaygrounds, itSub, expect} from './util';192021const MAX_COLLECTION_DESCRIPTION_LENGTH = 256n;22const MAX_COLLECTION_NAME_LENGTH = 64n;23const COLLECTION_ADMINS_LIMIT = 5n;24const MAX_COLLECTION_PROPERTIES_SIZE = 40960n;25const MAX_TOKEN_PREFIX_LENGTH = 16n;26const MAX_PROPERTY_KEY_LENGTH = 256n;27const MAX_PROPERTY_VALUE_LENGTH = 32768n;28const MAX_PROPERTIES_PER_ITEM = 64n;29const MAX_TOKEN_PROPERTIES_SIZE = 32768n;30const NESTING_BUDGET = 5n;3132const DEFAULT_COLLETCTION_LIMIT = {33  accountTokenOwnershipLimit: '1,000,000',34  sponsoredDataSize: '2,048',35  sponsoredDataRateLimit: 'SponsoringDisabled',36  tokenLimit: '4,294,967,295',37  sponsorTransferTimeout: '5',38  sponsorApproveTimeout: '5',39  ownerCanTransfer: false,40  ownerCanDestroy: true,41  transfersEnabled: true,42};4344describe('integration test: API UNIQUE consts', () => {45  let api: ApiPromise;46  47  before(async () => {48    await usingPlaygrounds(async (helper) => {49      api = await helper.getApi();50    });51  });52  53  itSub('DEFAULT_NFT_COLLECTION_LIMITS', () => {54    expect(api.consts.unique.nftDefaultCollectionLimits.toHuman()).to.deep.equal(DEFAULT_COLLETCTION_LIMIT);55  });56  57  itSub('DEFAULT_RFT_COLLECTION_LIMITS', () => {58    expect(api.consts.unique.rftDefaultCollectionLimits.toHuman()).to.deep.equal(DEFAULT_COLLETCTION_LIMIT);59  });60  61  itSub('DEFAULT_FT_COLLECTION_LIMITS', () => {62    expect(api.consts.unique.ftDefaultCollectionLimits.toHuman()).to.deep.equal(DEFAULT_COLLETCTION_LIMIT);63  });64  65  itSub('MAX_COLLECTION_NAME_LENGTH', () => {66    checkConst(api.consts.unique.maxCollectionNameLength, MAX_COLLECTION_NAME_LENGTH);67  });68  69  itSub('MAX_COLLECTION_DESCRIPTION_LENGTH', () => {70    checkConst(api.consts.unique.maxCollectionDescriptionLength, MAX_COLLECTION_DESCRIPTION_LENGTH);71  });72  73  itSub('MAX_COLLECTION_PROPERTIES_SIZE', () => {74    checkConst(api.consts.unique.maxCollectionPropertiesSize, MAX_COLLECTION_PROPERTIES_SIZE);75  });7677  itSub('MAX_TOKEN_PREFIX_LENGTH', () => {78    checkConst(api.consts.unique.maxTokenPrefixLength, MAX_TOKEN_PREFIX_LENGTH);79  });8081  itSub('MAX_PROPERTY_KEY_LENGTH', () => {82    checkConst(api.consts.unique.maxPropertyKeyLength, MAX_PROPERTY_KEY_LENGTH);83  });84  85  itSub('MAX_PROPERTY_VALUE_LENGTH', () => {86    checkConst(api.consts.unique.maxPropertyValueLength, MAX_PROPERTY_VALUE_LENGTH);87  });88  89  itSub('MAX_PROPERTIES_PER_ITEM', () => {90    checkConst(api.consts.unique.maxPropertiesPerItem, MAX_PROPERTIES_PER_ITEM);91  });92  93  itSub('NESTING_BUDGET', () => {94    checkConst(api.consts.unique.nestingBudget, NESTING_BUDGET);95  });96  97  itSub('MAX_TOKEN_PROPERTIES_SIZE', () => {98    checkConst(api.consts.unique.maxTokenPropertiesSize, MAX_TOKEN_PROPERTIES_SIZE);99  });100  101  itSub('COLLECTION_ADMINS_LIMIT', () => {102    checkConst(api.consts.unique.collectionAdminsLimit, COLLECTION_ADMINS_LIMIT);103  });104});105106function checkConst<T>(constValue: any, expectedValue: T) {107  expect(constValue.toBigInt()).equal(expectedValue);108}