difftreelog
Move app promotion configuration to globalSetup
in: master
2 files changed
tests/src/app-promotion.test.tsdiffbeforeafterboth31 before(async function () {31 before(async function () {32 await usingPlaygrounds(async (helper, privateKey) => {32 await usingPlaygrounds(async (helper, privateKey) => {33 requirePalletsOrSkip(this, helper, [Pallets.AppPromotion]);33 requirePalletsOrSkip(this, helper, [Pallets.AppPromotion]);34 const alice = await privateKey('//Alice');35 donor = await privateKey({filename: __filename});34 donor = await privateKey({filename: __filename});36 palletAddress = helper.arrange.calculatePalletAddress('appstake');35 palletAddress = helper.arrange.calculatePalletAddress('appstake');37 palletAdmin = await privateKey('//PromotionAdmin');36 palletAdmin = await privateKey('//PromotionAdmin');40 const accountBalances = new Array(100);39 const accountBalances = new Array(100);41 accountBalances.fill(1000n);40 accountBalances.fill(1000n);42 accounts = await helper.arrange.createAccounts(accountBalances, donor); // create accounts-pool to speed up tests41 accounts = await helper.arrange.createAccounts(accountBalances, donor); // create accounts-pool to speed up tests43 const api = helper.getApi();44 await helper.executeExtrinsic(alice, 'api.tx.sudo.sudo', [api.tx.configuration.setAppPromotionConfigurationOverride({recalculationInterval: LOCKING_PERIOD, pendingInterval: UNLOCKING_PERIOD})], true);45 });42 });46 });43 });4744tests/src/util/globalSetup.tsdiffbeforeafterboth18 if (!result) Promise.reject();18 if (!result) Promise.reject();19 });19 });202021 // 3. Set up App Promotion admin 21 // 3. Configure App Promotion 22 const missingPallets = helper.fetchMissingPalletNames([Pallets.AppPromotion]);22 const missingPallets = helper.fetchMissingPalletNames([Pallets.AppPromotion]);23 if (missingPallets.length === 0) {23 if (missingPallets.length === 0) {24 // TODO: move to config file25 const LOCKING_PERIOD = 8n; // 8 blocks of relay26 const UNLOCKING_PERIOD = 4n; // 4 blocks of parachain2724 const superuser = await privateKey('//Alice');28 const superuser = await privateKey('//Alice');25 const palletAddress = helper.arrange.calculatePalletAddress('appstake');29 const palletAddress = helper.arrange.calculatePalletAddress('appstake');29 const nominal = helper.balance.getOneTokenNominal();33 const nominal = helper.balance.getOneTokenNominal();30 await helper.balance.transferToSubstrate(superuser, palletAdmin.address, 1000n * nominal);34 await helper.balance.transferToSubstrate(superuser, palletAdmin.address, 1000n * nominal);31 await helper.balance.transferToSubstrate(superuser, palletAddress, 1000n * nominal);35 await helper.balance.transferToSubstrate(superuser, palletAddress, 1000n * nominal);36 await helper.executeExtrinsic(superuser, 'api.tx.sudo.sudo', [api.tx.configuration37 .setAppPromotionConfigurationOverride({38 recalculationInterval: LOCKING_PERIOD,39 pendingInterval: UNLOCKING_PERIOD})], true);32 }40 }33 } catch (error) {41 } catch (error) {34 console.error(error);42 console.error(error);