git.delta.rocks / unique-network / refs/commits / 23067ec51dc9

difftreelog

tests: adjust minimum donor fund structure + fix app-promotion.seqtest's 'after' if the pallet is not present

Fahrrader2022-10-13parent: #02e004a.patch.diff
in: master

3 files changed

modifiedtests/src/app-promotion.seqtest.tsdiffbeforeafterboth
--- a/tests/src/app-promotion.seqtest.ts
+++ b/tests/src/app-promotion.seqtest.ts
@@ -34,8 +34,9 @@
     });
   });
 
-  after(async () => {
+  after(async function () {
     await usingPlaygrounds(async (helper) => {
+      if (helper.fetchMissingPalletNames([Pallets.AppPromotion]).length != 0) return;
       const api = helper.getApi();
       await helper.signTransaction(superuser, api.tx.sudo.sudo(api.tx.appPromotion.setAdminAddress({Substrate: palletAdmin.address})));
     });
modifiedtests/src/util/globalSetup.tsdiffbeforeafterboth
--- a/tests/src/util/globalSetup.ts
+++ b/tests/src/util/globalSetup.ts
@@ -1,7 +1,7 @@
 // Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
 // SPDX-License-Identifier: Apache-2.0
 
-import {usingPlaygrounds, Pallets} from './index';
+import {usingPlaygrounds, Pallets, DONOR_FUNDING, MINIMUM_DONOR_FUND} from './index';
 import * as path from 'path';
 import {promises as fs} from 'fs';
 
@@ -67,11 +67,11 @@
         const account = await privateKey({filename: f, ignoreFundsPresence: true});
         const aliceBalance = await helper.balance.getSubstrate(account.address);
 
-        if (aliceBalance < 100_000n * oneToken) {
+        if (aliceBalance < MINIMUM_DONOR_FUND * oneToken) {
           tx.push(helper.executeExtrinsic(
             alice, 
             'api.tx.balances.transfer',
-            [account.address, 1_000_000n * oneToken],
+            [account.address, DONOR_FUNDING * oneToken],
             true,
             {nonce: nonce + balanceGrantedCounter++},
           ).then(() => true).catch(() => {console.error(`Transaction to ${path.basename(f)} registered as failed. Strange.`); return false;}));
modifiedtests/src/util/index.tsdiffbeforeafterboth
38 else {38 else {
39 const actualSeed = getTestSeed(seed.filename);39 const actualSeed = getTestSeed(seed.filename);
40 let account = helper.util.fromSeed(actualSeed, ss58Format);40 let account = helper.util.fromSeed(actualSeed, ss58Format);
41 if (!seed.ignoreFundsPresence && await helper.balance.getSubstrate(account.address) == 0n) {41 if (!seed.ignoreFundsPresence && await helper.balance.getSubstrate(account.address) < MINIMUM_DONOR_FUND) {
42 console.warn(`${path.basename(seed.filename)}: Not enough funds present on the filename account. Using the default one as the donor instead.`);42 console.warn(`${path.basename(seed.filename)}: Not enough funds present on the filename account. Using the default one as the donor instead.`);
43 account = helper.util.fromSeed('//Alice', ss58Format);43 account = helper.util.fromSeed('//Alice', ss58Format);
44 }44 }
53 }53 }
54};54};
55
56export const MINIMUM_DONOR_FUND = 100_000n;
57export const DONOR_FUNDING = 1_000_000n;
5558
56export enum Pallets {59export enum Pallets {
57 Inflation = 'inflation',60 Inflation = 'inflation',