1234567891011121314151617import {ApiPromise} from '@polkadot/api';18import {expect} from 'chai';19import usingApi from './substrate/substrate-api';2021function getModuleNames(api: ApiPromise): string[] {22 return api.runtimeMetadata.asLatest.pallets.map(m => m.name.toString().toLowerCase());23}242526const requiredPallets = [27 'balances',28 'common',29 'randomnesscollectiveflip',30 'timestamp',31 'transactionpayment',32 'treasury',33 'structure',34 'system',35 'vesting',36 'parachainsystem',37 'parachaininfo',38 'evm',39 'evmcodersubstrate',40 'evmcontracthelpers',41 'evmmigration',42 'evmtransactionpayment',43 'ethereum',44 'fungible',45 'xcmpqueue',46 'polkadotxcm',47 'cumulusxcm',48 'dmpqueue',49 'inflation',50 'unique',51 'nonfungible',52 'charging',53 'configuration',54 'tokens',55 'xtokens',56];575859const consensusPallets = [60 'sudo',61 'aura',62 'auraext',63];6465describe('Pallet presence', () => {66 before(async () => {67 await usingApi(async api => {68 const chain = await api.rpc.system.chain();6970 const refungible = 'refungible';71 const scheduler = 'scheduler';72 const foreignAssets = 'foreignassets';73 const rmrkPallets = ['rmrkcore', 'rmrkequip'];7475 if (chain.eq('OPAL by UNIQUE')) {76 requiredPallets.push(77 refungible,78 scheduler,79 foreignAssets,80 ...rmrkPallets,81 );82 } else if (chain.eq('QUARTZ by UNIQUE')) {83 84 } else if (chain.eq('UNIQUE')) {85 86 }87 });88 });8990 it('Required pallets are present', async () => {91 await usingApi(async api => {92 for (let i=0; i<requiredPallets.length; i++) {93 expect(getModuleNames(api)).to.include(requiredPallets[i]);94 }95 });96 });97 it('Governance and consensus pallets are present', async () => {98 await usingApi(async api => {99 for (let i=0; i<consensusPallets.length; i++) {100 expect(getModuleNames(api)).to.include(consensusPallets[i]);101 }102 });103 });104 it('No extra pallets are included', async () => {105 await usingApi(async api => {106 expect(getModuleNames(api).sort()).to.be.deep.equal([...requiredPallets, ...consensusPallets].sort());107 });108 });109});