From 1bec9285e663455bd22754f3b15286bdb3c49a57 Mon Sep 17 00:00:00 2001 From: Vitomir Pavlov Date: Thu, 16 Jan 2025 09:22:56 +0200 Subject: [PATCH] fix test (#93) * commit epochs to enter the maturing phase in the "should successfully calculate the total reward for currently maturing position" test; * add check to ensure that the position is maturing; --- test/HydraDelegation/VestedDelegation.test.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/HydraDelegation/VestedDelegation.test.ts b/test/HydraDelegation/VestedDelegation.test.ts index a391598f..99c8b5ae 100644 --- a/test/HydraDelegation/VestedDelegation.test.ts +++ b/test/HydraDelegation/VestedDelegation.test.ts @@ -1564,10 +1564,20 @@ export function RunVestedDelegationTests(): void { }); it("should successfully calculate the total reward for currently maturing position", async function () { - const { systemHydraChain, hydraDelegation, delegatedValidator, vestManager } = await loadFixture( + const { systemHydraChain, hydraStaking, hydraDelegation, delegatedValidator, vestManager } = await loadFixture( this.fixtures.vestedDelegationFixture ); + // commit epochs and increase time to make the position matured & commit epochs + await commitEpochs(systemHydraChain, hydraStaking, [delegatedValidator], 10, this.epochSize, WEEK); + + // ensure that the position is maturing + const isMaturing = await hydraDelegation.isMaturingDelegatePosition( + delegatedValidator.address, + vestManager.address + ); + expect(isMaturing, "isMaturing").to.be.true; + // prepare params for call let { epochNum, balanceChangeIndex } = await getClaimableRewardRPSData( systemHydraChain, @@ -1575,6 +1585,7 @@ export function RunVestedDelegationTests(): void { delegatedValidator.address, vestManager.address ); + const positionClaimableReward = await hydraDelegation.calculatePositionClaimableReward( delegatedValidator.address, vestManager.address, @@ -1589,6 +1600,7 @@ export function RunVestedDelegationTests(): void { delegatedValidator.address, vestManager.address )); + const positionTotalReward = await hydraDelegation.calculatePositionTotalReward( delegatedValidator.address, vestManager.address, @@ -1596,7 +1608,7 @@ export function RunVestedDelegationTests(): void { balanceChangeIndex ); - expect(positionClaimableReward).to.lt(positionTotalReward); + expect(positionClaimableReward, "positionClaimableReward").to.lt(positionTotalReward); }); it("should not claim if position is matured but we pass old RPS data", async function () {