difftreelog
tests: adjust minimum donor fund structure + fix app-promotion.seqtest's 'after' if the pallet is not present
in: master
3 files changed
tests/src/app-promotion.seqtest.tsdiffbeforeafterboth34 });34 });35 });35 });363637 after(async () => {37 after(async function () {38 await usingPlaygrounds(async (helper) => {38 await usingPlaygrounds(async (helper) => {39 if (helper.fetchMissingPalletNames([Pallets.AppPromotion]).length != 0) return;39 const api = helper.getApi();40 const api = helper.getApi();40 await helper.signTransaction(superuser, api.tx.sudo.sudo(api.tx.appPromotion.setAdminAddress({Substrate: palletAdmin.address})));41 await helper.signTransaction(superuser, api.tx.sudo.sudo(api.tx.appPromotion.setAdminAddress({Substrate: palletAdmin.address})));41 });42 });tests/src/util/globalSetup.tsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// SPDX-License-Identifier: Apache-2.02// SPDX-License-Identifier: Apache-2.0334import {usingPlaygrounds, Pallets} from './index';4import {usingPlaygrounds, Pallets, DONOR_FUNDING, MINIMUM_DONOR_FUND} from './index';5import * as path from 'path';5import * as path from 'path';6import {promises as fs} from 'fs';6import {promises as fs} from 'fs';7767 const account = await privateKey({filename: f, ignoreFundsPresence: true});67 const account = await privateKey({filename: f, ignoreFundsPresence: true});68 const aliceBalance = await helper.balance.getSubstrate(account.address);68 const aliceBalance = await helper.balance.getSubstrate(account.address);696970 if (aliceBalance < 100_000n * oneToken) {70 if (aliceBalance < MINIMUM_DONOR_FUND * oneToken) {71 tx.push(helper.executeExtrinsic(71 tx.push(helper.executeExtrinsic(72 alice, 72 alice, 73 'api.tx.balances.transfer',73 'api.tx.balances.transfer',74 [account.address, 1_000_000n * oneToken],74 [account.address, DONOR_FUNDING * oneToken],75 true,75 true,76 {nonce: nonce + balanceGrantedCounter++},76 {nonce: nonce + balanceGrantedCounter++},77 ).then(() => true).catch(() => {console.error(`Transaction to ${path.basename(f)} registered as failed. Strange.`); return false;}));77 ).then(() => true).catch(() => {console.error(`Transaction to ${path.basename(f)} registered as failed. Strange.`); return false;}));tests/src/util/index.tsdiffbeforeafterboth38 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};5556export const MINIMUM_DONOR_FUND = 100_000n;57export const DONOR_FUNDING = 1_000_000n;555856export enum Pallets {59export enum Pallets {57 Inflation = 'inflation',60 Inflation = 'inflation',