From a7ca659301d7deb80221ff00403bbef5c81075af Mon Sep 17 00:00:00 2001 From: Vladislav Vasilev <81014877+faust403@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:20:02 +0100 Subject: [PATCH] unbond --- .../src/testcases/lazy-staking.test.ts | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/integration_tests/src/testcases/lazy-staking.test.ts b/integration_tests/src/testcases/lazy-staking.test.ts index ece803f4..9dc4a0b2 100644 --- a/integration_tests/src/testcases/lazy-staking.test.ts +++ b/integration_tests/src/testcases/lazy-staking.test.ts @@ -257,4 +257,51 @@ describe('Lazy Staking', () => { const { amount } = await client.getBalance(account.address, ldntrnDenom); expect(amount).toEqual('1010000000'); }); + + it('Exchange rate now 100', async () => { + const { coreContractClient, account } = context; + await coreContractClient.updateExchangeRate(account.address, { + exchange_rate: '100', + }); + expect(await coreContractClient.queryExchangeRate()).toEqual('100'); + }); + + it("If we have 1010 ldNTRN, they're now equal to 10.1 dNTRN (because 1 dNTRN equals 100 NTRN)", async () => { + const { lazyStakingClient } = context; + const rewards = await lazyStakingClient.queryRewards(); + expect(rewards).toEqual('99900000'); + }); + + it('Unbond tokens back and make sure we have 10.1 dNTRN back', async () => { + const { + lazyStakingClient, + coreContractClient, + account, + ldntrnDenom, + dntrnDenom, + } = context; + const { events } = await lazyStakingClient.unbond( + account.address, + undefined, + undefined, + [ + { + denom: ldntrnDenom, + amount: '1010000000', + }, + ], + ); + const attrs = events + .filter((e) => e.type == 'coin_received') + .map((e) => e.attributes) + .flat(); + expect(attrs).toContainEqual({ + key: 'amount', + value: '10100000' + dntrnDenom, + }); + const core_exchange_rate = Number( + await coreContractClient.queryExchangeRate(), + ); + expect(10100000 * core_exchange_rate).toEqual(1010000000); + }); });