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,12 +166,15 @@ 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));
if (membersReward.isGreaterThan(0)) {
// Check that cumulative rewards have increased. // Check that cumulative rewards have increased.
const [ const [
mostRecentCumulativeRewards, mostRecentCumulativeRewards,
cumulativeRewardsLastStored, cumulativeRewardsLastStored,
] = await stakingWrapper.getMostRecentCumulativeReward(poolId).callAsync(); ] = await stakingWrapper.getMostRecentCumulativeReward(poolId).callAsync();
expect(cumulativeRewardsLastStored).to.bignumber.equal(currentEpoch); expect(cumulativeRewardsLastStored).to.bignumber.equal(currentEpoch);
let [numerator, denominator] = ReferenceFunctions.LibFractions.add( let [numerator, denominator] = ReferenceFunctions.LibFractions.add(
beforeInfo.mostRecentCumulativeRewards.numerator, beforeInfo.mostRecentCumulativeRewards.numerator,
beforeInfo.mostRecentCumulativeRewards.denominator, beforeInfo.mostRecentCumulativeRewards.denominator,
@@ -180,6 +183,7 @@ export function validFinalizePoolAssertion(
); );
[numerator, denominator] = ReferenceFunctions.LibFractions.normalize(numerator, denominator); [numerator, denominator] = ReferenceFunctions.LibFractions.normalize(numerator, denominator);
expect(mostRecentCumulativeRewards).to.deep.equal({ 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(