git.delta.rocks / unique-network / refs/commits / 31b1faacd1c9

difftreelog

source

tests/src/apiConsts.test.ts4.2 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 {ApiBase} from '@polkadot/api/base';19import {usingPlaygrounds, itSub, expect} from './util';202122const MAX_COLLECTION_DESCRIPTION_LENGTH = 256n;23const MAX_COLLECTION_NAME_LENGTH = 64n;24const COLLECTION_ADMINS_LIMIT = 5n;25const MAX_COLLECTION_PROPERTIES_SIZE = 40960n;26const MAX_TOKEN_PREFIX_LENGTH = 16n;27const MAX_PROPERTY_KEY_LENGTH = 256n;28const MAX_PROPERTY_VALUE_LENGTH = 32768n;29const MAX_PROPERTIES_PER_ITEM = 64n;30const MAX_TOKEN_PROPERTIES_SIZE = 32768n;31const NESTING_BUDGET = 5n;3233const DEFAULT_COLLETCTION_LIMIT = {34  accountTokenOwnershipLimit: '1,000,000',35  sponsoredDataSize: '2,048',36  sponsoredDataRateLimit: 'SponsoringDisabled',37  tokenLimit: '4,294,967,295',38  sponsorTransferTimeout: '5',39  sponsorApproveTimeout: '5',40  ownerCanTransfer: false,41  ownerCanDestroy: true,42  transfersEnabled: true,43};4445const EVM_COLLECTION_HELPERS_ADDRESS = '0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f';46const HELPERS_CONTRACT_ADDRESS = '0x842899ECF380553E8a4de75bF534cdf6fBF64049';4748describe('integration test: API UNIQUE consts', () => {49  let api: ApiPromise;50  51  before(async () => {52    await usingPlaygrounds(async (helper) => {53      api = await helper.getApi();54    });55  });56  57  itSub('DEFAULT_NFT_COLLECTION_LIMITS', () => {58    expect(api.consts.unique.nftDefaultCollectionLimits.toHuman()).to.deep.equal(DEFAULT_COLLETCTION_LIMIT);59  });60  61  itSub('DEFAULT_RFT_COLLECTION_LIMITS', () => {62    expect(api.consts.unique.rftDefaultCollectionLimits.toHuman()).to.deep.equal(DEFAULT_COLLETCTION_LIMIT);63  });64  65  itSub('DEFAULT_FT_COLLECTION_LIMITS', () => {66    expect(api.consts.unique.ftDefaultCollectionLimits.toHuman()).to.deep.equal(DEFAULT_COLLETCTION_LIMIT);67  });68  69  itSub('MAX_COLLECTION_NAME_LENGTH', () => {70    checkConst(api.consts.unique.maxCollectionNameLength, MAX_COLLECTION_NAME_LENGTH);71  });72  73  itSub('MAX_COLLECTION_DESCRIPTION_LENGTH', () => {74    checkConst(api.consts.unique.maxCollectionDescriptionLength, MAX_COLLECTION_DESCRIPTION_LENGTH);75  });76  77  itSub('MAX_COLLECTION_PROPERTIES_SIZE', () => {78    checkConst(api.consts.unique.maxCollectionPropertiesSize, MAX_COLLECTION_PROPERTIES_SIZE);79  });8081  itSub('MAX_TOKEN_PREFIX_LENGTH', () => {82    checkConst(api.consts.unique.maxTokenPrefixLength, MAX_TOKEN_PREFIX_LENGTH);83  });8485  itSub('MAX_PROPERTY_KEY_LENGTH', () => {86    checkConst(api.consts.unique.maxPropertyKeyLength, MAX_PROPERTY_KEY_LENGTH);87  });88  89  itSub('MAX_PROPERTY_VALUE_LENGTH', () => {90    checkConst(api.consts.unique.maxPropertyValueLength, MAX_PROPERTY_VALUE_LENGTH);91  });92  93  itSub('MAX_PROPERTIES_PER_ITEM', () => {94    checkConst(api.consts.unique.maxPropertiesPerItem, MAX_PROPERTIES_PER_ITEM);95  });96  97  itSub('NESTING_BUDGET', () => {98    checkConst(api.consts.unique.nestingBudget, NESTING_BUDGET);99  });100  101  itSub('MAX_TOKEN_PROPERTIES_SIZE', () => {102    checkConst(api.consts.unique.maxTokenPropertiesSize, MAX_TOKEN_PROPERTIES_SIZE);103  });104  105  itSub('COLLECTION_ADMINS_LIMIT', () => {106    checkConst(api.consts.unique.collectionAdminsLimit, COLLECTION_ADMINS_LIMIT);107  });108  109  itSub('HELPERS_CONTRACT_ADDRESS', () => {110    expect(api.consts.evmContractHelpers.contractAddress.toString().toLowerCase()).to.be.equal(HELPERS_CONTRACT_ADDRESS.toLowerCase());111  });112  113  itSub('EVM_COLLECTION_HELPERS_ADDRESS', () => {114    expect(api.consts.common.contractAddress.toString().toLowerCase()).to.be.equal(EVM_COLLECTION_HELPERS_ADDRESS.toLowerCase());115  });116});117118function checkConst<T>(constValue: any, expectedValue: T) {119  expect(constValue.toBigInt()).equal(expectedValue);120}