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

difftreelog

source

tests/src/pallet-presence.test.ts1.7 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 {ApiPromise} from '@polkadot/api';7import {expect} from 'chai';8import usingApi from './substrate/substrate-api';910function getModuleNames(api: ApiPromise): string[] {11  return api.runtimeMetadata.asLatest.pallets.map(m => m.name.toString().toLowerCase());12}1314// Pallets that must always be present15const requiredPallets = [16  'balances',17  'common',18  'randomnesscollectiveflip',19  'timestamp',20  'transactionpayment',21  'treasury',22  'system',23  'vesting',24  'parachainsystem',25  'parachaininfo',26  'evm',27  'evmcodersubstrate',28  'evmcontracthelpers',29  'evmmigration',30  'evmtransactionpayment',31  'ethereum',32  'fungible',33  'xcmpqueue',34  'polkadotxcm',35  'cumulusxcm',36  'dmpqueue',37  'inflation',38  'nft',39  'nonfungible',40  'refungible',41  'scheduler',42  'nftpayment',43  'charging',44];4546// Pallets that depend on consensus and governance configuration47const consensusPallets = [48  'sudo',49  'aura',50  'auraext',51];5253describe('Pallet presence', () => {54  it('Required pallets are present', async () => {55    await usingApi(async api => {56      for (let i=0; i<requiredPallets.length; i++) {57        expect(getModuleNames(api)).to.include(requiredPallets[i]);58      }59    });60  });61  it('Governance and consensus pallets are present', async () => {62    await usingApi(async api => {63      for (let i=0; i<consensusPallets.length; i++) {64        expect(getModuleNames(api)).to.include(consensusPallets[i]);65      }66    });67  });68  it('No extra pallets are included', async () => {69    await usingApi(async api => {70      expect(getModuleNames(api).sort()).to.be.deep.equal([...requiredPallets, ...consensusPallets].sort());71    });72  });73});