Skip to content

Commit

Permalink
fix test (#93)
Browse files Browse the repository at this point in the history
* 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;
  • Loading branch information
Vitomir2 authored Jan 16, 2025
1 parent 38a8651 commit 1bec928
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions test/HydraDelegation/VestedDelegation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1564,17 +1564,28 @@ 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,
hydraDelegation,
delegatedValidator.address,
vestManager.address
);

const positionClaimableReward = await hydraDelegation.calculatePositionClaimableReward(
delegatedValidator.address,
vestManager.address,
Expand All @@ -1589,14 +1600,15 @@ export function RunVestedDelegationTests(): void {
delegatedValidator.address,
vestManager.address
));

const positionTotalReward = await hydraDelegation.calculatePositionTotalReward(
delegatedValidator.address,
vestManager.address,
epochNum,
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 () {
Expand Down

0 comments on commit 1bec928

Please sign in to comment.