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

difftreelog

source

tests/src/pallet-presence.test.ts1.3 KiBsourcehistory
1import { ApiPromise } from "@polkadot/api";2import { expect } from "chai";3import usingApi from "./substrate/substrate-api";45function getModuleNames(api: ApiPromise): string[] {6  return api.runtimeMetadata.asLatest.modules.map(m => m.name.toString().toLowerCase());7}89// Pallets that must always be present10const requiredPallets = [11  'nft', 'balances', 'contracts', 'randomnesscollectiveflip', 'system', 'timestamp', 'transactionpayment', 'treasury', 'vesting'12];1314// Pallets that depend on consensus and governance configuration15const consensusPallets = [16  'sudo', 'grandpa', 'aura'17];1819describe('Pallet presence', () => {20  it('Required pallets are present', async () => {21    await usingApi(async api => {22      for (let i=0; i<requiredPallets.length; i++) {23        expect(getModuleNames(api)).to.include(requiredPallets[i]);24      }25    });26  });27  it('Governance and consensus pallets are present', async () => {28    await usingApi(async api => {29      for (let i=0; i<consensusPallets.length; i++) {30        expect(getModuleNames(api)).to.include(consensusPallets[i]);31      }32    });33  });34  it('No extra pallets are included', async () => {35    await usingApi(async api => {36      expect(getModuleNames(api).length).to.be.equal(requiredPallets.length + consensusPallets.length);37    });38  });39});