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

difftreelog

source

tests/src/pallet-presence.test.ts1.4 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.modules.map(m => m.name.toString().toLowerCase());12}1314// Pallets that must always be present15const requiredPallets = [16  'nft', 'balances', 'contracts', 'randomnesscollectiveflip', 'system', 'timestamp', 'transactionpayment', 'treasury', 'vesting'17];1819// Pallets that depend on consensus and governance configuration20const consensusPallets = [21  'sudo', 'grandpa', 'aura'22];2324describe('Pallet presence', () => {25  it('Required pallets are present', async () => {26    await usingApi(async api => {27      for (let i=0; i<requiredPallets.length; i++) {28        expect(getModuleNames(api)).to.include(requiredPallets[i]);29      }30    });31  });32  it('Governance and consensus pallets are present', async () => {33    await usingApi(async api => {34      for (let i=0; i<consensusPallets.length; i++) {35        expect(getModuleNames(api)).to.include(consensusPallets[i]);36      }37    });38  });39  it('No extra pallets are included', async () => {40    await usingApi(async api => {41      expect(getModuleNames(api).length).to.be.equal(requiredPallets.length + consensusPallets.length);42    });43  });44});