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

difftreelog

Merge pull request #145 from usetech-llc/feature/NFTPAR-413_inflation

Yaroslav Bolyukin2021-04-08parents: #8cfbb8c #0b68862.patch.diff
in: master
Fix pallet presence test

2 files changed

modifiedtests/package.jsondiffbeforeafterboth
--- a/tests/package.json
+++ b/tests/package.json
@@ -51,7 +51,8 @@
     "testSetOffchainSchema": "mocha --timeout 9999999 -r ts-node/register ./**/setOffchainSchema.test.ts",
     "testOverflow": "mocha --timeout 9999999 -r ts-node/register ./**/overflow.test.ts",
     "testSetVariableMetadataSponsoringRateLimit": "mocha --timeout 9999999 -r ts-node/register ./**/setVariableMetadataSponsoringRateLimit.test.ts",
-    "testInflation": "mocha --timeout 9999999 -r ts-node/register ./**/inflation.test.ts"
+    "testInflation": "mocha --timeout 9999999 -r ts-node/register ./**/inflation.test.ts",
+    "testPalletPresence": "mocha --timeout 9999999 -r ts-node/register ./**/pallet-presence.test.ts"
   },
   "author": "",
   "license": "SEE LICENSE IN ../LICENSE",
modifiedtests/src/pallet-presence.test.tsdiffbeforeafterboth
before · tests/src/pallet-presence.test.ts
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});
after · tests/src/pallet-presence.test.ts
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', 'inflation', '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});