difftreelog
fix app-promotion test
in: master
1 file changed
tests/src/app-promotion.test.tsdiffbeforeafterboth33 requirePalletsOrSkip(this, helper, [Pallets.AppPromotion]);33 requirePalletsOrSkip(this, helper, [Pallets.AppPromotion]);34 donor = await privateKey({filename: __filename});34 donor = await privateKey({filename: __filename});35 palletAddress = helper.arrange.calculatePalletAddress('appstake');35 palletAddress = helper.arrange.calculatePalletAddress('appstake');36 palletAdmin = await privateKey('//Alice');36 palletAdmin = await privateKey('//PromotionAdmin');37 nominal = helper.balance.getOneTokenNominal();37 nominal = helper.balance.getOneTokenNominal();383839 const accountBalances = new Array(100);39 await helper.executeExtrinsic(palletAdmin, 'api.tx.sudo.sudo', [helper.api!.tx.appPromotion.setAdminAddress({Substrate: palletAdmin.address})]);40 accountBalances.fill(1000n);40 await helper.executeExtrinsic(palletAdmin, 'api.tx.sudo.sudo', [helper.api!.tx.configuration41 accounts = await helper.arrange.createAccounts(accountBalances, donor); // create accounts-pool to speed up tests41 .setAppPromotionConfigurationOverride({42 recalculationInterval: LOCKING_PERIOD,43 pendingInterval: UNLOCKING_PERIOD})], true);44 });42 });45 });43 });464447 describe('stake extrinsic', () => { 45 describe('stake extrinsic', () => { 48 itSub('should "lock" staking balance, add it to "staked" map, and increase "totalStaked" amount', async ({helper}) => {46 itSub('should "lock" staking balance, add it to "staked" map, and increase "totalStaked" amount', async ({helper}) => {49 47 const [staker, recepient] = [accounts.pop()!, accounts.pop()!];50 48 const totalStakedBefore = await helper.staking.getTotalStaked();49 50 // Minimum stake amount is 100:51 await expect(helper.staking.stake(staker, 100n * nominal - 1n)).to.be.rejected;52 await helper.staking.stake(staker, 100n * nominal);53 54 // Staker balance is: miscFrozen: 100, feeFrozen: 100, reserved: 0n...55 // ...so he can not transfer 90056 expect (await helper.balance.getSubstrateFull(staker.address)).to.contain({miscFrozen: 100n * nominal, feeFrozen: 100n * nominal, reserved: 0n});57 await expect(helper.balance.transferToSubstrate(staker, recepient.address, 900n * nominal)).to.be.rejectedWith('balances.LiquidityRestrictions');58 59 expect(await helper.staking.getTotalStaked({Substrate: staker.address})).to.be.equal(100n * nominal);60 expect(await helper.balance.getSubstrate(staker.address) / nominal).to.be.equal(999n);61 // it is potentially flaky test. Promotion can credited some tokens. Maybe we need to use closeTo? 62 expect(await helper.staking.getTotalStaked()).to.be.equal(totalStakedBefore + 100n * nominal); // total tokens amount staked in app-promotion increased 63 64 65 await helper.staking.stake(staker, 200n * nominal);66 expect(await helper.staking.getTotalStaked({Substrate: staker.address})).to.be.equal(300n * nominal);67 const totalStakedPerBlock = await helper.staking.getTotalStakedPerBlock({Substrate: staker.address});68 expect(totalStakedPerBlock[0].amount).to.equal(100n * nominal);69 expect(totalStakedPerBlock[1].amount).to.equal(200n * nominal);51 });70 });52 71 53 itSub('should allow to create maximum 10 stakes for account', async ({helper}) => {72 itSub('should allow to create maximum 10 stakes for account', async ({helper}) => {