fix bug in finalizePool

This commit is contained in:
Michael Zhu 2020-01-08 18:09:01 -08:00
parent c36d0fdc7c
commit c5b2991821

View File

@ -166,20 +166,24 @@ export function validFinalizePoolAssertion(
// Check that pool rewards have increased. // Check that pool rewards have increased.
const poolRewards = await stakingWrapper.rewardsByPoolId(poolId).callAsync(); const poolRewards = await stakingWrapper.rewardsByPoolId(poolId).callAsync();
expect(poolRewards).to.bignumber.equal(beforeInfo.poolRewards.plus(membersReward)); expect(poolRewards).to.bignumber.equal(beforeInfo.poolRewards.plus(membersReward));
// Check that cumulative rewards have increased.
const [ if (membersReward.isGreaterThan(0)) {
mostRecentCumulativeRewards, // Check that cumulative rewards have increased.
cumulativeRewardsLastStored, const [
] = await stakingWrapper.getMostRecentCumulativeReward(poolId).callAsync(); mostRecentCumulativeRewards,
expect(cumulativeRewardsLastStored).to.bignumber.equal(currentEpoch); cumulativeRewardsLastStored,
let [numerator, denominator] = ReferenceFunctions.LibFractions.add( ] = await stakingWrapper.getMostRecentCumulativeReward(poolId).callAsync();
beforeInfo.mostRecentCumulativeRewards.numerator, expect(cumulativeRewardsLastStored).to.bignumber.equal(currentEpoch);
beforeInfo.mostRecentCumulativeRewards.denominator,
membersReward, let [numerator, denominator] = ReferenceFunctions.LibFractions.add(
beforeInfo.poolStats.membersStake, beforeInfo.mostRecentCumulativeRewards.numerator,
); beforeInfo.mostRecentCumulativeRewards.denominator,
[numerator, denominator] = ReferenceFunctions.LibFractions.normalize(numerator, denominator); membersReward,
expect(mostRecentCumulativeRewards).to.deep.equal({ numerator, denominator }); beforeInfo.poolStats.membersStake,
);
[numerator, denominator] = ReferenceFunctions.LibFractions.normalize(numerator, denominator);
expect(mostRecentCumulativeRewards).to.deep.equal({ numerator, denominator });
}
// Check that aggregated stats have been updated // Check that aggregated stats have been updated
const aggregatedStats = AggregatedStats.fromArray( const aggregatedStats = AggregatedStats.fromArray(