Skip to content

Commit

Permalink
Fix broken tests after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
patitonar committed Jan 5, 2023
1 parent 4c9c806 commit 5d510a3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
9 changes: 1 addition & 8 deletions test/unit/StakingPool/depositTo.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
const { ethers } = require('hardhat');
const { expect } = require('chai');

const {
getTranches,
getNewRewardShares,
estimateStakeShares,
POOL_FEE_DENOMINATOR,
setTime,
TRANCHE_DURATION,
} = require('./helpers');
const { getTranches, getNewRewardShares, estimateStakeShares, setTime, TRANCHE_DURATION } = require('./helpers');
const { setEtherBalance, increaseTime } = require('../utils').evm;
const { daysToSeconds } = require('../utils').helpers;

Expand Down
12 changes: 9 additions & 3 deletions test/unit/StakingPool/processExpirations.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,13 @@ describe('processExpirations', function () {
const accFromBeforeToBucketExpiration = nextBucketStartTime
.sub(lastAccNxmUpdateBefore)
.mul(rewardPerSecondBefore)
.mul(parseEther('1'))
.div(rewardsSharesSupply);

const accFromBucketExpirationToTrancheExpiration = trancheEndTime
.sub(nextBucketStartTime)
.mul(rewardPerSecondBefore.sub(nextBucketRewardPerSecondCut))
.mul(parseEther('1'))
.div(rewardsSharesSupply);

expect(expiredTranche.accNxmPerRewardShareAtExpiry).to.equal(
Expand All @@ -314,11 +316,13 @@ describe('processExpirations', function () {
const accFromTrancheExpirationToSecondBucketExpiration = secondNextBucketStartTime
.sub(trancheEndTime)
.mul(rewardPerSecondBefore.sub(nextBucketRewardPerSecondCut))
.mul(parseEther('1'))
.div(rewardsSharesSupply.sub(tranche.rewardsShares));

const accFromSecondBucketExpirationToCurrentTime = BigNumber.from(timestamp)
.sub(secondNextBucketStartTime)
.mul(rewardPerSecondBefore.sub(nextBucketRewardPerSecondCut).sub(secondBucketRewardPerSecondCut))
.mul(parseEther('1'))
.div(rewardsSharesSupply.sub(tranche.rewardsShares));

expect(accNxmPerRewardsShareAfter).to.equal(
Expand Down Expand Up @@ -365,7 +369,7 @@ describe('processExpirations', function () {
expect(expiredBucketRewards).to.equal(rewardPerSecondBefore);
expect(rewardPerSecondAfter).to.equal(rewardPerSecondBefore.sub(expiredBucketRewards));
expect(accNxmPerRewardsShareAfter).to.equal(
accNxmPerRewardsShareBefore.add(elapsed.mul(rewardPerSecondBefore).div(rewardsSharesSupply)),
accNxmPerRewardsShareBefore.add(elapsed.mul(rewardPerSecondBefore).mul(parseEther('1')).div(rewardsSharesSupply)),
);
expect(lastAccNxmUpdateAfter).to.equal(bucketStartTime);
});
Expand Down Expand Up @@ -463,10 +467,12 @@ describe('processExpirations', function () {
const elapsedAfterBucket = BigNumber.from(lastBlock.timestamp).sub(lastAccNxmUpdateBefore);

const accNxmPerRewardsAtBucketEnd = accNxmPerRewardsShareBefore.add(
elapsedInBucket.mul(rewardPerSecondBefore).div(rewardsSharesSupply),
elapsedInBucket.mul(rewardPerSecondBefore).mul(parseEther('1')).div(rewardsSharesSupply),
);
expect(accNxmPerRewardsShareAfter).to.equal(
accNxmPerRewardsAtBucketEnd.add(elapsedAfterBucket.mul(rewardPerSecondAfter).div(rewardsSharesSupply)),
accNxmPerRewardsAtBucketEnd.add(
elapsedAfterBucket.mul(rewardPerSecondAfter).mul(parseEther('1')).div(rewardsSharesSupply),
),
);
expect(lastAccNxmUpdateAfter).to.equal(lastBlock.timestamp);
});
Expand Down
2 changes: 1 addition & 1 deletion test/unit/StakingPool/withdraw.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ describe('withdraw', function () {
const tcBalanceBeforeRewards = await nxm.balanceOf(tokenController.address);

const allocationAmount = parseEther('100');
await generateRewards(stakingPool, coverSigner, allocationAmount);
await generateRewards(stakingPool, coverSigner, undefined, undefined, allocationAmount);

const tcBalanceAfterRewards = await nxm.balanceOf(tokenController.address);
const rewardedAmount = tcBalanceAfterRewards.sub(tcBalanceBeforeRewards);
Expand Down

0 comments on commit 5d510a3

Please sign in to comment.