From 7bc3b32154c905a51e0505e8eae8a25dc1046a8c Mon Sep 17 00:00:00 2001 From: PraetorP Date: Thu, 25 May 2023 04:54:27 +0000 Subject: [PATCH] test(app-promo): migrating falling tests to new behavior (freezes) Test 'should allow to stake() if balance is locked with different id' has been skipped because of app-promo no locks balances anymore --- --- a/tests/src/sub/appPromotion/appPromotion.test.ts +++ b/tests/src/sub/appPromotion/appPromotion.test.ts @@ -78,7 +78,7 @@ }); describe('stake extrinsic', () => { - itSub('should "lock" staking balance, add it to "staked" map, and increase "totalStaked" amount', async ({helper}) => { + itSub('should "freeze" staking balance, add it to "staked" map, and increase "totalStaked" amount', async ({helper}) => { const [staker, recepient] = await getAccounts(2); const totalStakedBefore = await helper.staking.getTotalStaked(); @@ -89,7 +89,7 @@ // Staker balance is: frozen: 100, reserved: 0n... // ...so he can not transfer 900 expect(await helper.balance.getSubstrateFull(staker.address)).to.contain({frozen: 100n * nominal, reserved: 0n}); - expect(await helper.balance.getLocked(staker.address)).to.deep.eq([{id: 'appstake', amount: 100n * nominal, reasons: 'All'}]); + expect(await helper.balance.getFrozen(staker.address)).to.deep.eq([{id: 'appstakeappstake', amount: 100n * nominal}]); await expect(helper.balance.transferToSubstrate(staker, recepient.address, 900n * nominal)).to.be.rejectedWith(/^Token: Frozen$/); expect(await helper.staking.getTotalStaked({Substrate: staker.address})).to.be.equal(100n * nominal); @@ -144,8 +144,8 @@ } }); }); - - itSub('should allow to stake() if balance is locked with different id', async ({helper}) => { + // Now AppPromo makes freezes. Probably this test should be changed\removed. + itSub.skip('should allow to stake() if balance is locked with different id', async ({helper}) => { const [staker] = await getAccounts(1); // staker has tokens locked with vesting id: @@ -218,7 +218,7 @@ // Right after unstake tokens are still locked expect(await helper.staking.getStakesNumber({Substrate: staker.address})).to.eq(0); - expect(await helper.balance.getLocked(staker.address)).to.deep.eq([{id: 'appstake', amount: STAKE_AMOUNT, reasons: 'All'}]); + expect(await helper.balance.getFrozen(staker.address)).to.deep.eq([{id: 'appstakeappstake', amount: STAKE_AMOUNT}]); expect(await helper.balance.getSubstrateFull(staker.address)).to.deep.contain({reserved: 0n, frozen: STAKE_AMOUNT}); // Staker can not transfer await expect(helper.balance.transferToSubstrate(staker, recepient.address, 100n * nominal)).to.be.rejectedWith(/^Token: Frozen$/); --- a/tests/src/util/playgrounds/unique.ts +++ b/tests/src/util/playgrounds/unique.ts @@ -2404,6 +2404,11 @@ const locks = (await this.helper.callRpc('api.query.balances.locks', [address])).toHuman(); return locks.map((lock: any) => { return {id: lock.id, amount: BigInt(lock.amount.replace(/,/g, '')), reasons: lock.reasons}; }); } + + async getFrozen(address: TSubstrateAccount): Promise<[{ id: string, amount: bigint}]> { + const locks = (await this.helper.callRpc('api.query.balances.freezes', [address])).toHuman(); + return locks.map((lock: any) => { return {id: lock.id, amount: BigInt(lock.amount.replace(/,/g, ''))}; }); + } } class EthereumBalanceGroup extends HelperGroup { @@ -2497,6 +2502,15 @@ } /** + * Get frozen balances + * @param address substrate address + * @returns frozen balances with id via api.query.balances.freezes + */ + getFrozen(address: TSubstrateAccount) { + return this.subBalanceGroup.getFrozen(address); + } + + /** * Get ethereum address balance * @param address ethereum address * @example getEthereum("0x9F0583DbB855d...") -- gitstuff