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

difftreelog

Use chai-subset to test events

Max Andreev2022-12-21parent: #534b1e6.patch.diff
in: master

5 files changed

modifiedtests/package.jsondiffbeforeafterboth
--- a/tests/package.json
+++ b/tests/package.json
@@ -8,11 +8,13 @@
     "@types/chai": "^4.3.3",
     "@types/chai-as-promised": "^7.1.5",
     "@types/chai-like": "^1.1.1",
+    "@types/chai-subset": "^1.3.3",
     "@types/mocha": "^10.0.0",
     "@types/node": "^18.11.2",
     "@typescript-eslint/eslint-plugin": "^5.40.1",
     "@typescript-eslint/parser": "^5.40.1",
     "chai": "^4.3.6",
+    "chai-subset": "^1.6.0",
     "eslint": "^8.25.0",
     "eslint-plugin-mocha": "^10.1.0",
     "mocha": "^10.1.0",
modifiedtests/src/eth/events.test.tsdiffbeforeafterboth
--- a/tests/src/eth/events.test.ts
+++ b/tests/src/eth/events.test.ts
@@ -40,7 +40,7 @@
   const {collectionAddress, events: ethEvents} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
   await helper.wait.newBlocks(1);
   {
-    expect(ethEvents).to.be.like([
+    expect(ethEvents).to.containSubset([
       {
         event: 'CollectionCreated',
         args: {
@@ -49,21 +49,21 @@
         },
       },
     ]);
-    expect(subEvents).to.be.like([{method: 'CollectionCreated'}]);
+    expect(subEvents).to.containSubset([{method: 'CollectionCreated'}]);
     clearEvents(ethEvents, subEvents);
   }
   {
     const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
     const result = await collectionHelper.methods.destroyCollection(collectionAddress).send({from:owner});
     await helper.wait.newBlocks(1);
-    expect(result.events).to.be.like({
+    expect(result.events).to.containSubset({
       CollectionDestroyed: {
         returnValues: {
           collectionId: collectionAddress,
         },
       },
     });
-    expect(subEvents).to.be.like([{method: 'CollectionDestroyed'}]);
+    expect(subEvents).to.containSubset([{method: 'CollectionDestroyed'}]);
   }
   unsubscribe();
 }
@@ -82,7 +82,7 @@
   {
     await collection.methods.setCollectionProperties([{key: 'A', value: [0,1,2,3]}]).send({from:owner});
     await helper.wait.newBlocks(1);
-    expect(ethEvents).to.be.like([
+    expect(ethEvents).to.containSubset([
       {
         event: 'CollectionChanged',
         returnValues: {
@@ -90,13 +90,13 @@
         },
       },
     ]);
-    expect(subEvents).to.be.like([{method: 'CollectionPropertySet'}]);
+    expect(subEvents).to.containSubset([{method: 'CollectionPropertySet'}]);
     clearEvents(ethEvents, subEvents);
   }
   {
     await collection.methods.deleteCollectionProperties(['A']).send({from:owner});
     await helper.wait.newBlocks(1);
-    expect(ethEvents).to.be.like([
+    expect(ethEvents).to.containSubset([
       {
         event: 'CollectionChanged',
         returnValues: {
@@ -104,7 +104,7 @@
         },
       },
     ]);
-    expect(subEvents).to.be.like([{method: 'CollectionPropertyDeleted'}]);
+    expect(subEvents).to.containSubset([{method: 'CollectionPropertyDeleted'}]);
   }
   unsubscribe();
 }
@@ -127,7 +127,7 @@
     ],
   ]).send({from: owner});
   await helper.wait.newBlocks(1);
-  expect(ethEvents).to.be.like([
+  expect(ethEvents).to.containSubset([
     {
       event: 'CollectionChanged',
       returnValues: {
@@ -135,7 +135,7 @@
       },
     },
   ]);
-  expect(subEvents).to.be.like([{method: 'PropertyPermissionSet'}]);
+  expect(subEvents).to.containSubset([{method: 'PropertyPermissionSet'}]);
   unsubscribe();
 }
 
@@ -154,7 +154,7 @@
   {
     await collection.methods.addToCollectionAllowListCross(user).send({from: owner});
     await helper.wait.newBlocks(1);
-    expect(ethEvents).to.be.like([
+    expect(ethEvents).to.containSubset([
       {
         event: 'CollectionChanged',
         returnValues: {
@@ -162,14 +162,14 @@
         },
       },
     ]);
-    expect(subEvents).to.be.like([{method: 'AllowListAddressAdded'}]);
+    expect(subEvents).to.containSubset([{method: 'AllowListAddressAdded'}]);
     clearEvents(ethEvents, subEvents);
   }
   {
     await collection.methods.removeFromCollectionAllowListCross(user).send({from: owner});
     await helper.wait.newBlocks(1);
     expect(ethEvents.length).to.be.eq(1);
-    expect(ethEvents).to.be.like([
+    expect(ethEvents).to.containSubset([
       {
         event: 'CollectionChanged',
         returnValues: {
@@ -177,7 +177,7 @@
         },
       },
     ]);
-    expect(subEvents).to.be.like([{method: 'AllowListAddressRemoved'}]);
+    expect(subEvents).to.containSubset([{method: 'AllowListAddressRemoved'}]);
   }
   unsubscribe();
 }
@@ -196,7 +196,7 @@
   {
     await collection.methods.addCollectionAdminCross(user).send({from: owner});
     await helper.wait.newBlocks(1);
-    expect(ethEvents).to.be.like([
+    expect(ethEvents).to.containSubset([
       {
         event: 'CollectionChanged',
         returnValues: {
@@ -204,13 +204,13 @@
         },
       },
     ]);
-    expect(subEvents).to.be.like([{method: 'CollectionAdminAdded'}]);
+    expect(subEvents).to.containSubset([{method: 'CollectionAdminAdded'}]);
     clearEvents(ethEvents, subEvents);
   }
   {
     await collection.methods.removeCollectionAdminCross(user).send({from: owner});
     await helper.wait.newBlocks(1);
-    expect(ethEvents).to.be.like([
+    expect(ethEvents).to.containSubset([
       {
         event: 'CollectionChanged',
         returnValues: {
@@ -218,7 +218,7 @@
         },
       },
     ]);
-    expect(subEvents).to.be.like([{method: 'CollectionAdminRemoved'}]);
+    expect(subEvents).to.containSubset([{method: 'CollectionAdminRemoved'}]);
   }
   unsubscribe();
 }
@@ -236,7 +236,7 @@
   {
     await collection.methods.setCollectionLimit(CollectionLimits.OwnerCanTransfer, true, 0).send({from: owner});
     await helper.wait.newBlocks(1);
-    expect(ethEvents).to.be.like([
+    expect(ethEvents).to.containSubset([
       {
         event: 'CollectionChanged',
         returnValues: {
@@ -244,7 +244,7 @@
         },
       },
     ]);
-    expect(subEvents).to.be.like([{method: 'CollectionLimitSet'}]);
+    expect(subEvents).to.containSubset([{method: 'CollectionLimitSet'}]);
   }
   unsubscribe();
 }
@@ -263,7 +263,7 @@
   {
     await collection.methods.changeCollectionOwnerCross(newOwner).send({from: owner});
     await helper.wait.newBlocks(1);
-    expect(ethEvents).to.be.like([
+    expect(ethEvents).to.containSubset([
       {
         event: 'CollectionChanged',
         returnValues: {
@@ -271,7 +271,7 @@
         },
       },
     ]);
-    expect(subEvents).to.be.like([{method: 'CollectionOwnerChanged'}]);
+    expect(subEvents).to.containSubset([{method: 'CollectionOwnerChanged'}]);
   }
   unsubscribe();
 }
@@ -289,7 +289,7 @@
   {
     await collection.methods.setCollectionMintMode(true).send({from: owner});
     await helper.wait.newBlocks(1);
-    expect(ethEvents).to.be.like([
+    expect(ethEvents).to.containSubset([
       {
         event: 'CollectionChanged',
         returnValues: {
@@ -297,13 +297,13 @@
         },
       },
     ]);
-    expect(subEvents).to.be.like([{method: 'CollectionPermissionSet'}]);
+    expect(subEvents).to.containSubset([{method: 'CollectionPermissionSet'}]);
     clearEvents(ethEvents, subEvents);
   }
   {
     await collection.methods.setCollectionAccess(1).send({from: owner});
     await helper.wait.newBlocks(1);
-    expect(ethEvents).to.be.like([
+    expect(ethEvents).to.containSubset([
       {
         event: 'CollectionChanged',
         returnValues: {
@@ -311,7 +311,7 @@
         },
       },
     ]);
-    expect(subEvents).to.be.like([{method: 'CollectionPermissionSet'}]);
+    expect(subEvents).to.containSubset([{method: 'CollectionPermissionSet'}]);
   }
   unsubscribe();
 }
@@ -320,7 +320,7 @@
   const owner = await helper.eth.createAccountWithBalance(donor);
   const sponsor = await helper.ethCrossAccount.createAccountWithBalance(donor);
   const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
-  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
+  const collection = helper.ethNativeContract.collection(collectionAddress, mode, owner);
   const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
   const ethEvents: any = [];
   collectionHelper.events.allEvents((_: any, event: any) => {
@@ -332,21 +332,19 @@
   {
     await collection.methods.setCollectionSponsorCross(sponsor).send({from: owner});
     await helper.wait.newBlocks(1);
-    expect(ethEvents).to.be.like([
-      {
-        event: 'CollectionChanged',
-        returnValues: {
-          collectionId: collectionAddress,
-        },
+    expect(ethEvents).to.containSubset([{
+      event: 'CollectionChanged',
+      returnValues: {
+        collectionId: collectionAddress,
       },
-    ]);
-    expect(subEvents).to.be.like([{method: 'CollectionSponsorSet'}]);
+    }]);
+    expect(subEvents).to.containSubset([{method: 'CollectionSponsorSet'}]);
     clearEvents(ethEvents, subEvents);
   }
   {
     await collection.methods.confirmCollectionSponsorship().send({from: sponsor.eth});
     await helper.wait.newBlocks(1);
-    expect(ethEvents).to.be.like([
+    expect(ethEvents).to.containSubset([
       {
         event: 'CollectionChanged',
         returnValues: {
@@ -354,13 +352,13 @@
         },
       },
     ]);
-    expect(subEvents).to.be.like([{method: 'SponsorshipConfirmed'}]);
+    expect(subEvents).to.containSubset([{method: 'SponsorshipConfirmed'}]);
     clearEvents(ethEvents, subEvents);
   }
   {
     await collection.methods.removeCollectionSponsor().send({from: owner});
     await helper.wait.newBlocks(1);
-    expect(ethEvents).to.be.like([
+    expect(ethEvents).to.containSubset([
       {
         event: 'CollectionChanged',
         returnValues: {
@@ -368,7 +366,7 @@
         },
       },
     ]);
-    expect(subEvents).to.be.like([{method: 'CollectionSponsorRemoved'}]);
+    expect(subEvents).to.containSubset([{method: 'CollectionSponsorRemoved'}]);
   }
   unsubscribe();
 }
@@ -376,7 +374,7 @@
 async function testTokenPropertySetAndDeleted(helper: EthUniqueHelper, mode: TCollectionMode) {
   const owner = await helper.eth.createAccountWithBalance(donor);
   const {collectionAddress} = await helper.eth.createCollection(mode, owner, 'A', 'B', 'C');
-  const collection = await helper.ethNativeContract.collection(collectionAddress, mode, owner);
+  const collection = helper.ethNativeContract.collection(collectionAddress, mode, owner);
   const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
   const result = await collection.methods.mint(owner).send({from: owner});
   const tokenId = result.events.Transfer.returnValues.tokenId;
@@ -397,7 +395,7 @@
   {
     await collection.methods.setProperties(tokenId, [{key: 'A', value: [1,2,3]}]).send({from: owner});
     await helper.wait.newBlocks(1);
-    expect(ethEvents).to.be.like([
+    expect(ethEvents).to.containSubset([
       {
         event: 'TokenChanged',
         returnValues: {
@@ -405,13 +403,13 @@
         },
       },
     ]);
-    expect(subEvents).to.be.like([{method: 'TokenPropertySet'}]);
+    expect(subEvents).to.containSubset([{method: 'TokenPropertySet'}]);
     clearEvents(ethEvents, subEvents);
   }
   {
     await collection.methods.deleteProperties(tokenId, ['A']).send({from: owner});
     await helper.wait.newBlocks(1);
-    expect(ethEvents).to.be.like([
+    expect(ethEvents).to.containSubset([
       {
         event: 'TokenChanged',
         returnValues: {
@@ -419,7 +417,7 @@
         },
       },
     ]);
-    expect(subEvents).to.be.like([{method: 'TokenPropertyDeleted'}]);
+    expect(subEvents).to.containSubset([{method: 'TokenPropertyDeleted'}]);
   }
   unsubscribe();
 }
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -402,6 +402,8 @@
         },
       });
     }
+
+    expect(await helper.nft.doesTokenExist(collection.collectionId, token.tokenId)).to.be.false;
   });
   
   itEth('Can perform transfer with ApprovalForAll', async ({helper}) => {
modifiedtests/src/util/index.tsdiffbeforeafterboth
before · tests/src/util/index.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.034import * as path from 'path';5import * as crypto from 'crypto';6import {IKeyringPair} from '@polkadot/types/types/interfaces';7import chai from 'chai';8import chaiAsPromised from 'chai-as-promised';9import {Context} from 'mocha';10import config from '../config';11import {ChainHelperBase} from './playgrounds/unique';12import {ILogger} from './playgrounds/types';13import {DevUniqueHelper, SilentLogger, SilentConsole, DevMoonbeamHelper, DevMoonriverHelper, DevAcalaHelper, DevKaruraHelper, DevRelayHelper, DevWestmintHelper} from './playgrounds/unique.dev';1415chai.use(chaiAsPromised);16export const expect = chai.expect;1718const getTestHash = (filename: string) => {19  return crypto.createHash('md5').update(filename).digest('hex');20};2122export const getTestSeed = (filename: string) => {23  return `//Alice+${getTestHash(filename)}`;24};2526async function usingPlaygroundsGeneral<T extends ChainHelperBase>(helperType: new(logger: ILogger) => T, url: string, code: (helper: T, privateKey: (seed: string | {filename: string, ignoreFundsPresence?: boolean}) => Promise<IKeyringPair>) => Promise<void>) {27  const silentConsole = new SilentConsole();28  silentConsole.enable();2930  const helper = new helperType(new SilentLogger());3132  try {33    await helper.connect(url);34    const ss58Format = helper.chain.getChainProperties().ss58Format;35    const privateKey = async (seed: string | {filename: string, ignoreFundsPresence?: boolean}) => {36      if (typeof seed === 'string') {37        return helper.util.fromSeed(seed, ss58Format);38      }39      else {40        const actualSeed = getTestSeed(seed.filename);41        let account = helper.util.fromSeed(actualSeed, ss58Format);42        // here's to hoping that no 43        if (!seed.ignoreFundsPresence && ((helper as any)['balance'] == undefined || await (helper as any).balance.getSubstrate(account.address) < MINIMUM_DONOR_FUND)) {44          console.warn(`${path.basename(seed.filename)}: Not enough funds present on the filename account. Using the default one as the donor instead.`);45          account = helper.util.fromSeed('//Alice', ss58Format);46        }47        return account;48      }49    };50    await code(helper, privateKey);51  }52  finally {53    await helper.disconnect();54    silentConsole.disable();55  }56}5758export const usingPlaygrounds = (code: (helper: DevUniqueHelper, privateKey: (seed: string | {filename: string, ignoreFundsPresence?: boolean}) => Promise<IKeyringPair>) => Promise<void>, url: string = config.substrateUrl) => {59  return usingPlaygroundsGeneral<DevUniqueHelper>(DevUniqueHelper, url, code);60};6162export const usingWestmintPlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {63  return usingPlaygroundsGeneral<DevWestmintHelper>(DevWestmintHelper, url, code);64};6566export const usingRelayPlaygrounds = (url: string, code: (helper: DevRelayHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {67  return usingPlaygroundsGeneral<DevRelayHelper>(DevRelayHelper, url, code);68};6970export const usingAcalaPlaygrounds = (url: string, code: (helper: DevAcalaHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {71  return usingPlaygroundsGeneral<DevAcalaHelper>(DevAcalaHelper, url, code);72};7374export const usingKaruraPlaygrounds = (url: string, code: (helper: DevKaruraHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {75  return usingPlaygroundsGeneral<DevKaruraHelper>(DevAcalaHelper, url, code);76};7778export const usingMoonbeamPlaygrounds = (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {79  return usingPlaygroundsGeneral<DevMoonbeamHelper>(DevMoonbeamHelper, url, code);80};8182export const usingMoonriverPlaygrounds = (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {83  return usingPlaygroundsGeneral<DevMoonriverHelper>(DevMoonriverHelper, url, code);84};8586export const MINIMUM_DONOR_FUND = 100_000n;87export const DONOR_FUNDING = 1_000_000n;8889// App-promotion periods:90export const LOCKING_PERIOD = 12n; // 12 blocks of relay91export const UNLOCKING_PERIOD = 6n; // 6 blocks of parachain929394export enum Pallets {95  Inflation = 'inflation',96  RmrkCore = 'rmrkcore',97  RmrkEquip = 'rmrkequip',98  ReFungible = 'refungible',99  Fungible = 'fungible',100  NFT = 'nonfungible',101  Scheduler = 'scheduler',102  AppPromotion = 'apppromotion',103  TestUtils = 'testutils',104}105106export function requirePalletsOrSkip(test: Context, helper: DevUniqueHelper, requiredPallets: string[]) {107  const missingPallets = helper.fetchMissingPalletNames(requiredPallets);108    109  if (missingPallets.length > 0) {110    const skipMsg = `\tSkipping test '${test.test?.title}'.\n\tThe following pallets are missing:\n\t- ${missingPallets.join('\n\t- ')}`;111    console.warn('\x1b[38:5:208m%s\x1b[0m', skipMsg);112    test.skip();113  }114}115116export function itSub(name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {117  (opts.only ? it.only : 118    opts.skip ? it.skip : it)(name, async function () {119    await usingPlaygrounds(async (helper, privateKey) => {120      if (opts.requiredPallets) {121        requirePalletsOrSkip(this, helper, opts.requiredPallets);122      }123      124      await cb({helper, privateKey});125    });126  });127}128export function itSubIfWithPallet(name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {129  return itSub(name, cb, {requiredPallets: required, ...opts});130}131itSub.only = (name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSub(name, cb, {only: true});132itSub.skip = (name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSub(name, cb, {skip: true});133134itSubIfWithPallet.only = (name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSubIfWithPallet(name, required, cb, {only: true});135itSubIfWithPallet.skip = (name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSubIfWithPallet(name, required, cb, {skip: true});136itSub.ifWithPallets = itSubIfWithPallet;137138export type SchedKind = 'anon' | 'named';139140export function itSched(141  name: string,142  cb: (schedKind: SchedKind, apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any,143  opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {},144) {145  itSub(name + ' (anonymous scheduling)', (apis) => cb('anon', apis), opts);146  itSub(name + ' (named scheduling)', (apis) => cb('named', apis), opts);147}148itSched.only = (name: string, cb: (schedKind: SchedKind, apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSched(name, cb, {only: true});149itSched.skip = (name: string, cb: (schedKind: SchedKind, apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSched(name, cb, {skip: true});150itSched.ifWithPallets = itSchedIfWithPallets;151152function itSchedIfWithPallets(name: string, required: string[], cb: (schedKind: SchedKind, apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {153  return itSched(name, cb, {requiredPallets: required, ...opts});154}155156export function describeXCM(title: string, fn: (this: Mocha.Suite) => void, opts: {skip?: boolean} = {}) {157  (process.env.RUN_XCM_TESTS && !opts.skip158    ? describe159    : describe.skip)(title, fn);160}161162describeXCM.skip = (name: string, fn: (this: Mocha.Suite) => void) => describeXCM(name, fn, {skip: true});
after · tests/src/util/index.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.034import * as path from 'path';5import * as crypto from 'crypto';6import {IKeyringPair} from '@polkadot/types/types/interfaces';7import chai from 'chai';8import chaiAsPromised from 'chai-as-promised';9import chaiSubset from 'chai-subset';10import {Context} from 'mocha';11import config from '../config';12import {ChainHelperBase} from './playgrounds/unique';13import {ILogger} from './playgrounds/types';14import {DevUniqueHelper, SilentLogger, SilentConsole, DevMoonbeamHelper, DevMoonriverHelper, DevAcalaHelper, DevKaruraHelper, DevRelayHelper, DevWestmintHelper} from './playgrounds/unique.dev';1516chai.use(chaiAsPromised);17chai.use(chaiSubset);18export const expect = chai.expect;1920const getTestHash = (filename: string) => {21  return crypto.createHash('md5').update(filename).digest('hex');22};2324export const getTestSeed = (filename: string) => {25  return `//Alice+${getTestHash(filename)}`;26};2728async function usingPlaygroundsGeneral<T extends ChainHelperBase>(helperType: new(logger: ILogger) => T, url: string, code: (helper: T, privateKey: (seed: string | {filename: string, ignoreFundsPresence?: boolean}) => Promise<IKeyringPair>) => Promise<void>) {29  const silentConsole = new SilentConsole();30  silentConsole.enable();3132  const helper = new helperType(new SilentLogger());3334  try {35    await helper.connect(url);36    const ss58Format = helper.chain.getChainProperties().ss58Format;37    const privateKey = async (seed: string | {filename: string, ignoreFundsPresence?: boolean}) => {38      if (typeof seed === 'string') {39        return helper.util.fromSeed(seed, ss58Format);40      }41      else {42        const actualSeed = getTestSeed(seed.filename);43        let account = helper.util.fromSeed(actualSeed, ss58Format);44        // here's to hoping that no 45        if (!seed.ignoreFundsPresence && ((helper as any)['balance'] == undefined || await (helper as any).balance.getSubstrate(account.address) < MINIMUM_DONOR_FUND)) {46          console.warn(`${path.basename(seed.filename)}: Not enough funds present on the filename account. Using the default one as the donor instead.`);47          account = helper.util.fromSeed('//Alice', ss58Format);48        }49        return account;50      }51    };52    await code(helper, privateKey);53  }54  finally {55    await helper.disconnect();56    silentConsole.disable();57  }58}5960export const usingPlaygrounds = (code: (helper: DevUniqueHelper, privateKey: (seed: string | {filename: string, ignoreFundsPresence?: boolean}) => Promise<IKeyringPair>) => Promise<void>, url: string = config.substrateUrl) => {61  return usingPlaygroundsGeneral<DevUniqueHelper>(DevUniqueHelper, url, code);62};6364export const usingWestmintPlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {65  return usingPlaygroundsGeneral<DevWestmintHelper>(DevWestmintHelper, url, code);66};6768export const usingRelayPlaygrounds = (url: string, code: (helper: DevRelayHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {69  return usingPlaygroundsGeneral<DevRelayHelper>(DevRelayHelper, url, code);70};7172export const usingAcalaPlaygrounds = (url: string, code: (helper: DevAcalaHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {73  return usingPlaygroundsGeneral<DevAcalaHelper>(DevAcalaHelper, url, code);74};7576export const usingKaruraPlaygrounds = (url: string, code: (helper: DevKaruraHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {77  return usingPlaygroundsGeneral<DevKaruraHelper>(DevAcalaHelper, url, code);78};7980export const usingMoonbeamPlaygrounds = (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {81  return usingPlaygroundsGeneral<DevMoonbeamHelper>(DevMoonbeamHelper, url, code);82};8384export const usingMoonriverPlaygrounds = (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {85  return usingPlaygroundsGeneral<DevMoonriverHelper>(DevMoonriverHelper, url, code);86};8788export const MINIMUM_DONOR_FUND = 100_000n;89export const DONOR_FUNDING = 1_000_000n;9091// App-promotion periods:92export const LOCKING_PERIOD = 12n; // 12 blocks of relay93export const UNLOCKING_PERIOD = 6n; // 6 blocks of parachain949596export enum Pallets {97  Inflation = 'inflation',98  RmrkCore = 'rmrkcore',99  RmrkEquip = 'rmrkequip',100  ReFungible = 'refungible',101  Fungible = 'fungible',102  NFT = 'nonfungible',103  Scheduler = 'scheduler',104  AppPromotion = 'apppromotion',105  TestUtils = 'testutils',106}107108export function requirePalletsOrSkip(test: Context, helper: DevUniqueHelper, requiredPallets: string[]) {109  const missingPallets = helper.fetchMissingPalletNames(requiredPallets);110    111  if (missingPallets.length > 0) {112    const skipMsg = `\tSkipping test '${test.test?.title}'.\n\tThe following pallets are missing:\n\t- ${missingPallets.join('\n\t- ')}`;113    console.warn('\x1b[38:5:208m%s\x1b[0m', skipMsg);114    test.skip();115  }116}117118export function itSub(name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {119  (opts.only ? it.only : 120    opts.skip ? it.skip : it)(name, async function () {121    await usingPlaygrounds(async (helper, privateKey) => {122      if (opts.requiredPallets) {123        requirePalletsOrSkip(this, helper, opts.requiredPallets);124      }125      126      await cb({helper, privateKey});127    });128  });129}130export function itSubIfWithPallet(name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {131  return itSub(name, cb, {requiredPallets: required, ...opts});132}133itSub.only = (name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSub(name, cb, {only: true});134itSub.skip = (name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSub(name, cb, {skip: true});135136itSubIfWithPallet.only = (name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSubIfWithPallet(name, required, cb, {only: true});137itSubIfWithPallet.skip = (name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSubIfWithPallet(name, required, cb, {skip: true});138itSub.ifWithPallets = itSubIfWithPallet;139140export type SchedKind = 'anon' | 'named';141142export function itSched(143  name: string,144  cb: (schedKind: SchedKind, apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any,145  opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {},146) {147  itSub(name + ' (anonymous scheduling)', (apis) => cb('anon', apis), opts);148  itSub(name + ' (named scheduling)', (apis) => cb('named', apis), opts);149}150itSched.only = (name: string, cb: (schedKind: SchedKind, apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSched(name, cb, {only: true});151itSched.skip = (name: string, cb: (schedKind: SchedKind, apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSched(name, cb, {skip: true});152itSched.ifWithPallets = itSchedIfWithPallets;153154function itSchedIfWithPallets(name: string, required: string[], cb: (schedKind: SchedKind, apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {155  return itSched(name, cb, {requiredPallets: required, ...opts});156}157158export function describeXCM(title: string, fn: (this: Mocha.Suite) => void, opts: {skip?: boolean} = {}) {159  (process.env.RUN_XCM_TESTS && !opts.skip160    ? describe161    : describe.skip)(title, fn);162}163164describeXCM.skip = (name: string, fn: (this: Mocha.Suite) => void) => describeXCM(name, fn, {skip: true});
modifiedtests/yarn.lockdiffbeforeafterboth
--- a/tests/yarn.lock
+++ b/tests/yarn.lock
@@ -979,6 +979,13 @@
   dependencies:
     "@types/chai" "*"
 
+"@types/chai-subset@^1.3.3":
+  version "1.3.3"
+  resolved "https://registry.yarnpkg.com/@types/chai-subset/-/chai-subset-1.3.3.tgz#97893814e92abd2c534de422cb377e0e0bdaac94"
+  integrity sha512-frBecisrNGz+F4T6bcc+NLeolfiojh5FxW2klu669+8BARtyQv2C/GkNW6FUodVe4BroGMP/wER/YDGc7rEllw==
+  dependencies:
+    "@types/chai" "*"
+
 "@types/chai@*", "@types/chai@^4.3.3":
   version "4.3.4"
   resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.3.4.tgz#e913e8175db8307d78b4e8fa690408ba6b65dee4"
@@ -1569,6 +1576,11 @@
   resolved "https://registry.yarnpkg.com/chai-like/-/chai-like-1.1.1.tgz#8c558a414c34514e814d497c772547ceb7958f64"
   integrity sha512-VKa9z/SnhXhkT1zIjtPACFWSoWsqVoaz1Vg+ecrKo5DCKVlgL30F/pEyEvXPBOVwCgLZcWUleCM/C1okaKdTTA==
 
+chai-subset@^1.6.0:
+  version "1.6.0"
+  resolved "https://registry.yarnpkg.com/chai-subset/-/chai-subset-1.6.0.tgz#a5d0ca14e329a79596ed70058b6646bd6988cfe9"
+  integrity sha512-K3d+KmqdS5XKW5DWPd5sgNffL3uxdDe+6GdnJh3AYPhwnBGRY5urfvfcbRtWIvvpz+KxkL9FeBB6MZewLUNwug==
+
 chai@^4.3.6:
   version "4.3.7"
   resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.7.tgz#ec63f6df01829088e8bf55fca839bcd464a8ec51"