git.delta.rocks / unique-network / refs/commits / 7bc3b32154c9

difftreelog

test(app-promo) migrating falling tests to new behavior (freezes)

PraetorP2023-05-25parent: #5c283c1.patch.diff
in: master
Test 'should allow to stake() if balance is locked with different id' has been skipped because of app-promo no locks balances anymore

2 files changed

modifiedtests/src/sub/appPromotion/appPromotion.test.tsdiffbeforeafterboth
--- 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$/);
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
2405 return locks.map((lock: any) => { return {id: lock.id, amount: BigInt(lock.amount.replace(/,/g, '')), reasons: lock.reasons}; });2405 return locks.map((lock: any) => { return {id: lock.id, amount: BigInt(lock.amount.replace(/,/g, '')), reasons: lock.reasons}; });
2406 }2406 }
2407
2408 async getFrozen(address: TSubstrateAccount): Promise<[{ id: string, amount: bigint}]> {
2409 const locks = (await this.helper.callRpc('api.query.balances.freezes', [address])).toHuman();
2410 return locks.map((lock: any) => { return {id: lock.id, amount: BigInt(lock.amount.replace(/,/g, ''))}; });
2411 }
2407}2412}
24082413
2409class EthereumBalanceGroup<T extends ChainHelperBase> extends HelperGroup<T> {2414class EthereumBalanceGroup<T extends ChainHelperBase> extends HelperGroup<T> {
2496 return this.subBalanceGroup.getLocked(address);2501 return this.subBalanceGroup.getLocked(address);
2497 }2502 }
2503
2504 /**
2505 * Get frozen balances
2506 * @param address substrate address
2507 * @returns frozen balances with id via api.query.balances.freezes
2508 */
2509 getFrozen(address: TSubstrateAccount) {
2510 return this.subBalanceGroup.getFrozen(address);
2511 }
24982512
2499 /**2513 /**
2500 * Get ethereum address balance2514 * Get ethereum address balance