git.delta.rocks / unique-network / refs/commits / 2c586ed344ac

difftreelog

Move app promotion configuration to globalSetup

Max Andreev2022-12-13parent: #f09b3a8.patch.diff
in: master

2 files changed

modifiedtests/src/app-promotion.test.tsdiffbeforeafterboth
31 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 tests
43 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 });
4744
modifiedtests/src/util/globalSetup.tsdiffbeforeafterboth
--- a/tests/src/util/globalSetup.ts
+++ b/tests/src/util/globalSetup.ts
@@ -18,9 +18,13 @@
           if (!result) Promise.reject();
         });
 
-      // 3. Set up App Promotion admin 
+      // 3. Configure App Promotion 
       const missingPallets = helper.fetchMissingPalletNames([Pallets.AppPromotion]);
       if (missingPallets.length === 0) {
+        // TODO: move to config file
+        const LOCKING_PERIOD = 8n; // 8 blocks of relay
+        const UNLOCKING_PERIOD = 4n; // 4 blocks of parachain
+
         const superuser = await privateKey('//Alice');
         const palletAddress = helper.arrange.calculatePalletAddress('appstake');
         const palletAdmin = await privateKey('//PromotionAdmin');
@@ -29,6 +33,10 @@
         const nominal = helper.balance.getOneTokenNominal();
         await helper.balance.transferToSubstrate(superuser, palletAdmin.address, 1000n * nominal);
         await helper.balance.transferToSubstrate(superuser, palletAddress, 1000n * nominal);
+        await helper.executeExtrinsic(superuser, 'api.tx.sudo.sudo', [api.tx.configuration
+          .setAppPromotionConfigurationOverride({
+            recalculationInterval: LOCKING_PERIOD,
+            pendingInterval: UNLOCKING_PERIOD})], true);
       }
     } catch (error) {
       console.error(error);